Initial commit
This commit is contained in:
53
306-controller_interface.X/factory/factory.c
Normal file
53
306-controller_interface.X/factory/factory.c
Normal file
@ -0,0 +1,53 @@
|
||||
#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());
|
||||
}
|
41
306-controller_interface.X/factory/factory.h
Normal file
41
306-controller_interface.X/factory/factory.h
Normal file
@ -0,0 +1,41 @@
|
||||
/* this is the Factory class */
|
||||
|
||||
|
||||
#ifndef FACTORY_ONCE
|
||||
#define FACTORY_ONCE
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../board/led/led.h"
|
||||
#include "../board/button/button.h"
|
||||
#include "../board/button/buttonsm.h"
|
||||
#include "../app/blcontrol.h"
|
||||
|
||||
|
||||
#define BID 1
|
||||
#define LID 1
|
||||
|
||||
void bObs(void*, uint8_t,bool);
|
||||
|
||||
struct Factory_
|
||||
{
|
||||
LED l_;
|
||||
Button b_;
|
||||
ButtonSM bsm_;
|
||||
BLControl blc_;
|
||||
};
|
||||
|
||||
typedef struct Factory_ Factory;
|
||||
|
||||
void Factory_init();
|
||||
void Factory_build();
|
||||
void Factory_start();
|
||||
|
||||
//these are global getters for our objects
|
||||
LED* l();
|
||||
Button* b();
|
||||
ButtonSM* bsm();
|
||||
BLControl* blc();
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user