Closed DigitalBrains1 closed 3 years ago
I changed one change (I thought I had already done this but I thought wrong):
@@ -226,7 +226,7 @@ extern "C" int strcmp(const char *s1, const char *s2) throw();
static void _test_wattgauge()
{
- struct { const char *const tm; unsigned long val; } data[] = {
+ struct { const char *const tm; int val; } data[] = {
These values are actually used as int
s. I only changed the _test_energygauge()
in the way I intended.
There's no functional difference as they were cast to int
anyway.
The computations done on time intervals were somewhat confused. Masking out the sign bit of a
signed long
does not result in correct interval computations (okay, if the mask was again applied to the result of a computation, it actually would, but this was not done). This resulted in a situation whereWattGauge
could get stuck untilreset()
was called. In practice, this call happens often and it would get unstuck, merely reporting wrong values for some time.The type of
millis()
is unsigned anyway, As It Should Be(TM).Along with changing the type of time values to
unsigned long
, I changed the type ofWattGauge._p
, because otherwise it would have just stuck out like a sore thumb here: