From 0329c762a0d660c03beec23da24fd3cb0b1f6c52 Mon Sep 17 00:00:00 2001 From: Klagarge Date: Tue, 5 Sep 2023 20:02:25 +0200 Subject: [PATCH] add dead joystick --- 306-controller_interface.X/app/factory/factory.c | 2 +- 306-controller_interface.X/app/factory/factory.h | 1 + 306-controller_interface.X/app/kartculator.c | 4 ++++ 306-controller_interface.X/app/kartculator.h | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/306-controller_interface.X/app/factory/factory.c b/306-controller_interface.X/app/factory/factory.c index 7980383..b896121 100644 --- a/306-controller_interface.X/app/factory/factory.c +++ b/306-controller_interface.X/app/factory/factory.c @@ -59,7 +59,7 @@ void Factory_build() { ALIVE_onSetup(ALjoy(), CM_JOY_SETUP, NULL); ALIVE_setAliveTime(ALjoy(), KART_CST.JOYSTICK_ALIVE_TIME); //ALIVE_onBorn(ALjoy(), LED_on, l1()); - //ALIVE_onDead(ALjoy(), LED_off, l1()); + ALIVE_onDead(ALjoy(), deadJoystick, NULL); //DRIVE_onRun(drive(), LED_on, l2()); //DRIVE_onDead(drive(), LED_off, l2()); diff --git a/306-controller_interface.X/app/factory/factory.h b/306-controller_interface.X/app/factory/factory.h index f486e95..0b89f81 100644 --- a/306-controller_interface.X/app/factory/factory.h +++ b/306-controller_interface.X/app/factory/factory.h @@ -17,6 +17,7 @@ #include "../eeprom.h" #include "../drive.h" #include "../steering.h" +#include "../kartculator.h" #include "../../board/led/led.h" #include "../../board/button/button.h" #include "../../middleware/alive.h" diff --git a/306-controller_interface.X/app/kartculator.c b/306-controller_interface.X/app/kartculator.c index aa43fef..40f2b5c 100644 --- a/306-controller_interface.X/app/kartculator.c +++ b/306-controller_interface.X/app/kartculator.c @@ -7,6 +7,10 @@ #include "kartculator.h" +void deadJoystick(void* p){ + eKart.torque = 0; + eKart.position = eKart.center; +} void calcTorque(uint8_t joy_pos) { int32_t calcTorque; calcTorque = (int8_t) joy_pos; // joystick position diff --git a/306-controller_interface.X/app/kartculator.h b/306-controller_interface.X/app/kartculator.h index a2ce5cb..cad450f 100644 --- a/306-controller_interface.X/app/kartculator.h +++ b/306-controller_interface.X/app/kartculator.h @@ -13,6 +13,7 @@ #include "../mcc_generated_files/mcc.h" #include "car.h" +void deadJoystick(void* p); void calcTorque(uint8_t joy_pos); void calcPosition(uint8_t joy_pos); void calcSpeed(int32_t rpm);