add blinker debug
This commit is contained in:
		| @@ -7,7 +7,7 @@ | ||||
|  | ||||
| #include "alive.h" | ||||
|  | ||||
| void ALIVE_init(ALIVE* me){ | ||||
| void ALIVE_init(ALIVE* me, uint8_t led){ | ||||
|     me->state = STAL_INIT; | ||||
|     me->isAlive = false; | ||||
|     me->checker = false; | ||||
| @@ -20,14 +20,23 @@ void ALIVE_init(ALIVE* me){ | ||||
|     me->dead.f = NULL; | ||||
|     me->alive.f = NULL; | ||||
|     me->break_cb.f = NULL; | ||||
|     LED_init(&me->debugLed, led); | ||||
|     LED_initHW(&me->debugLed); | ||||
|     BLINKER_init(&me->debugBlinker); | ||||
|     BLINKER_setTimeOn(&me->debugBlinker, 50); | ||||
|     BLINKER_setTimeOff(&me->debugBlinker, 50); | ||||
|     BLINKER_onOn(&me->debugBlinker, LED_on, &me->debugLed); | ||||
|     BLINKER_onOff(&me->debugBlinker, LED_off, &me->debugLed); | ||||
| } | ||||
|  | ||||
| void ALIVE_startBehaviourChecker(ALIVE* me){ | ||||
|     POST(me, &ALIVE_processEvent, evALinitChecker, 0, 0); | ||||
|     BLINKER_startBehaviour(&me->debugBlinker); | ||||
|     POST(me, &ALIVE_processEvent, evALinitChecker, 10, 0); | ||||
| } | ||||
|  | ||||
| void ALIVE_startBehaviourSender(ALIVE* me){ | ||||
|     POST(me, &ALIVE_processEvent, evALinitSender, 0, 0); | ||||
|     BLINKER_startBehaviour(&me->debugBlinker); | ||||
|     POST(me, &ALIVE_processEvent, evALinitSender, 10, 0); | ||||
| } | ||||
|  | ||||
| bool ALIVE_processEvent(Event* ev) { | ||||
| @@ -39,6 +48,7 @@ bool ALIVE_processEvent(Event* ev) { | ||||
|      | ||||
|     switch (me->state) {        // onState | ||||
|         case STAL_INIT: | ||||
|             LED_on(&me->debugLed); | ||||
|             if (ev->id == evALinitChecker) { | ||||
|                 me->state = STAL_SETUP; | ||||
|             } | ||||
| @@ -125,12 +135,14 @@ bool ALIVE_processEvent(Event* ev) { | ||||
|                 break; | ||||
|              | ||||
|             case STAL_WAIT: | ||||
|                 BLINKER_endBlink(&me->debugBlinker); | ||||
|                 break; | ||||
|              | ||||
|             case STAL_DEAD: | ||||
|                 break; | ||||
|              | ||||
|             case STAL_ALIVE: | ||||
|                 BLINKER_endBlink(&me->debugBlinker); | ||||
|                 break; | ||||
|              | ||||
|             case STAL_BREAK: | ||||
| @@ -155,6 +167,8 @@ bool ALIVE_processEvent(Event* ev) { | ||||
|                 break; | ||||
|              | ||||
|             case STAL_WAIT: | ||||
|                 LED_off(&me->debugLed); | ||||
|                 BLINKER_emitBlink(&me->debugBlinker, 0); | ||||
|                 if (me->wait.f != NULL) { | ||||
|                     me->wait.f(me->wait.p); | ||||
|                 } | ||||
| @@ -167,6 +181,8 @@ bool ALIVE_processEvent(Event* ev) { | ||||
|                 break; | ||||
|              | ||||
|             case STAL_ALIVE: | ||||
|                 LED_off(&me->debugLed); | ||||
|                 BLINKER_emitBlink(&me->debugBlinker, 0); | ||||
|                 me->sender = true; | ||||
|                 break; | ||||
|              | ||||
|   | ||||
		Reference in New Issue
	
	Block a user