1

Topic: Slider: negative values, if >100.

I need to use PWM with the slider so i did:

RemoteXY.slider=random(0,100);

I get correctly values from to 0 to 100. When i add:

RemoteXY.slider= map(RemoteXY.slider, 0, 100, 0, 255);

I get negative values. So the RemoteXY.slider variable isn't able to use values greater than 100, in fact passing random(0,255), i have negative values again. I think a good range could be (0,1023) like a real potentiometer.
Thanks

2

Re: Slider: negative values, if >100.

As any variable of type int8_t, range is -128 to 127, and will wrap around when set value is out of this range. The slider value can be -100 to 100 if "center" is set to Middle, else 0 to 100. I agree that a better resolution (int16_t) would be nice.

3

Re: Slider: negative values, if >100.

Guillaume wrote:

As any variable of type int8_t, range is -128 to 127, and will wrap around when set value is out of this range. The slider value can be -100 to 100 if "center" is set to Middle, else 0 to 100. I agree that a better resolution (int16_t) would be nice.

I'm not sure if that would help... finger position resolution on phone touch screens is pretty course.  Nudge up/down buttons could be implemented, but will require the clunky "updateInputs" fix.

2B, or not 2B, that is the pencil ...