Question
Slider used as 4 buttons on STM32L-Discovery
Posted on May 25, 2012 at 15:58
Hi,
I am new to this forum and I am programming the STM32L-Discovery using Crossworks.I am currently trying to do something which I believe should be relatively simple. e.g when I touch the 1st quarter of the slider - do something (like turn on the 1st LCD bar say). Touch the second quarter of the slider and the 2nd LCD bar goes on, etc. Basically use the slider as 4 separate buttons, with 4 separate functions.I tried to use some code similar to that used in one of the examples, e.g---- if ((SLIDER_DETECTED)&&(TSLState == TSL_IDLE_STATE)) { if( SLIDER_POSITION <= 25 ) buttonPressed = 0; break; if( (SLIDER_POSITION > 25 ) && (SLIDER_POSITION <= 110 )) buttonPressed = 1; break; if( (SLIDER_POSITION > 110 ) && (SLIDER_POSITION <= 200 )) buttonPressed = 2; break; if( SLIDER_POSITION > 200 ) buttonPressed = 3; break; }---However, regardless of where I touch the slider, ''buttonPressed=0, always seems to be true.If somebody could point me in the right direction, I would be very grateful.Can anyone recommend a good reference as to the possible ways to configure the operation of the slider?Regards