small example with struct for multi params in callbacks
This commit is contained in:
parent
defd961017
commit
2281778915
@ -71,6 +71,9 @@ BLINKER* blR() {
|
|||||||
BLINKER* blB() {
|
BLINKER* blB() {
|
||||||
return &theFactory.blB_;
|
return &theFactory.blB_;
|
||||||
}
|
}
|
||||||
|
BLINKER* blT() {
|
||||||
|
return &theFactory.blT_;
|
||||||
|
}
|
||||||
|
|
||||||
APP* app() {
|
APP* app() {
|
||||||
return &theFactory.app_;
|
return &theFactory.app_;
|
||||||
@ -116,9 +119,15 @@ void Factory_init() {
|
|||||||
BLINKER_init(blL());
|
BLINKER_init(blL());
|
||||||
BLINKER_init(blR());
|
BLINKER_init(blR());
|
||||||
BLINKER_init(blB());
|
BLINKER_init(blB());
|
||||||
|
BLINKER_init(blT());
|
||||||
|
|
||||||
APP_init(app());
|
APP_init(app());
|
||||||
|
|
||||||
|
theFactory.bar.timeOn = 1000;
|
||||||
|
theFactory.bar.timeOff = 500;
|
||||||
|
theFactory.bar.n = 5;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void warningBlink(void* on_){
|
void warningBlink(void* on_){
|
||||||
@ -134,6 +143,16 @@ void warningBlink(void* on_){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
//connect objects if required
|
||||||
void Factory_build() {
|
void Factory_build() {
|
||||||
|
|
||||||
@ -145,6 +164,9 @@ void Factory_build() {
|
|||||||
BUTTON_onReleased(b2(), &CLICK_HANDLER_emitPbrelease, ch2());
|
BUTTON_onReleased(b2(), &CLICK_HANDLER_emitPbrelease, ch2());
|
||||||
BUTTON_onReleased(b3(), &CLICK_HANDLER_emitPbrelease, ch3());
|
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_onOn(blL(), &LED_on, l1());
|
||||||
BLINKER_onOff(blL(), &LED_off, l1());
|
BLINKER_onOff(blL(), &LED_off, l1());
|
||||||
BLINKER_onOn(blR(), &LED_on, l10());
|
BLINKER_onOn(blR(), &LED_on, l10());
|
||||||
@ -152,6 +174,8 @@ void Factory_build() {
|
|||||||
BLINKER_onOn(blB(), &warningBlink, true);
|
BLINKER_onOn(blB(), &warningBlink, true);
|
||||||
BLINKER_onOff(blB(), &warningBlink, false);
|
BLINKER_onOff(blB(), &warningBlink, false);
|
||||||
|
|
||||||
|
BLINKER_onOn(blT(), &LED_on, l5());
|
||||||
|
BLINKER_onOff(blT(), &LED_off, l5());
|
||||||
}
|
}
|
||||||
|
|
||||||
//start all state machines
|
//start all state machines
|
||||||
@ -165,5 +189,6 @@ void Factory_start() {
|
|||||||
BLINKER_startBehaviour(blL());
|
BLINKER_startBehaviour(blL());
|
||||||
BLINKER_startBehaviour(blR());
|
BLINKER_startBehaviour(blR());
|
||||||
BLINKER_startBehaviour(blB());
|
BLINKER_startBehaviour(blB());
|
||||||
|
BLINKER_startBehaviour(blT());
|
||||||
APP_startBehaviour(app());
|
APP_startBehaviour(app());
|
||||||
}
|
}
|
@ -16,6 +16,12 @@
|
|||||||
#include "../middleware/blinker.h"
|
#include "../middleware/blinker.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t timeOn;
|
||||||
|
uint16_t timeOff;
|
||||||
|
uint8_t n;
|
||||||
|
} foo;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
LED l1_;
|
LED l1_;
|
||||||
LED l2_;
|
LED l2_;
|
||||||
@ -36,7 +42,9 @@ typedef struct {
|
|||||||
BLINKER blL_;
|
BLINKER blL_;
|
||||||
BLINKER blR_;
|
BLINKER blR_;
|
||||||
BLINKER blB_;
|
BLINKER blB_;
|
||||||
|
BLINKER blT_;
|
||||||
APP app_;
|
APP app_;
|
||||||
|
foo bar;
|
||||||
} Factory;
|
} Factory;
|
||||||
|
|
||||||
|
|
||||||
@ -67,6 +75,7 @@ CLICK_HANDLER* ch3();
|
|||||||
BLINKER* blL();
|
BLINKER* blL();
|
||||||
BLINKER* blR();
|
BLINKER* blR();
|
||||||
BLINKER* blB();
|
BLINKER* blB();
|
||||||
|
BLINKER* blT();
|
||||||
|
|
||||||
APP* app();
|
APP* app();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user