add toggle on blinker
This commit is contained in:
parent
1f091485ac
commit
b428b0cd76
@ -62,8 +62,11 @@ CLICK_HANDLER* ch3() {
|
|||||||
return &theFactory.ch3_;
|
return &theFactory.ch3_;
|
||||||
}
|
}
|
||||||
|
|
||||||
BLINKER* blA() {
|
BLINKER* blL() {
|
||||||
return &theFactory.blA_;
|
return &theFactory.blL_;
|
||||||
|
}
|
||||||
|
BLINKER* blR() {
|
||||||
|
return &theFactory.blR_;
|
||||||
}
|
}
|
||||||
BLINKER* blB() {
|
BLINKER* blB() {
|
||||||
return &theFactory.blB_;
|
return &theFactory.blB_;
|
||||||
@ -106,31 +109,44 @@ void Factory_init() {
|
|||||||
CLICK_HANDLER_init(ch2(), b2());
|
CLICK_HANDLER_init(ch2(), b2());
|
||||||
CLICK_HANDLER_init(ch3(), b3());
|
CLICK_HANDLER_init(ch3(), b3());
|
||||||
|
|
||||||
BLINKER_init(blA());
|
BLINKER_init(blL());
|
||||||
|
BLINKER_init(blR());
|
||||||
BLINKER_init(blB());
|
BLINKER_init(blB());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//connect objects if required
|
//connect objects if required
|
||||||
void Factory_build() {
|
void Factory_build() {
|
||||||
BLINKER_defineNblink(blA(), 3);
|
|
||||||
BLINKER_defineNblink(blB(), 5);
|
|
||||||
|
|
||||||
BLINKER_setTimeOn(blA(), 20);
|
BLINKER_setTurnOn(blL(), BLINKER_defineCallBack(&LED_on, l1()));
|
||||||
BLINKER_setTimeOff(blA(), 480);
|
BLINKER_setTurnOff(blL(), BLINKER_defineCallBack(&LED_off, l1()));
|
||||||
|
BLINKER_setTurnOn(blR(), BLINKER_defineCallBack(&LED_on, l10()));
|
||||||
|
BLINKER_setTurnOff(blR(), BLINKER_defineCallBack(&LED_off, l10()));
|
||||||
|
BLINKER_setTurnOn(blB(), BLINKER_defineCallBack(&warningBlink, true));
|
||||||
|
BLINKER_setTurnOff(blB(), BLINKER_defineCallBack(&warningBlink, false));
|
||||||
|
|
||||||
BLINKER_setTurnOn(blA(), BLINKER_defineCallBack(&LED_on, l1()));
|
CLICK_HANDLER_setSingleClickCallback(ch1(), CLICK_HANDLER_defineCallBack(&BLINKER_toggle, blL()));
|
||||||
BLINKER_setTurnOff(blA(), BLINKER_defineCallBack(&LED_off, l1()));
|
CLICK_HANDLER_setSingleClickCallback(ch3(), CLICK_HANDLER_defineCallBack(&BLINKER_toggle, blR()));
|
||||||
BLINKER_setTurnOn(blB(), BLINKER_defineCallBack(&LED_on, l10()));
|
|
||||||
BLINKER_setTurnOff(blB(), BLINKER_defineCallBack(&LED_off, l10()));
|
|
||||||
|
|
||||||
CLICK_HANDLER_setSingleClickCallback(ch1(), CLICK_HANDLER_defineCallBack(&BLINKER_blink, blA()));
|
CLICK_HANDLER_setDoubleClickCallback(ch1(), CLICK_HANDLER_defineCallBack(&BLINKER_blinkN, blL()));
|
||||||
CLICK_HANDLER_setDoubleClickCallback(ch1(), CLICK_HANDLER_defineCallBack(&BLINKER_endBlink, blA()));
|
CLICK_HANDLER_setDoubleClickCallback(ch3(), CLICK_HANDLER_defineCallBack(&BLINKER_blinkN, blR()));
|
||||||
CLICK_HANDLER_setLongClickCallback(ch1(), CLICK_HANDLER_defineCallBack(&BLINKER_blinkN, blA()));
|
|
||||||
|
|
||||||
CLICK_HANDLER_setSingleClickCallback(ch3(), CLICK_HANDLER_defineCallBack(&BLINKER_blink, blB()));
|
CLICK_HANDLER_setLongClickCallback(ch1(), CLICK_HANDLER_defineCallBack(&BLINKER_toggle, blB()));
|
||||||
CLICK_HANDLER_setDoubleClickCallback(ch3(), CLICK_HANDLER_defineCallBack(&BLINKER_endBlink, blB()));
|
CLICK_HANDLER_setLongClickCallback(ch3(), CLICK_HANDLER_defineCallBack(&BLINKER_toggle, blB()));
|
||||||
CLICK_HANDLER_setLongClickCallback(ch3(), CLICK_HANDLER_defineCallBack(&BLINKER_blinkN, blB()));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,6 +158,7 @@ void Factory_start() {
|
|||||||
CLICK_HANDLER_startBehaviour(ch1());
|
CLICK_HANDLER_startBehaviour(ch1());
|
||||||
CLICK_HANDLER_startBehaviour(ch2());
|
CLICK_HANDLER_startBehaviour(ch2());
|
||||||
CLICK_HANDLER_startBehaviour(ch3());
|
CLICK_HANDLER_startBehaviour(ch3());
|
||||||
BLINKER_starBehaviour(blA());
|
BLINKER_starBehaviour(blL());
|
||||||
|
BLINKER_starBehaviour(blR());
|
||||||
BLINKER_starBehaviour(blB());
|
BLINKER_starBehaviour(blB());
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,8 @@ typedef struct {
|
|||||||
CLICK_HANDLER ch1_;
|
CLICK_HANDLER ch1_;
|
||||||
CLICK_HANDLER ch2_;
|
CLICK_HANDLER ch2_;
|
||||||
CLICK_HANDLER ch3_;
|
CLICK_HANDLER ch3_;
|
||||||
BLINKER blA_;
|
BLINKER blL_;
|
||||||
|
BLINKER blR_;
|
||||||
BLINKER blB_;
|
BLINKER blB_;
|
||||||
} Factory;
|
} Factory;
|
||||||
|
|
||||||
@ -61,7 +62,8 @@ CLICK_HANDLER* ch1();
|
|||||||
CLICK_HANDLER* ch2();
|
CLICK_HANDLER* ch2();
|
||||||
CLICK_HANDLER* ch3();
|
CLICK_HANDLER* ch3();
|
||||||
|
|
||||||
BLINKER* blA();
|
BLINKER* blL();
|
||||||
|
BLINKER* blR();
|
||||||
BLINKER* blB();
|
BLINKER* blB();
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -132,3 +132,18 @@ bool BLINKER_processEvent(Event* ev) {
|
|||||||
void BLINKER_endBlink(BLINKER* me) {
|
void BLINKER_endBlink(BLINKER* me) {
|
||||||
me->remainBlinks = 0;
|
me->remainBlinks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BLINKER_toggle(BLINKER* me){
|
||||||
|
switch(me->state) {
|
||||||
|
case STBL_WAIT:
|
||||||
|
BLINKER_blink(me);
|
||||||
|
break;
|
||||||
|
case STBL_OFF:
|
||||||
|
BLINKER_endBlink(me);
|
||||||
|
break;
|
||||||
|
case STBL_ON:
|
||||||
|
BLINKER_endBlink(me);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
me->toggleRemainBlinks = me->remainBlinks;
|
||||||
|
}
|
||||||
|
@ -120,6 +120,8 @@ bool BLINKER_processEvent(Event* ev);
|
|||||||
*/
|
*/
|
||||||
void BLINKER_endBlink(BLINKER* me);
|
void BLINKER_endBlink(BLINKER* me);
|
||||||
|
|
||||||
|
void BLINKER_toggle(BLINKER* me);
|
||||||
|
|
||||||
|
|
||||||
#endif /* BLINKER_H */
|
#endif /* BLINKER_H */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user