if value has changed less than 2

so I'm building this weather station thing for mominlaw and its working reasonable good

doing some long-term testing I have found that the radio connection can get some false values that make to go crazy like adding 4000 mm of rain in one hour and no I don't live in a rainforest :stuck_out_tongue:

I thought that the problem only happens once in a while and it must be a disturbance from another transmitter around where I live and I have no control over it

currently i update the display this way:

if (remoteHours != previousRemoteHours)
{

my thought was expanding it to only update if the change in value is less than 2

that goes for every value in date and clock and the rain count as it would not be able to tip more than one time during a transmission of values.. not even if I put a whole cup of water in the rain gauge

how do i: if value has changed less than 2?

i googled for it but only got more confused

Take the difference of two consecutive values.
If the absolute value of the difference is less than two . . . Do or don't do your thing.

so: if (remoteHours - previousRemoteHours < 2)

or did i screw a simple task?

oh.... abs let me google a bit

can i do it in this way?

if abs(remoteHours - previousRemoteHours) < 2

{

do this

}

can i do it in this way?

The compiler won't like it like that but that's the general idea.

hehe

it might not like it, but at least a dummie like me understand it

you are right

might not like it in this case means a fail to compile

so how do i make it enough complicated that the compiler likes it?

i thought just subtracting the 2 values and do a thing if the difference was less than 2 would be simple

if (someCondition)

Those () really make a difference.

DOH :confused: :smiley:

of course

laughs on me