getTime() not consistently reporting correct time information. #4092
Replies: 1 comment
-
Posted at 2022-10-30 by brian150509 Think I solved the problem by calling clearWatch(). Will keep you posted. Posted at 2022-10-31 by @gfwilliams I'd imagine the issue is:
If this gets called twice in quick succession then the second time it's called you'll get a very small time period reported. Posted at 2022-11-01 by brian150509 Thanks. That worked too. I had written a workaround to say if the reading was too small then skip. But denounce:20 accomplishes the same thing. Thank you. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2022-10-28 by brian150509
I've tried creating an electric pulse meter with the puck js 2.1 The code works on occasion but then starts reporting funny values for watts. The general idea of the code is to get the current time, compare it with the previous time of the last pulse and use the time difference to calculate the watts. Sometimes however, even though i can tell from the logs that say the last pulse time was 12 or so seconds ago, the calculation only reads .01 of a second therefore throwing the calculation off. It's not consistent, sometimes it gets it bang on, other times not. For instance I ran it yesterday for the first time, it seem to run fine for a few hours but then started reporting erroneous values. When i ran updated code 10 minutes ago with better logging, i can see that every second reading is correct. Note originally i was using Date.now() for the time, but then tried getTime() to see if it would fix the issue, but it did not. Please see logs and code below.
Here are the logs
Beta Was this translation helpful? Give feedback.
All reactions