54 lines
741 B
C
54 lines
741 B
C
|
#include "factory.h"
|
||
|
|
||
|
|
||
|
//the factory object containing all objects of our system
|
||
|
static Factory theFactory;
|
||
|
|
||
|
|
||
|
//all the getters
|
||
|
LED* l()
|
||
|
{
|
||
|
return &theFactory.l_;
|
||
|
}
|
||
|
|
||
|
Button* b()
|
||
|
{
|
||
|
return &theFactory.b_;
|
||
|
}
|
||
|
|
||
|
ButtonSM* bsm()
|
||
|
{
|
||
|
return &theFactory.bsm_;
|
||
|
}
|
||
|
|
||
|
BLControl* blc()
|
||
|
{
|
||
|
return &theFactory.blc_;
|
||
|
}
|
||
|
|
||
|
|
||
|
//initialize all objects
|
||
|
void Factory_init()
|
||
|
{
|
||
|
LED_init(l(),LID);
|
||
|
LED_initHW(l());
|
||
|
Button_init(b(),BID, true);
|
||
|
Button_initHW(b());
|
||
|
ButtonSM_init(bsm(),b());
|
||
|
BLControl_init(blc());
|
||
|
;
|
||
|
|
||
|
}
|
||
|
|
||
|
//connect objects if required
|
||
|
void Factory_build()
|
||
|
{
|
||
|
ButtonSM_setObserver(bsm(), blc(), &BLControl_onButton);
|
||
|
}
|
||
|
|
||
|
//start all state machines
|
||
|
void Factory_start()
|
||
|
{
|
||
|
ButtonSM_startBehaviour(bsm());
|
||
|
}
|