From 017fd46ca5d862bbacca8d3c65cbe9f4b3544837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Thu, 13 Jul 2023 22:04:30 +0200 Subject: [PATCH] convert to model --- Makefile | 113 ----------------- generator | 2 +- nbproject/configurations.xml | 230 ----------------------------------- nbproject/project.xml | 25 ---- src/app/app.c | 217 --------------------------------- src/app/app.h | 40 ------ src/app/factory.c | 57 +-------- src/app/factory.h | 20 --- src/board/led.c | 2 +- src/board/led.h | 2 +- 10 files changed, 5 insertions(+), 703 deletions(-) delete mode 100644 Makefile delete mode 100644 nbproject/configurations.xml delete mode 100644 nbproject/project.xml delete mode 100644 src/app/app.c delete mode 100644 src/app/app.h diff --git a/Makefile b/Makefile deleted file mode 100644 index fca8e2c..0000000 --- a/Makefile +++ /dev/null @@ -1,113 +0,0 @@ -# -# There exist several targets which are by default empty and which can be -# used for execution of your targets. These targets are usually executed -# before and after some main targets. They are: -# -# .build-pre: called before 'build' target -# .build-post: called after 'build' target -# .clean-pre: called before 'clean' target -# .clean-post: called after 'clean' target -# .clobber-pre: called before 'clobber' target -# .clobber-post: called after 'clobber' target -# .all-pre: called before 'all' target -# .all-post: called after 'all' target -# .help-pre: called before 'help' target -# .help-post: called after 'help' target -# -# Targets beginning with '.' are not intended to be called on their own. -# -# Main targets can be executed directly, and they are: -# -# build build a specific configuration -# clean remove built files from a configuration -# clobber remove all built files -# all build all configurations -# help print help mesage -# -# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and -# .help-impl are implemented in nbproject/makefile-impl.mk. -# -# Available make variables: -# -# CND_BASEDIR base directory for relative paths -# CND_DISTDIR default top distribution directory (build artifacts) -# CND_BUILDDIR default top build directory (object files, ...) -# CONF name of current configuration -# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration) -# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration) -# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration) -# CND_PACKAGE_DIR_${CONF} directory of package (current configuration) -# CND_PACKAGE_NAME_${CONF} name of package (current configuration) -# CND_PACKAGE_PATH_${CONF} path to package (current configuration) -# -# NOCDDL - - -# Environment -MKDIR=mkdir -CP=cp -CCADMIN=CCadmin -RANLIB=ranlib - - -# build -build: .build-post - -.build-pre: -# Add your pre 'build' code here... - -.build-post: .build-impl -# Add your post 'build' code here... - - -# clean -clean: .clean-post - -.clean-pre: -# Add your pre 'clean' code here... -# WARNING: the IDE does not call this target since it takes a long time to -# simply run make. Instead, the IDE removes the configuration directories -# under build and dist directly without calling make. -# This target is left here so people can do a clean when running a clean -# outside the IDE. - -.clean-post: .clean-impl -# Add your post 'clean' code here... - - -# clobber -clobber: .clobber-post - -.clobber-pre: -# Add your pre 'clobber' code here... - -.clobber-post: .clobber-impl -# Add your post 'clobber' code here... - - -# all -all: .all-post - -.all-pre: -# Add your pre 'all' code here... - -.all-post: .all-impl -# Add your post 'all' code here... - - -# help -help: .help-post - -.help-pre: -# Add your pre 'help' code here... - -.help-post: .help-impl -# Add your post 'help' code here... - - - -# include project implementation makefile -include nbproject/Makefile-impl.mk - -# include project make variables -include nbproject/Makefile-variables.mk diff --git a/generator b/generator index a808b1a..6ddda29 160000 --- a/generator +++ b/generator @@ -1 +1 @@ -Subproject commit a808b1a1fb577636ebeebcd07374754688d37e71 +Subproject commit 6ddda2930030db6bd45a81e1547a4ac9a88d90af diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml deleted file mode 100644 index 09f6cc3..0000000 --- a/nbproject/configurations.xml +++ /dev/null @@ -1,230 +0,0 @@ - - - - - - src/app/factory.h - src/app/app.h - - - src/board/led.h - src/board/button.h - - - src/mcc_generated_files/tmr0.h - src/mcc_generated_files/pin_manager.h - src/mcc_generated_files/mcc.h - src/mcc_generated_files/interrupt_manager.h - src/mcc_generated_files/device_config.h - - - src/middleware/blinker.h - src/middleware/click_handler.h - - - src/xf/ireactive.h - src/xf/event.h - src/xf/xf.h - - - - - - - src/app/factory.c - src/app/main.c - src/app/app.c - - - src/board/led.c - src/board/button.c - - - src/mcc_generated_files/mcc.c - src/mcc_generated_files/interrupt_manager.c - src/mcc_generated_files/device_config.c - src/mcc_generated_files/pin_manager.c - src/mcc_generated_files/tmr0.c - - - src/middleware/blinker.c - src/middleware/click_handler.c - - - src/xf/xf.c - src/xf/event.c - - - - Makefile - - - - src - - Makefile - - - - localhost - PIC18F87K22 - - - PICkit3PlatformTool - XC8 - 2.41 - 2 - - - - - - - - - - - - - - - false - false - - - - - - - false - false - - false - - false - false - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/nbproject/project.xml b/nbproject/project.xml deleted file mode 100644 index 4e0519e..0000000 --- a/nbproject/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - com.microchip.mplab.nbide.embedded.makeproject - - - XFT - 9d10e4b8-91cc-4d86-8f12-a6fd880b26ed - 0 - UTF-8 - - - src - - - - default - 2 - - - - false - - - - diff --git a/src/app/app.c b/src/app/app.c deleted file mode 100644 index 1c2328a..0000000 --- a/src/app/app.c +++ /dev/null @@ -1,217 +0,0 @@ -/** - * @author R�mi Heredero (remi@heredero.ch) - * @version 1.0.0 - * @date 2023-06-15 - */ - -#include "app.h" -#include "factory.h" -#include "../middleware/blinker.h" -#include "../middleware/click_handler.h" - -void clickL(APP* me){ - POST(me, &APP_processEvent, evAPclickL, 0, 0); -} -void clickLn(APP* me){ - POST(me, &APP_processEvent, evAPclickLn, 0, 0); -} -void clickR(APP* me){ - POST(me, &APP_processEvent, evAPclickR, 0, 0); -} -void clickRn(APP* me){ - POST(me, &APP_processEvent, evAPclickRn, 0, 0); -} -void endL(APP* me){ - POST(me, &APP_processEvent, evAPendL, 0, 0); -} -void endR(APP* me){ - POST(me, &APP_processEvent, evAPendR, 0, 0); -} -void longClick(APP* me){ - POST(me, &APP_processEvent, evAPlongClick, 0, 0); -} - - - -void APP_init(APP* me){ - - me->state = STAP_INIT; - - CLICK_HANDLER_onSingle_click(ch1(), &clickL, me); - CLICK_HANDLER_onSingle_click(ch3(), &clickR, me); - - CLICK_HANDLER_onDouble_click(ch1(), &clickLn, me); - CLICK_HANDLER_onDouble_click(ch3(), &clickRn, me); - - CLICK_HANDLER_onLong_click(ch1(), &longClick, me); - CLICK_HANDLER_onLong_click(ch3(), &longClick, me); - - BLINKER_onFinished(blL(), &endL, me); - BLINKER_onFinished(blR(), &endR, me); - -} - -void APP_startBehaviour(APP* me){ - POST(me, &APP_processEvent, evAPinit, 0, 0); -} - -bool APP_processEvent(Event* ev){ - bool processed = false; - APP* me = (APP*) Event_getTarget(ev); - APP_STATES oldState = me->state; - evIDT evid = Event_getId(ev); - - switch(me->state) { // In state - case STAP_INIT: - if(evid == evAPinit) { - me->state = STAP_WAIT; - } - break; - - case STAP_WAIT: - if(evid == evAPclickL) { - me->state = STAP_BLINKER_L; - BLINKER_emitBlink(blL(), 0); - } - if(evid == evAPclickLn) { - me->state = STAP_BLINKER_L; - BLINKER_emitBlinkN(blL(), 0); - } - if(evid == evAPclickR) { - me->state = STAP_BLINKER_R; - BLINKER_emitBlink(blR(), 0); - } - if(evid == evAPclickRn) { - me->state = STAP_BLINKER_R; - BLINKER_emitBlinkN(blR(), 0); - } - if(evid == evAPlongClick) { - me->state = STAP_BLINKER_W; - BLINKER_emitBlink(blB(), 0); - } - break; - - case STAP_BLINKER_L: - if(evid == evAPclickR){ - me->state = STAP_BLINKER_LR; - BLINKER_emitBlink(blR(), 0); - } - if(evid == evAPclickRn){ - me->state = STAP_BLINKER_LR; - BLINKER_emitBlinkN(blR(), 0); - } - if(evid == evAPclickL) { - me->state = STAP_WAIT; - BLINKER_endBlink(blL()); - } - if(evid == evAPendL) { - me->state = STAP_WAIT; - } - if(evid == evAPlongClick) { - me->state = STAP_BLINKER_W; - BLINKER_endBlink(blL()); - BLINKER_emitBlink(blB(), 0); - } - break; - - case STAP_BLINKER_R: - if(evid == evAPclickL){ - me->state = STAP_BLINKER_LR; - BLINKER_emitBlink(blL(), 0); - } - if(evid == evAPclickLn){ - me->state = STAP_BLINKER_LR; - BLINKER_emitBlinkN(blL(), 0); - } - if(evid == evAPclickR) { - me->state = STAP_WAIT; - BLINKER_endBlink(blR()); - } - if(evid == evAPendR) { - me->state = STAP_WAIT; - } - if(evid == evAPlongClick) { - me->state = STAP_BLINKER_W; - BLINKER_endBlink(blR()); - BLINKER_emitBlink(blB(), 0); - } - break; - - case STAP_BLINKER_LR: - if(evid == evAPclickR) { - me->state = STAP_BLINKER_L; - BLINKER_endBlink(blR()); - } - if(evid == evAPendR) { - me->state = STAP_BLINKER_L; - } - if(evid == evAPclickL) { - me->state = STAP_BLINKER_R; - BLINKER_endBlink(blL()); - } - if(evid == evAPendL) { - me->state = STAP_BLINKER_R; - } - if(evid == evAPlongClick) { - me->state = STAP_BLINKER_W; - BLINKER_endBlink(blL()); - BLINKER_endBlink(blR()); - BLINKER_emitBlink(blB(), 0); - - } - break; - - case STAP_BLINKER_W: - if(evid == evAPlongClick){ - me->state = STAP_WAIT; - BLINKER_endBlink(blB()); - } - break; - - } - - if(oldState != me->state) { - switch(oldState) { // on exit - case STAP_INIT: - break; - - case STAP_WAIT: - break; - - case STAP_BLINKER_L: - break; - - case STAP_BLINKER_R: - break; - - case STAP_BLINKER_LR: - break; - - case STAP_BLINKER_W: - break; - } - - switch(me->state) { // on entry - case STAP_INIT: - break; - - case STAP_WAIT: - break; - - case STAP_BLINKER_L: - break; - - case STAP_BLINKER_R: - break; - - case STAP_BLINKER_LR: - break; - - case STAP_BLINKER_W: - break; - - } - processed = true; - } - return processed; -} diff --git a/src/app/app.h b/src/app/app.h deleted file mode 100644 index 90b8dec..0000000 --- a/src/app/app.h +++ /dev/null @@ -1,40 +0,0 @@ -/** - * @author Rémi Heredero (remi@heredero.ch) - * @version 1.0.0 - * @date 2023-06-17 - */ -#ifndef APP_H -#define APP_H - -#include "../xf/xf.h" - -typedef enum { - STAP_INIT, - STAP_WAIT, - STAP_BLINKER_L, - STAP_BLINKER_R, - STAP_BLINKER_LR, - STAP_BLINKER_W -} APP_STATES; - -typedef enum { - evAPinit = 150, - evAPclickL, - evAPclickLn, - evAPclickR, - evAPclickRn, - evAPendL, - evAPendR, - evAPlongClick -} APP_EVENTS; - -typedef struct { - APP_STATES state; // Actual state -} APP; - -void APP_init(APP* me); -void APP_startBehaviour(APP* me); -bool APP_processEvent(Event* ev); - -#endif /* APP_H */ - diff --git a/src/app/factory.c b/src/app/factory.c index f4f6821..0cd32a2 100755 --- a/src/app/factory.c +++ b/src/app/factory.c @@ -102,8 +102,7 @@ void Factory_init() { LED_initHW(l8()); LED_initHW(l9()); LED_initHW(l10()); - - + BUTTON_init(b1(), 1); BUTTON_init(b2(), 2); BUTTON_init(b3(), 3); @@ -115,42 +114,7 @@ void Factory_init() { CLICK_HANDLER_init(ch1()); CLICK_HANDLER_init(ch2()); CLICK_HANDLER_init(ch3()); - - BLINKER_init(blL()); - BLINKER_init(blR()); - BLINKER_init(blB()); - BLINKER_init(blT()); - APP_init(app()); - - theFactory.bar.timeOn = 1000; - theFactory.bar.timeOff = 500; - theFactory.bar.n = 5; - - -} - -void warningBlink(void* on_){ - bool on = (bool)on_; - BLINKER_endBlink(blL()); - BLINKER_endBlink(blR()); - if(on) { - LED_on(l1()); - LED_on(l10()); - } else { - LED_off(l1()); - LED_off(l10()); - } -} - -void toggleBlink(void* st_){ - foo* st = (foo*)st_; - uint16_t timeOn= st->timeOn; - uint16_t timeOff = st->timeOff; - uint8_t n = st->n; - BLINKER_setTimeOn(blT(), timeOn); - BLINKER_setTimeOff(blT(), timeOff); - BLINKER_setNumberOfBlink(blT(), n); } //connect objects if required @@ -163,19 +127,7 @@ void Factory_build() { BUTTON_onReleased(b1(), &CLICK_HANDLER_emitPbrelease, ch1()); BUTTON_onReleased(b2(), &CLICK_HANDLER_emitPbrelease, ch2()); BUTTON_onReleased(b3(), &CLICK_HANDLER_emitPbrelease, ch3()); - - CLICK_HANDLER_onSingle_click(ch2(), &BLINKER_emitBlinkN, blT()); - CLICK_HANDLER_onLong_click(ch2(), &toggleBlink, &theFactory.bar); - - BLINKER_onOn(blL(), &LED_on, l1()); - BLINKER_onOff(blL(), &LED_off, l1()); - BLINKER_onOn(blR(), &LED_on, l10()); - BLINKER_onOff(blR(), &LED_off, l10()); - BLINKER_onOn(blB(), &warningBlink, true); - BLINKER_onOff(blB(), &warningBlink, false); - - BLINKER_onOn(blT(), &LED_on, l5()); - BLINKER_onOff(blT(), &LED_off, l5()); + } //start all state machines @@ -186,9 +138,4 @@ void Factory_start() { CLICK_HANDLER_startBehaviour(ch1()); CLICK_HANDLER_startBehaviour(ch2()); CLICK_HANDLER_startBehaviour(ch3()); - BLINKER_startBehaviour(blL()); - BLINKER_startBehaviour(blR()); - BLINKER_startBehaviour(blB()); - BLINKER_startBehaviour(blT()); - APP_startBehaviour(app()); } \ No newline at end of file diff --git a/src/app/factory.h b/src/app/factory.h index c17ddfa..12ca7f0 100755 --- a/src/app/factory.h +++ b/src/app/factory.h @@ -14,13 +14,6 @@ #include "../board/button.h" #include "../middleware/click_handler.h" #include "../middleware/blinker.h" -#include "app.h" - -typedef struct { - uint16_t timeOn; - uint16_t timeOff; - uint8_t n; - } foo; typedef struct { LED l1_; @@ -39,12 +32,6 @@ typedef struct { CLICK_HANDLER ch1_; CLICK_HANDLER ch2_; CLICK_HANDLER ch3_; - BLINKER blL_; - BLINKER blR_; - BLINKER blB_; - BLINKER blT_; - APP app_; - foo bar; } Factory; @@ -72,11 +59,4 @@ CLICK_HANDLER* ch1(); CLICK_HANDLER* ch2(); CLICK_HANDLER* ch3(); -BLINKER* blL(); -BLINKER* blR(); -BLINKER* blB(); -BLINKER* blT(); - -APP* app(); - #endif \ No newline at end of file diff --git a/src/board/led.c b/src/board/led.c index b151cbf..ad75893 100644 --- a/src/board/led.c +++ b/src/board/led.c @@ -1,5 +1,5 @@ /** - * @author R�mi Heredero (remi@heredero.ch) + * @author Rémi Heredero * @version. 1.0.0 * @date 2023-06-15 */ diff --git a/src/board/led.h b/src/board/led.h index 5255053..04504a7 100644 --- a/src/board/led.h +++ b/src/board/led.h @@ -1,5 +1,5 @@ /** - * @author Rémi Heredero (remi@heredero.ch) + * @author Rémi Heredero * @version. 1.0.0 * @date 2023-06-15 */