129 lines
2.8 KiB
C
Executable File
129 lines
2.8 KiB
C
Executable File
#include "factory.h"
|
|
|
|
|
|
//the factory object containing all objects of our system
|
|
static Factory theFactory;
|
|
|
|
|
|
//all the getters
|
|
LED* l1() {
|
|
return &theFactory.l1_;
|
|
}
|
|
LED* l2() {
|
|
return &theFactory.l2_;
|
|
}
|
|
LED* l3() {
|
|
return &theFactory.l3_;
|
|
}
|
|
LED* l4() {
|
|
return &theFactory.l4_;
|
|
}
|
|
LED* l5() {
|
|
return &theFactory.l5_;
|
|
}
|
|
LED* l6() {
|
|
return &theFactory.l6_;
|
|
}
|
|
LED* l7() {
|
|
return &theFactory.l7_;
|
|
}
|
|
LED* l8() {
|
|
return &theFactory.l8_;
|
|
}
|
|
LED* l9() {
|
|
return &theFactory.l9_;
|
|
}
|
|
LED* l10() {
|
|
return &theFactory.l10_;
|
|
}
|
|
|
|
BUTTON* b1() {
|
|
return &theFactory.b1_;
|
|
}
|
|
BUTTON* b2() {
|
|
return &theFactory.b2_;
|
|
}
|
|
BUTTON* b3() {
|
|
return &theFactory.b3_;
|
|
}
|
|
|
|
CLICK_HANDLER* ch1() {
|
|
return &theFactory.ch1_;
|
|
}
|
|
CLICK_HANDLER* ch2() {
|
|
return &theFactory.ch2_;
|
|
}
|
|
CLICK_HANDLER* ch3() {
|
|
return &theFactory.ch3_;
|
|
}
|
|
|
|
|
|
LEDBlinker* lb() {
|
|
return &theFactory.lb_;
|
|
}
|
|
|
|
//initialize all objects
|
|
void Factory_init() {
|
|
LED_init(l1(), 1);
|
|
LED_init(l2(), 2);
|
|
LED_init(l3(), 3);
|
|
LED_init(l4(), 4);
|
|
LED_init(l5(), 5);
|
|
LED_init(l6(), 6);
|
|
LED_init(l7(), 7);
|
|
LED_init(l8(), 8);
|
|
LED_init(l9(), 9);
|
|
LED_init(l10(), 10);
|
|
|
|
BUTTON_init(b1(), 1);
|
|
BUTTON_init(b2(), 2);
|
|
BUTTON_init(b3(), 3);
|
|
|
|
CLICK_HANDLER_init(ch1(), b1());
|
|
CLICK_HANDLER_init(ch2(), b2());
|
|
CLICK_HANDLER_init(ch3(), b3());
|
|
|
|
|
|
LED_initHW(l1());
|
|
LED_initHW(l2());
|
|
LED_initHW(l3());
|
|
LED_initHW(l4());
|
|
LED_initHW(l5());
|
|
LED_initHW(l6());
|
|
LED_initHW(l7());
|
|
LED_initHW(l8());
|
|
LED_initHW(l9());
|
|
LED_initHW(l10());
|
|
|
|
BUTTON_initHW(b1());
|
|
BUTTON_initHW(b2());
|
|
BUTTON_initHW(b3());
|
|
}
|
|
|
|
//connect objects if required
|
|
void Factory_build() {
|
|
//BUTTON_setEventFunctions(b1(), BUTTON_defineCallBack(&LED_on, l1()), BUTTON_defineCallBack(NULL, NULL));
|
|
//BUTTON_setEventFunctions(b3(), BUTTON_defineCallBack(&LED_off, l1()), BUTTON_defineCallBack(NULL, NULL));
|
|
|
|
|
|
CLICK_HANDLER_setSingleClickCallback(ch1(), CLICK_HANDLER_defineCallBack(&LED_on, l1()));
|
|
CLICK_HANDLER_setSingleClickCallback(ch3(), CLICK_HANDLER_defineCallBack(&LED_on, l3()));
|
|
|
|
CLICK_HANDLER_setDoubleClickCallback(ch1(), CLICK_HANDLER_defineCallBack(&LED_off, l1()));
|
|
CLICK_HANDLER_setDoubleClickCallback(ch3(), CLICK_HANDLER_defineCallBack(&LED_off, l3()));
|
|
|
|
CLICK_HANDLER_setLongClickCallback(ch1(), CLICK_HANDLER_defineCallBack(&LED_on, l2()));
|
|
CLICK_HANDLER_setLongClickCallback(ch3(), CLICK_HANDLER_defineCallBack(&LED_off, l2()));
|
|
}
|
|
|
|
//start all state machines
|
|
void Factory_start() {
|
|
//LEDBlinker_startBehaviour(lb());
|
|
BUTTON_startBehaviour(b1());
|
|
BUTTON_startBehaviour(b2());
|
|
BUTTON_startBehaviour(b3());
|
|
CLICK_HANDLER_startBehaviour(ch1());
|
|
CLICK_HANDLER_startBehaviour(ch2());
|
|
CLICK_HANDLER_startBehaviour(ch3());
|
|
}
|