Hi Guys,
I´m working on to implement a sensitive button. I´m using firstly to implement it with SmartRF05EB 1.7.1 and EM inside.
I have in my mind to implement the code according to this rule:
- Normal press just on or off
- Press and hold more than 3 seconds the first time will increase the level,
- Press and hold more than 3 seconds will decrease level,
I have some doubts about how to detect the hold time, I have started in the HandleKeys function to detect the hold time but I don´t know how to do it using for example osal_start_timer.
Would see below, my code with LED_ON and LED_OFF, beginning to understanding the better way to implement the code, in the future I´ll using dimmer level up and down.
if ( (keys & HAL_KEY_SW_6) == 0) { //giLightScreenMode = LIGHT_MAINMODE; HalLedSet( HAL_LED_1, HAL_LED_MODE_ON); buttonPressed =1; longBtnPress = 0; if(buttonPressed == 1) { // test for long or short btn press if(longBtnPress == 1) { zclTTa0003_OnOff = zclTTa0003_OnOff ? LIGHT_OFF : LIGHT_ON; longBtnPress = 0; }else { HalLedSet( HAL_LED_1, HAL_LED_MODE_OFF );//toggle short led } buttonPressed = 0; timerCounter = 0; } #ifdef ZCL_LEVEL_CTRL // zclTTa0003_OnOff = zclTTa0003_OnOff ? LIGHT_OFF : LIGHT_ON; #endif }
Someone has an idea how to I cam implement the mechanism to detect the hold time?
BR,
Alex