diff --git a/src/board/button.c b/archives/button.c similarity index 97% rename from src/board/button.c rename to archives/button.c index 1417941..bd3aafe 100644 --- a/src/board/button.c +++ b/archives/button.c @@ -5,8 +5,8 @@ */ #include "button.h" -#include "../mcc_generated_files/pin_manager.h" -#include "../app/factory.h" +#include "../src/mcc_generated_files/pin_manager.h" +#include "../src/app/factory.h" /** * @brief Initialize the button diff --git a/src/board/button.h b/archives/button.h similarity index 98% rename from src/board/button.h rename to archives/button.h index 36b6060..6b2dcba 100644 --- a/src/board/button.h +++ b/archives/button.h @@ -8,7 +8,7 @@ #include #include -#include "../xf/xf.h" +#include "../src/xf/xf.h" #define PB_POLL_TIME 20 // Poll time for BUTTON diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml index 0c464b7..9e058c9 100644 --- a/nbproject/configurations.xml +++ b/nbproject/configurations.xml @@ -9,6 +9,7 @@ src/board/led.h + src/board/button.h src/mcc_generated_files/interrupt_manager.h src/mcc_generated_files/device_config.h + + src/middleware/clickHandler.h + src/middleware/blinker.h + src/xf/ireactive.h src/xf/event.h @@ -38,6 +43,7 @@ src/board/led.c + src/board/button.c src/mcc_generated_files/pin_manager.c src/mcc_generated_files/tmr0.c + + src/middleware/blinker.c + src/middleware/clickHandler.c + src/xf/xf.c src/xf/event.c diff --git a/src/app/main.c b/src/app/main.c index af1013e..e08c63f 100644 --- a/src/app/main.c +++ b/src/app/main.c @@ -1,6 +1,6 @@ #include "../mcc_generated_files/mcc.h" -#include "../app/factory/factory.h" +#include "../app/factory.h" #include "../xf/xf.h" diff --git a/src/middleware/clickHandler.c b/src/middleware/clickHandler.c index 7379f8f..6659183 100644 --- a/src/middleware/clickHandler.c +++ b/src/middleware/clickHandler.c @@ -1,17 +1,24 @@ /** - * @author Rémi Heredero (remi@heredero.ch) + * @author R�mi Heredero (remi@heredero.ch) * @version. 1.0.0 * @date 2023-06-15 */ #include "clickHandler.h" +#include "../board/led.h" +#include "../app/factory.h" + +typedef struct { + CLICK_HANDLER* me; + uint16_t t; +} foo; void CLICK_HANDLER_BUTTON_PRESS(CLICK_HANDLER* me){ POST(me, &CLICK_HANDLER_processEvent, evCHpbPress, 0, 0); } -void CLICK_HANDLER_BUTTON_RELEASE(CLICK_HANDLER * me) { - POST(me, &CLICK_HANDLER_processEvent, evCHpbRelease, 0, 0); +void CLICK_HANDLER_BUTTON_RELEASE(CLICK_HANDLER* me) { + POST(me, &CLICK_HANDLER_processEvent, evCHpbRelease,0, 0); } void CLICK_HANDLER_init(CLICK_HANDLER* me, BUTTON* b){ @@ -21,15 +28,8 @@ void CLICK_HANDLER_init(CLICK_HANDLER* me, BUTTON* b){ me->singleClick.fCallBack = NULL; me->doubleClick.fCallBack = NULL; - buttonCallBack pbPressCallBack; - pbPressCallBack.fCallBack = CLICK_HANDLER_BUTTON_PRESS; - pbPressCallBack.param = me; - - buttonCallBack pbReleaseCallBack; - pbReleaseCallBack.fCallBack = CLICK_HANDLER_BUTTON_RELEASE; - pbReleaseCallBack.param = me; - - BUTTON_setEventFunctions(b, pbPressCallBack, pbReleaseCallBack); + BUTTON_onPress(b, CLICK_HANDLER_BUTTON_PRESS, me); + BUTTON_onRelease(b, CLICK_HANDLER_BUTTON_RELEASE, me); } void CLICK_HANDLER_startBehaviour(CLICK_HANDLER* me){ @@ -71,8 +71,12 @@ bool CLICK_HANDLER_processEvent(Event* ev) { case STCH_WAIT: if(evid == evCHpbPress) { - me->state = STCH_LONG_CLICK; - POST(me, &CLICK_HANDLER_processEvent, evCHtimer, CH_CLICK_TIMER, 0); + LED_on(l2()); + //me->state = STCH_LONG_CLICK; + //POST(me, &CLICK_HANDLER_processEvent, evCHtimer, CH_CLICK_TIMER, 0); + } + if(evid==evCHpbRelease) { + LED_off(l2()); } break; @@ -86,7 +90,9 @@ bool CLICK_HANDLER_processEvent(Event* ev) { if(evid == evCHtimer) { me->state = STCH_WAIT; + LED_on(l4()); if(me->longClick.fCallBack != NULL) { + LED_on(l5()); me->longClick.fCallBack(me->longClick.param); } } @@ -97,10 +103,12 @@ bool CLICK_HANDLER_processEvent(Event* ev) { case STCH_SINGLE_CLICK: if(evid == evCHpbPress) { + LED_on(l2()); me->state = STCH_DOUBLE_CLICK; } if(evid == evCHtimer) { + LED_on(l3()); me->state = STCH_WAIT; if(me->singleClick.fCallBack != NULL) { me->singleClick.fCallBack(me->singleClick.param);