2013-12-17 05:31 AM
Hello everyone. I am making Kitchen Clock on STM8S105C6 and STM8 touch sence library. I need 4 buttons and i have configurate them as SCKEY. Now they works fine. My problem is that library catch only one button at once, i mean if you touch 2 buttons at same time library gaves only one Detect flag for first of two buttons. But i need to enter in Time adjustment menu by pressing two buttons at once. Can you give mi a suggest please.
#touch #stm8-tsl #stm8s-and-tsl #double2013-12-18 03:25 AM
Hi
In the real world - it is very unlikely you will ever get both touch buttons pressed/sensed together. It is like real world push buttons - they never give you a clean off/on - you need to debounce them. So for the touch sense, what does the STM8 touch sence library do when a second button is pressed when one is already pressed? If the library does not return that another button is pressed - you need to modify the library so that it does. If it does, Good. Now your software has to look for a second button a short period (we are talking upto 50ms here) after the first. Hint, if this only applies to one button, there is not need to do this code for all buttons.2013-12-18 06:36 AM
Here is my variant i don't know is it looks fine but it is working.
if (sSCKeyInfo[2].Setting.b.DETECTED) /* KEY 3 touched */ { GPIO_WriteReverse(LEDButtonPort, LED2Pin);// one button click if (sSCKeyInfo[1].State.b.DETECTED) { GPIO_WriteReverse(LEDButtonPort, LED1Pin);// case of two button click } } if (sSCKeyInfo[1].Setting.b.DETECTED) /* KEY 4 touched */{ GPIO_WriteReverse(LEDButtonPort, LED1Pin);// one button click if (sSCKeyInfo[2].State.b.DETECTED) { GPIO_WriteReverse(LEDButtonPort, LED2Pin);// case of two button click }}2013-12-18 09:21 AM
Hi
Good work. If it works - stick with it. If there are problems - fix them.2015-11-18 05:12 AM