This repository has been archived on 2024-01-25. You can view files and clone it, but cannot push or open issues or pull requests.

89 lines
1.8 KiB
C
Raw Normal View History

#include "factory.h"
//the factory object containing all objects of our system
static Factory theFactory;
//all the getters
LED* l7() {
return &theFactory.l7_;
}
LED* l8() {
return &theFactory.l8_;
}
ALIVE* ALcontroller(){
return &theFactory.ALcontroller_;
2023-08-25 14:13:51 +02:00
}
ALIVE* ALjoy(){
return &theFactory.ALjoy_;
2023-08-25 18:23:36 +02:00
}
2023-08-31 20:02:41 +02:00
DRIVE* drive(){
return &theFactory.drive_;
2023-08-31 17:02:23 +02:00
}
2023-09-04 15:20:54 +02:00
STEERING* steering(){
return &theFactory.steering_;
}
//initialize all objects
void Factory_init() {
LED_init(l7(), 7);
LED_init(l8(), 8);
LED_initHW(l7());
LED_initHW(l8());
CAN_init();
2023-08-24 17:28:30 +02:00
CAN_setSender(1);
2023-08-25 14:13:51 +02:00
2023-08-28 12:57:16 +02:00
MEM_init();
2023-09-07 10:31:26 +02:00
initRamp();
2023-08-25 14:13:51 +02:00
2023-09-05 08:52:27 +02:00
ALIVE_init(ALcontroller(), 6);
2023-08-30 15:37:53 +02:00
ALIVE_setAliveTime(ALcontroller(), KART_CST.CONTROL_ALIVE_TIME);
2023-08-25 18:23:36 +02:00
2023-09-05 08:52:27 +02:00
ALIVE_init(ALjoy(), 1);
2023-08-31 20:02:41 +02:00
DRIVE_init(drive());
2023-09-04 15:20:54 +02:00
STEERING_init(steering());
}
//connect objects if required
void Factory_build() {
ECAN_SetRXBnInterruptHandler(CAN_newMsg);
2023-08-25 18:35:01 +02:00
CAN_onReceiveCan(CM_processIncome);
2023-08-25 14:13:51 +02:00
ALIVE_onAlive(ALcontroller(), CM_CONTROLLER_ALIVE, NULL);
ALIVE_onSetup(ALjoy(), CM_JOY_SETUP, NULL);
2023-08-30 15:37:53 +02:00
ALIVE_setAliveTime(ALjoy(), KART_CST.JOYSTICK_ALIVE_TIME);
2023-09-05 08:52:27 +02:00
//ALIVE_onBorn(ALjoy(), LED_on, l1());
2023-09-05 20:02:25 +02:00
ALIVE_onDead(ALjoy(), deadJoystick, NULL);
2023-08-25 18:23:36 +02:00
2023-09-05 08:52:27 +02:00
//DRIVE_onRun(drive(), LED_on, l2());
//DRIVE_onDead(drive(), LED_off, l2());
2023-08-31 17:02:23 +02:00
2023-09-05 08:52:27 +02:00
//STEERING_onRun(steering(), LED_on, l3());
//STEERING_onDead(steering(), LED_off, l3());
2023-09-04 15:20:54 +02:00
}
//start all state machines
void Factory_start() {
CAN_startBehaviour();
2023-09-07 09:10:45 +02:00
ALIVE_startBehaviourSender(ALcontroller());
2023-09-06 21:03:23 +02:00
/*
2023-09-01 13:22:35 +02:00
DRIVE_startBehaviour(drive());
2023-09-04 15:44:36 +02:00
STEERING_startBehaviour(steering());
2023-09-01 13:22:35 +02:00
ALIVE_startBehaviourChecker(ALjoy());
ALIVE_emitBorn(ALjoy(), 100, 0);
ALIVE_emitReady(ALjoy(), 200, 0);
2023-09-06 21:03:23 +02:00
*/
2023-08-31 17:02:23 +02:00
2023-08-25 18:23:36 +02:00
}