matsstaff/stc1000p

Suspicious RANGE() function

Closed this issue · 3 comments

Hello,

I was really looking forward to using this program on my STC-1000, but unfortunately I got a version with a Holtek processor on it rather than the Microchip part.

However, in looking through the code briefly, I found a potential problem that you might want to take a look at:

static int RANGE(int x, int min, int max){
if(x>max)
return min;
if(x<min)
return max;
return x;
}

If x is greater than the max, then the min is returned!? Seems like the max should be returned. Same kinda deal for x less than min.

Hi!
Thanks for the report! It is nice to know someone gives a hoot :)
However, it is really the name of the function that is misleading. It is used to limit the values that you enter with the keypad. I personally (as I think a lot of others would also), prefer it to 'roll over' when max of min is reached, instead of going all the way back in the other direction.
But you are correct in that it is not really a range. I just don't really have a better name...

Cheers!

OK, I get it. It's a rollover, not a clipper.

Well, no harm, no foul.

Keep on brewing,

Art

Mats,

Just wanted to let you know that I ended up buying an STC-1000+ with dual
probes from Will at Black Box Brew.

Thanks again for your hard work,

Art

On Tue, Mar 10, 2015 at 12:30 PM, matsstaff notifications@github.com
wrote:

Hi!
Thanks for the report! It is nice to know someone gives a hoot :)
However, it is really the name of the function that is misleading. It is
used to limit the values that you enter with the keypad. I personally (as I
think a lot of others would also), prefer it to 'roll over' when max of min
is reached, instead of going all the way back in the other direction.
But you are correct in that it is not really a range. I just don't really
have a better name...

Cheers!


Reply to this email directly or view it on GitHub
#52 (comment).