mirror of
https://github.com/DashyFox/StackSport.git
synced 2025-05-03 23:00:17 +00:00
fix rc debug and ir logic
This commit is contained in:
parent
6c3af6fbb5
commit
839da85dfe
@ -14,7 +14,7 @@
|
|||||||
</extensions>
|
</extensions>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.952459078" name="Debug" parent="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug" postbuildStep="STM32_Programmer_CLI -c port=SWD -w "${ProjName}.hex" -v -rst">
|
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.952459078" name="Debug" parent="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug" postbuildStep="STM32_Programmer_CLI -c port=SWD -w "${ProjName}.hex" -v -rst">
|
||||||
<folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.952459078." name="/" resourcePath="">
|
<folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.952459078." name="/" resourcePath="">
|
||||||
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug.1721750213" name="MCU ARM GCC" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug">
|
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug.1721750213" name="MCU ARM GCC" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug">
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.1582155796" name="MCU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu" useByScannerDiscovery="true" value="STM32F103C8Tx" valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.1582155796" name="MCU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu" useByScannerDiscovery="true" value="STM32F103C8Tx" valueType="string"/>
|
||||||
@ -36,7 +36,7 @@
|
|||||||
</tool>
|
</tool>
|
||||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.400718382" name="MCU/MPU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
|
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.400718382" name="MCU/MPU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler">
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.1282773953" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g3" valueType="enumerated"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.1282773953" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.debuglevel.value.g3" valueType="enumerated"/>
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.394842051" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.os" valueType="enumerated"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.394842051" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.o3" valueType="enumerated"/>
|
||||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1350178782" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1350178782" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||||
<listOptionValue builtIn="false" value="DEBUG"/>
|
<listOptionValue builtIn="false" value="DEBUG"/>
|
||||||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||||
|
@ -45,4 +45,6 @@ enum IR_CMD_LIST {
|
|||||||
IR_ENGINE_DOWM_DEC = 17
|
IR_ENGINE_DOWM_DEC = 17
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void IR_CMD_Clear();
|
||||||
|
|
||||||
#endif /* INC_IR_CMD_HANDLER_H_ */
|
#endif /* INC_IR_CMD_HANDLER_H_ */
|
||||||
|
@ -24,6 +24,7 @@ typedef enum ServoMap{
|
|||||||
|
|
||||||
typedef enum Mode {
|
typedef enum Mode {
|
||||||
NoneMode, ShotMode, ProgramMode, MacroMode,
|
NoneMode, ShotMode, ProgramMode, MacroMode,
|
||||||
|
DebugShot,
|
||||||
} Mode;
|
} Mode;
|
||||||
|
|
||||||
typedef enum State{
|
typedef enum State{
|
||||||
@ -85,6 +86,7 @@ uint8_t prepareMacro(uint8_t number);
|
|||||||
|
|
||||||
void startShooting(uint32_t delayTime);
|
void startShooting(uint32_t delayTime);
|
||||||
void stopShooting();
|
void stopShooting();
|
||||||
|
void pauseShooting();
|
||||||
|
|
||||||
long map(long x, long in_min, long in_max, long out_min, long out_max);
|
long map(long x, long in_min, long in_max, long out_min, long out_max);
|
||||||
|
|
||||||
|
@ -135,6 +135,7 @@ MemoryStatus saveInfoBlock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MemoryStatus getInfoBlock() {
|
MemoryStatus getInfoBlock() {
|
||||||
|
memset(&infoBlock, 0x00, sizeof(InfoBlock));
|
||||||
MemoryStatus status = FLASH_ReadBlock(START_ADR_STAT, 0,
|
MemoryStatus status = FLASH_ReadBlock(START_ADR_STAT, 0,
|
||||||
(uint8_t*) &infoBlock, sizeof(InfoBlock));
|
(uint8_t*) &infoBlock, sizeof(InfoBlock));
|
||||||
|
|
||||||
@ -155,6 +156,7 @@ MemoryStatus saveShot(unsigned char number, Shot *shot) {
|
|||||||
|
|
||||||
MemoryStatus getShot(unsigned char number, Shot *shot) {
|
MemoryStatus getShot(unsigned char number, Shot *shot) {
|
||||||
HAL_IWDG_Refresh(&hiwdg);
|
HAL_IWDG_Refresh(&hiwdg);
|
||||||
|
memset(shot, 0x00, sizeof(Shot));
|
||||||
if (FLASH_ReadBlock(START_ADR_SHOT, number, (uint8_t*) shot, SHOT_BLOCKSIZE)
|
if (FLASH_ReadBlock(START_ADR_SHOT, number, (uint8_t*) shot, SHOT_BLOCKSIZE)
|
||||||
!= EEPROM_OK) {
|
!= EEPROM_OK) {
|
||||||
return EEPROM_FAIL;
|
return EEPROM_FAIL;
|
||||||
@ -198,6 +200,7 @@ MemoryStatus saveProg(unsigned char number, Program *prog) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MemoryStatus getProg(unsigned char number, Program *prog) {
|
MemoryStatus getProg(unsigned char number, Program *prog) {
|
||||||
|
memset(prog, 0x00, sizeof(Program));
|
||||||
if (FLASH_ReadBlock(START_ADR_PROGRAM, number, (uint8_t*) prog,
|
if (FLASH_ReadBlock(START_ADR_PROGRAM, number, (uint8_t*) prog,
|
||||||
PROGRAM_BLOCKSIZE) != EEPROM_OK) {
|
PROGRAM_BLOCKSIZE) != EEPROM_OK) {
|
||||||
return EEPROM_FAIL;
|
return EEPROM_FAIL;
|
||||||
@ -245,6 +248,7 @@ MemoryStatus saveMacro(unsigned char number, Macro *macro) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MemoryStatus getMacro(unsigned char number, Macro *macro) {
|
MemoryStatus getMacro(unsigned char number, Macro *macro) {
|
||||||
|
memset(macro, 0x00, sizeof(Macro));
|
||||||
if (FLASH_ReadBlock(START_ADR_MACRO, number, (uint8_t*) macro,
|
if (FLASH_ReadBlock(START_ADR_MACRO, number, (uint8_t*) macro,
|
||||||
MACRO_BLOCKSIZE) != EEPROM_OK) {
|
MACRO_BLOCKSIZE) != EEPROM_OK) {
|
||||||
return EEPROM_FAIL;
|
return EEPROM_FAIL;
|
||||||
@ -364,7 +368,7 @@ MemoryStatus FLASH_ReadBlock(uint16_t startAddr, uint8_t number,
|
|||||||
return EEPROM_OUT_OF_RANGE;
|
return EEPROM_OUT_OF_RANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(readData, 0x00, dataSize);
|
// memset(readData, 0x00, !!!!dataSize!!!!);
|
||||||
|
|
||||||
uint16_t blockAddr16 = (uint16_t) (startAddr
|
uint16_t blockAddr16 = (uint16_t) (startAddr
|
||||||
+ (uint16_t) (number * dataSize));
|
+ (uint16_t) (number * dataSize));
|
||||||
|
@ -74,6 +74,8 @@ uint8_t speedDown = 100;
|
|||||||
|
|
||||||
void IR_Home_Process() {
|
void IR_Home_Process() {
|
||||||
InputHandler = IR_Home_Process;
|
InputHandler = IR_Home_Process;
|
||||||
|
uint8_t isshotRcOverride = currentInfo.mode == ShotMode
|
||||||
|
&& currentInfo.state == RUN;
|
||||||
switch (data.command) {
|
switch (data.command) {
|
||||||
case IR_SHOT:
|
case IR_SHOT:
|
||||||
paramEnter(onSelectShot);
|
paramEnter(onSelectShot);
|
||||||
@ -96,106 +98,104 @@ void IR_Home_Process() {
|
|||||||
|
|
||||||
case IR_PAUSE:
|
case IR_PAUSE:
|
||||||
if (currentInfo.state == RUN) {
|
if (currentInfo.state == RUN) {
|
||||||
currentInfo.state = PAUSE;
|
pauseShooting();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IR_START:
|
case IR_START:
|
||||||
if (currentInfo.state == PAUSE) {
|
if (currentInfo.state == PAUSE) {
|
||||||
currentInfo.state = RUN;
|
currentInfo.state = RUN;
|
||||||
|
switch (currentInfo.mode) {
|
||||||
|
case DebugShot:
|
||||||
|
case ShotMode:
|
||||||
|
shotApply(¤tInfo.shot);
|
||||||
|
break;
|
||||||
|
case ProgramMode:
|
||||||
|
shotApply(¤tInfo.program.currentShot);
|
||||||
|
break;
|
||||||
|
case MacroMode:
|
||||||
|
shotApply(¤tInfo.macro.currentProgram.currentShot);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IR_ESC: {
|
case IR_ESC: {
|
||||||
// if (EEPROM_EARSE() != EEPROM_OK) {
|
IR_CMD_Clear();
|
||||||
// char errorMsg[] = "Error EEPROM_EARSE\n\n";
|
|
||||||
// CDC_Transmit_FS((uint8_t*) errorMsg, strlen(errorMsg));
|
|
||||||
// } else {
|
|
||||||
// char doneMsg[] = "EEPROM_EARSE Done\n\n";
|
|
||||||
// CDC_Transmit_FS((uint8_t*) doneMsg, strlen(doneMsg));
|
|
||||||
// }
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IR_DEBUG: {
|
case IR_DEBUG: {
|
||||||
|
if (!(currentInfo.state == STOP || currentInfo.state == PAUSE))
|
||||||
|
break;
|
||||||
|
|
||||||
|
switch (currentInfo.mode) {
|
||||||
|
case ShotMode:
|
||||||
|
currentInfo.mode = DebugShot;
|
||||||
|
currentInfo.state = RUN;
|
||||||
|
shotApply(¤tInfo.shot);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IR_NUM_1:
|
|
||||||
|
|
||||||
break;
|
|
||||||
case IR_NUM_2:
|
|
||||||
break;
|
|
||||||
case IR_NUM_3:
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IR_NUM_7:
|
|
||||||
break;
|
|
||||||
case IR_NUM_8:
|
|
||||||
break;
|
|
||||||
case IR_NUM_9:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IR_NUM_5:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IR_STOP: {
|
case IR_STOP: {
|
||||||
speedUP = 100;
|
print("***********************");
|
||||||
speedDown = 100;
|
|
||||||
screwSpeed = 0;
|
|
||||||
stopShooting();
|
stopShooting();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IR_TEMPO_INC:
|
case IR_TEMPO_INC:
|
||||||
if (currentInfo.shot.shot.speedScrew < 100) {
|
if (isshotRcOverride && currentInfo.shot.shot.speedScrew < 100) {
|
||||||
currentInfo.shot.shot.speedScrew++;
|
currentInfo.shot.shot.speedScrew++;
|
||||||
shotApply(¤tInfo.shot);
|
shotApply(¤tInfo.shot);
|
||||||
// led_progressbar(10, 19, currentInfo.shot.shot.speedScrew); //todo: led_progressbarTMP
|
// led_progressbar(10, 19, currentInfo.shot.shot.speedScrew); //todo: led_progressbarTMP
|
||||||
}
|
|
||||||
onHoldRepeat = IR_Home_Process;
|
onHoldRepeat = IR_Home_Process;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IR_TEMPO_DEC:
|
case IR_TEMPO_DEC:
|
||||||
if (currentInfo.shot.shot.speedScrew > 0) {
|
if (isshotRcOverride && currentInfo.shot.shot.speedScrew > 0) {
|
||||||
currentInfo.shot.shot.speedScrew--;
|
currentInfo.shot.shot.speedScrew--;
|
||||||
shotApply(¤tInfo.shot);
|
shotApply(¤tInfo.shot);
|
||||||
}
|
|
||||||
onHoldRepeat = IR_Home_Process;
|
onHoldRepeat = IR_Home_Process;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IR_ENGINE_UP_INC:
|
case IR_ENGINE_UP_INC:
|
||||||
if (currentInfo.shot.shot.speedRollerTop < 200) {
|
if (isshotRcOverride && currentInfo.shot.shot.speedRollerTop < 200) {
|
||||||
currentInfo.shot.shot.speedRollerTop++;
|
currentInfo.shot.shot.speedRollerTop++;
|
||||||
shotApply(¤tInfo.shot);
|
shotApply(¤tInfo.shot);
|
||||||
}
|
|
||||||
onHoldRepeat = IR_Home_Process;
|
onHoldRepeat = IR_Home_Process;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IR_ENGINE_UP_DEC:
|
case IR_ENGINE_UP_DEC:
|
||||||
if (currentInfo.shot.shot.speedRollerTop > 0) {
|
if (isshotRcOverride && currentInfo.shot.shot.speedRollerTop > 0) {
|
||||||
currentInfo.shot.shot.speedRollerTop--;
|
currentInfo.shot.shot.speedRollerTop--;
|
||||||
shotApply(¤tInfo.shot);
|
shotApply(¤tInfo.shot);
|
||||||
}
|
|
||||||
onHoldRepeat = IR_Home_Process;
|
onHoldRepeat = IR_Home_Process;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IR_ENGINE_DOWM_INC:
|
case IR_ENGINE_DOWM_INC:
|
||||||
if (currentInfo.shot.shot.speedRollerBottom < 200) {
|
if (isshotRcOverride && currentInfo.shot.shot.speedRollerBottom < 200) {
|
||||||
currentInfo.shot.shot.speedRollerBottom++;
|
currentInfo.shot.shot.speedRollerBottom++;
|
||||||
shotApply(¤tInfo.shot);
|
shotApply(¤tInfo.shot);
|
||||||
}
|
|
||||||
onHoldRepeat = IR_Home_Process;
|
onHoldRepeat = IR_Home_Process;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IR_ENGINE_DOWM_DEC:
|
case IR_ENGINE_DOWM_DEC:
|
||||||
if (currentInfo.shot.shot.speedRollerBottom > 0) {
|
if (isshotRcOverride && currentInfo.shot.shot.speedRollerBottom > 0) {
|
||||||
currentInfo.shot.shot.speedRollerBottom--;
|
currentInfo.shot.shot.speedRollerBottom--;
|
||||||
shotApply(¤tInfo.shot);
|
shotApply(¤tInfo.shot);
|
||||||
}
|
|
||||||
onHoldRepeat = IR_Home_Process;
|
onHoldRepeat = IR_Home_Process;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////
|
||||||
@ -293,13 +293,19 @@ void IR_Home_Process() {
|
|||||||
|
|
||||||
void IR_ShootingStart() {
|
void IR_ShootingStart() {
|
||||||
InputHandler = IR_ShootingStart;
|
InputHandler = IR_ShootingStart;
|
||||||
|
|
||||||
switch (data.command) {
|
switch (data.command) {
|
||||||
case IR_START:
|
case IR_START: {
|
||||||
|
InputHandler = IR_Home_Process;
|
||||||
startShooting(infoBlock.hwInfo.timings.preRun);
|
startShooting(infoBlock.hwInfo.timings.preRun);
|
||||||
break;
|
break;
|
||||||
default:
|
}
|
||||||
InputHandler();
|
|
||||||
|
default: {
|
||||||
|
InputHandler = IR_Home_Process;
|
||||||
|
IR_Home_Process();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,8 @@ void IR_CMD_Handler() {
|
|||||||
lastRepeatTime = millis(); // Обновляем время последнего вызова
|
lastRepeatTime = millis(); // Обновляем время последнего вызова
|
||||||
// uint8_t blinkPeriod = 10;
|
// uint8_t blinkPeriod = 10;
|
||||||
led_writeMirror(9, 1);
|
led_writeMirror(9, 1);
|
||||||
|
HAL_Delay(1);
|
||||||
|
led_writeMirror(9,0);
|
||||||
|
|
||||||
onHoldRepeat(); // Вызываем функцию при удержании
|
onHoldRepeat(); // Вызываем функцию при удержании
|
||||||
|
|
||||||
@ -129,16 +130,13 @@ void IR_CMD_Clear() {
|
|||||||
inputInProgerss = 0;
|
inputInProgerss = 0;
|
||||||
digitInputInProgerss = 0;
|
digitInputInProgerss = 0;
|
||||||
inputParam = NULL_NumberParam;
|
inputParam = NULL_NumberParam;
|
||||||
// SetShiftReg_inline(0, 0xff, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IR_ParamEnter() {
|
void IR_ParamEnter() {
|
||||||
// SetShiftReg_inline(0x03, 0, 0);
|
|
||||||
if (0 <= data.command && data.command <= 9) {
|
if (0 <= data.command && data.command <= 9) {
|
||||||
if (digitInputInProgerss) {
|
if (digitInputInProgerss) {
|
||||||
inputParam = inputParam * 10; // dec shift << 1
|
inputParam = inputParam * 10; // dec shift << 1
|
||||||
inputParam += (data.command + 1) % 10;
|
inputParam += (data.command + 1) % 10;
|
||||||
// SetShiftReg_inline(0xF0, 0, 0);
|
|
||||||
} else {
|
} else {
|
||||||
inputParam = (data.command + 1) % 10;
|
inputParam = (data.command + 1) % 10;
|
||||||
}
|
}
|
||||||
@ -151,13 +149,16 @@ void IR_ParamEnter() {
|
|||||||
if(inputParam != NULL_NumberParam){
|
if(inputParam != NULL_NumberParam){
|
||||||
print("Enter: ");
|
print("Enter: ");
|
||||||
printNumber(inputParam);
|
printNumber(inputParam);
|
||||||
// SetShiftReg_inline(0, 0, inputParam);
|
|
||||||
onParamEnter();
|
onParamEnter();
|
||||||
}
|
}
|
||||||
inputParam = NULL_NumberParam;
|
inputParam = NULL_NumberParam;
|
||||||
digitInputInProgerss = 0;
|
digitInputInProgerss = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case IR_START:
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
IR_Home_Process();
|
IR_Home_Process();
|
||||||
break;
|
break;
|
||||||
|
@ -228,12 +228,10 @@ void led_progressbar_(uint8_t fromLed, uint8_t toLed, uint8_t progress, void (*l
|
|||||||
ledBlinkInfo[ledIndex].count = 0;
|
ledBlinkInfo[ledIndex].count = 0;
|
||||||
|
|
||||||
if (i < ledsToLight) {
|
if (i < ledsToLight) {
|
||||||
// Включаем светодиод, если он не включен
|
|
||||||
if (!led_getState(ledMap.ALL[ledIndex])) {
|
if (!led_getState(ledMap.ALL[ledIndex])) {
|
||||||
led_writeFunc(ledIndex, 1); // Используем переданную функцию для включения
|
led_writeFunc(ledIndex, 1); // Используем переданную функцию для включения
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Выключаем светодиод, если он включен
|
|
||||||
if (led_getState(ledMap.ALL[ledIndex])) {
|
if (led_getState(ledMap.ALL[ledIndex])) {
|
||||||
led_writeFunc(ledIndex, 0); // Используем переданную функцию для выключения
|
led_writeFunc(ledIndex, 0); // Используем переданную функцию для выключения
|
||||||
}
|
}
|
||||||
@ -270,6 +268,7 @@ void led_PingPong_start(uint8_t fromLed, uint8_t toLed) {
|
|||||||
ledPingPongInfo.writeCallback = led_write;
|
ledPingPongInfo.writeCallback = led_write;
|
||||||
led_PingPong_start_(fromLed, toLed);
|
led_PingPong_start_(fromLed, toLed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void led_PingPong_start_(uint8_t fromLed, uint8_t toLed){
|
void led_PingPong_start_(uint8_t fromLed, uint8_t toLed){
|
||||||
if (fromLed < toLed) {
|
if (fromLed < toLed) {
|
||||||
ledPingPongInfo.start = fromLed;
|
ledPingPongInfo.start = fromLed;
|
||||||
|
@ -23,7 +23,6 @@ unsigned char Shiftreg[3];
|
|||||||
extern InfoBlock infoBlock;
|
extern InfoBlock infoBlock;
|
||||||
uint8_t ballDetected = 0;
|
uint8_t ballDetected = 0;
|
||||||
uint32_t ballReact_timer = 0;
|
uint32_t ballReact_timer = 0;
|
||||||
uint8_t isDelayTimerRun = 0;
|
|
||||||
uint32_t startDelay_timer;
|
uint32_t startDelay_timer;
|
||||||
CurrentShot *postDelayShot = NULL;
|
CurrentShot *postDelayShot = NULL;
|
||||||
uint32_t lastIndicationTime = 0;
|
uint32_t lastIndicationTime = 0;
|
||||||
@ -32,7 +31,7 @@ uint32_t noBallTimeout = 0xFFFFFFFF;
|
|||||||
|
|
||||||
void BallEXT_Handler();
|
void BallEXT_Handler();
|
||||||
void robotStateStart(uint32_t delayTime);
|
void robotStateStart(uint32_t delayTime);
|
||||||
void robotStatePause();
|
void pauseShooting();
|
||||||
void robotStateStop();
|
void robotStateStop();
|
||||||
float calculatePeriod(int pwm_value);
|
float calculatePeriod(int pwm_value);
|
||||||
uint8_t nextBallInShot(CurrentShot *shot);
|
uint8_t nextBallInShot(CurrentShot *shot);
|
||||||
@ -47,10 +46,13 @@ void robotStateStart(uint32_t delayTime) {
|
|||||||
currentInfo.state = PRERUN_WAIT;
|
currentInfo.state = PRERUN_WAIT;
|
||||||
currentInfo.startDelay = delayTime;
|
currentInfo.startDelay = delayTime;
|
||||||
startDelay_timer = millis();
|
startDelay_timer = millis();
|
||||||
isDelayTimerRun = 1;
|
|
||||||
}
|
}
|
||||||
void robotStatePause() {
|
void pauseShooting() {
|
||||||
currentInfo.state = PAUSE;
|
currentInfo.state = PAUSE;
|
||||||
|
led_clear();
|
||||||
|
setScrewkSpeed(0);
|
||||||
|
setRollersSpeed(100, 100);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void robotStateStop() {
|
void robotStateStop() {
|
||||||
@ -116,12 +118,14 @@ void RobotTick() {
|
|||||||
|
|
||||||
// No Ball Handler
|
// No Ball Handler
|
||||||
if (currentInfo.state == RUN && millis() - noBallTimer > noBallTimeout) {
|
if (currentInfo.state == RUN && millis() - noBallTimer > noBallTimeout) {
|
||||||
|
if(currentInfo.mode == DebugShot){
|
||||||
|
currentInfo.mode = ShotMode;
|
||||||
|
}
|
||||||
robotStateStop();
|
robotStateStop();
|
||||||
led_clear();
|
led_clear();
|
||||||
for (int i = 7; i <= 12; ++i) {
|
for (int i = 7; i <= 12; ++i) {
|
||||||
led_blink_num(i, 250, 0xFFFF-1);
|
led_blink_num(i, 250, 0xFFFF - 1);
|
||||||
}
|
}
|
||||||
isDelayTimerRun = 0;
|
|
||||||
setScrewkSpeed(0);
|
setScrewkSpeed(0);
|
||||||
setRollersSpeed(100, 100);
|
setRollersSpeed(100, 100);
|
||||||
setPos(infoBlock.hwInfo.servos[SERVO_AXIAL].def,
|
setPos(infoBlock.hwInfo.servos[SERVO_AXIAL].def,
|
||||||
@ -131,20 +135,19 @@ void RobotTick() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PreRun delay
|
// PreRun delay
|
||||||
if (isDelayTimerRun) {
|
if (currentInfo.state == PRERUN_WAIT) {
|
||||||
uint32_t elapsedTime = millis() - startDelay_timer;
|
uint32_t elapsedTime = millis() - startDelay_timer;
|
||||||
|
|
||||||
if (elapsedTime > currentInfo.startDelay) {
|
if (elapsedTime > currentInfo.startDelay) {
|
||||||
isDelayTimerRun = 0;
|
|
||||||
if (currentInfo.state == PRERUN_WAIT) {
|
|
||||||
currentInfo.state = RUN;
|
currentInfo.state = RUN;
|
||||||
shotApply(postDelayShot);
|
shotApply(postDelayShot);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
uint32_t intervalStep = currentInfo.startDelay / NUMLEDS;
|
uint32_t intervalStep = currentInfo.startDelay / NUMLEDS;
|
||||||
if (elapsedTime - lastIndicationTime >= intervalStep) {
|
if (elapsedTime - lastIndicationTime >= intervalStep) {
|
||||||
lastIndicationTime = elapsedTime;
|
lastIndicationTime = elapsedTime;
|
||||||
uint8_t progress = 100 - (elapsedTime * 100) / currentInfo.startDelay;
|
uint8_t progress = 100
|
||||||
|
- (elapsedTime * 100) / currentInfo.startDelay;
|
||||||
|
|
||||||
uint8_t ledProgress = map(progress, 0, 70, 0, 100);
|
uint8_t ledProgress = map(progress, 0, 70, 0, 100);
|
||||||
if (ledProgress > 30) {
|
if (ledProgress > 30) {
|
||||||
@ -258,6 +261,14 @@ void BallEXT_Handler() {
|
|||||||
infoBlock.statInfo.shotInMacro++;
|
infoBlock.statInfo.shotInMacro++;
|
||||||
saveInfoBlock();
|
saveInfoBlock();
|
||||||
break;
|
break;
|
||||||
|
case DebugShot:
|
||||||
|
currentInfo.mode = ShotMode;
|
||||||
|
led_clear();
|
||||||
|
robotStateStop();
|
||||||
|
setScrewkSpeed(0);
|
||||||
|
setRollersSpeed(100, 100);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -502,10 +513,13 @@ void startShooting(uint32_t delayTime) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void stopShooting() {
|
void stopShooting() {
|
||||||
|
if(currentInfo.mode == DebugShot){
|
||||||
|
currentInfo.mode = ShotMode;
|
||||||
|
}
|
||||||
|
robotStateStop();
|
||||||
|
|
||||||
led_clear();
|
led_clear();
|
||||||
|
|
||||||
isDelayTimerRun = 0;
|
|
||||||
robotStateStop();
|
|
||||||
setScrewkSpeed(0);
|
setScrewkSpeed(0);
|
||||||
setRollersSpeed(100, 100);
|
setRollersSpeed(100, 100);
|
||||||
setPosDefault();
|
setPosDefault();
|
||||||
|
@ -517,7 +517,7 @@ void UART3_ReadStatistics(uint8_t *dataPtr, uint8_t len) {
|
|||||||
} StatusStruct;
|
} StatusStruct;
|
||||||
|
|
||||||
StatusStruct res;
|
StatusStruct res;
|
||||||
uint8_t isRun = currentInfo.state == RUN;
|
uint8_t isRun = currentInfo.state == RUN || currentInfo.state == PRERUN_WAIT;
|
||||||
res.status = isRun;
|
res.status = isRun;
|
||||||
|
|
||||||
res.shot_number = 0xFF;
|
res.shot_number = 0xFF;
|
||||||
|
@ -174,7 +174,36 @@ int main(void)
|
|||||||
|
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
/* USER CODE BEGIN WHILE */
|
/* USER CODE BEGIN WHILE */
|
||||||
|
const char* getStateString(State state) {
|
||||||
|
switch (state) {
|
||||||
|
case STOP:
|
||||||
|
return "STOP";
|
||||||
|
case RUN:
|
||||||
|
return "RUN";
|
||||||
|
case PAUSE:
|
||||||
|
return "PAUSE";
|
||||||
|
case PRERUN_WAIT:
|
||||||
|
return "PRERUN_WAIT";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const char* getModeString(Mode mode) {
|
||||||
|
switch (mode) {
|
||||||
|
case NoneMode:
|
||||||
|
return "NoneMode";
|
||||||
|
case ShotMode:
|
||||||
|
return "ShotMode";
|
||||||
|
case ProgramMode:
|
||||||
|
return "ProgramMode";
|
||||||
|
case MacroMode:
|
||||||
|
return "MacroMode";
|
||||||
|
case DebugShot:
|
||||||
|
return "DebugShot";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
IR_CMD_Handler();
|
IR_CMD_Handler();
|
||||||
@ -194,13 +223,18 @@ int main(void)
|
|||||||
// extern uint32_t vsk2;
|
// extern uint32_t vsk2;
|
||||||
// extern uint16_t timing1;
|
// extern uint16_t timing1;
|
||||||
// extern uint16_t timing2;
|
// extern uint16_t timing2;
|
||||||
// // Форматируем строку для вывода timing1, timing2, vsk1, vsk2
|
|
||||||
// sprintf(buffer,
|
// sprintf(buffer,
|
||||||
// "timing1: %u ms, timing2: %u ms, vsk1: %u RPM, vsk2: %u RPM\n",
|
// "timing1: %u ms, timing2: %u ms, vsk1: %u RPM, vsk2: %u RPM\n",
|
||||||
// timing1, timing2, vsk1, vsk2);
|
// timing1, timing2, vsk1, vsk2);
|
||||||
//
|
//
|
||||||
// // Отправляем строку через CDC (USB)
|
|
||||||
// CDC_Transmit_FS((uint8_t*) buffer, strlen(buffer));
|
// CDC_Transmit_FS((uint8_t*) buffer, strlen(buffer));
|
||||||
|
|
||||||
|
char buffer[64];
|
||||||
|
sprintf(buffer, "Current mode: %s, Current state: %s\n",
|
||||||
|
getModeString(currentInfo.mode),
|
||||||
|
getStateString(currentInfo.state));
|
||||||
|
CDC_Transmit_FS((uint8_t*)buffer, strlen(buffer));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE END WHILE */
|
/* USER CODE END WHILE */
|
||||||
|
31
TODO.md
31
TODO.md
@ -1,10 +1,17 @@
|
|||||||
|
Баги:
|
||||||
|
При сбоях UART вешает его и иногда не переинициализирует даже после рестарта контроллера
|
||||||
|
|
||||||
Логика:
|
Логика:
|
||||||
Ограничение скорости роликов!
|
Ограничение скорости роликов!
|
||||||
Ограничение углов сервы
|
V Ограничение углов сервы
|
||||||
Уточнить, в ТЗ только обработка 201 команды и учитывается только макс угол
|
V Начальное смещение
|
||||||
Начальное смещение:
|
|
||||||
Корректировать макс углы ?
|
Исправлено:
|
||||||
Не корректировать углы ?
|
V+- В некоторый момент PID регулятор выдаёт 0 и двигатель не запускается не зависимо от входного значенияPWM
|
||||||
|
V rc debug button
|
||||||
|
Оранж:
|
||||||
|
V Программы:
|
||||||
|
V Есл стоит "Настроить темп ударов", во все удары приходят нули.
|
||||||
|
|
||||||
Рефактор:
|
Рефактор:
|
||||||
Сделать static все локальные функции
|
Сделать static все локальные функции
|
||||||
@ -36,10 +43,10 @@ IR:
|
|||||||
|
|
||||||
Индикация:
|
Индикация:
|
||||||
V Текущий буфер индикации
|
V Текущий буфер индикации
|
||||||
Функция отображения скорости
|
V Функция отображения скорости
|
||||||
Обратный отсчёт
|
V Обратный отсчёт
|
||||||
Индикация ошибок
|
V Индикация ошибок
|
||||||
Процесс удаления
|
V Процесс удаления
|
||||||
|
|
||||||
Звук:
|
Звук:
|
||||||
Звук приёма IR
|
Звук приёма IR
|
||||||
@ -48,11 +55,5 @@ IR:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Ошибки:
|
|
||||||
V+- В некоторый момент PID регулятор выдаёт 0 и двигатель не запускается не зависимо от входного значенияPWM
|
|
||||||
Оранж:
|
|
||||||
При сбоях UART вешает его и иногда не переинициализирует даже после рестарта контроллера
|
|
||||||
Программы:
|
|
||||||
Есл стоит "Настроить темп ударов", во все удары приходят нули.
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user