From 1564f38ff30e9dada362126b4dc388f4c1a547bb Mon Sep 17 00:00:00 2001 From: DashyFox Date: Sun, 22 Sep 2024 23:02:30 +0300 Subject: [PATCH] fix programm --- Core/Src/RobotFunctions.c | 14 +++++++++----- Core/Src/UART3_CMD_Handler.c | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Core/Src/RobotFunctions.c b/Core/Src/RobotFunctions.c index 90bca75..11a3995 100644 --- a/Core/Src/RobotFunctions.c +++ b/Core/Src/RobotFunctions.c @@ -13,7 +13,7 @@ #include "Print.h" #include "SimpleTimer.h" -#define ballReact_value 10 +#define ballReact_value 10 // время реакции на вылет мяча CurrentInfo currentInfo; @@ -266,8 +266,8 @@ void shotApply(Shot *shot) { shot->rotationVertical); setRollersSpeed(shot->speedRollerTop, shot->speedRollerBottom); setScrewkSpeed(shot->speedScrew); - noBallTimeout = calculatePeriod( - shot->speedScrew) * NOBALL_TIMEOUT_MULTIPLIER; + noBallTimeout = MIN(calculatePeriod( + shot->speedScrew) * NOBALL_TIMEOUT_MULTIPLIER, 30000); noBallTimer = millis(); print("Fire!\n"); print("isExist "); @@ -308,8 +308,13 @@ uint8_t loadShotFromProgram(CurrentProgram *currentProg) { // TODO: sound_ERR(); ledFX_ERR(); return 0; } - shot_.speedScrew = + + uint8_t overridenSpeedScrew = currentProg->program.shots[currentProgramShotId].speedScrew; + if (overridenSpeedScrew != 0) { + shot_.speedScrew = overridenSpeedScrew; + } + uint8_t repeatCountFromShot = currentProg->program.header.options & 2U; if (!repeatCountFromShot) { print("Repeat Count Override\n"); @@ -410,7 +415,6 @@ uint8_t prepareShot(uint8_t number) { return 0; } } - uint8_t prepareProgramm(uint8_t number) { Program program; getProg(number, &program); diff --git a/Core/Src/UART3_CMD_Handler.c b/Core/Src/UART3_CMD_Handler.c index 8678b51..45d4e6e 100644 --- a/Core/Src/UART3_CMD_Handler.c +++ b/Core/Src/UART3_CMD_Handler.c @@ -65,7 +65,7 @@ void UART3_SaveProgram(uint8_t *dataPtr, uint8_t len) { prog.header.countRepeat = dataPtr[2]; prog.header.options = dataPtr[3]; - if (dataPtr[4] != 0xFF && dataPtr[5]) { + if (dataPtr[4] != 0xFF && dataPtr[5] != 0xFF) { for (uint8_t i = 0; i < prog.header.shotCount; i++) { uint8_t pos = 4 + i * sizeof(ProgramShot); prog.shots[i].id = dataPtr[pos + 0];