fix rc debug and ir logic

This commit is contained in:
2024-10-01 22:34:01 +03:00
parent 6c3af6fbb5
commit 839da85dfe
11 changed files with 154 additions and 91 deletions

View File

@ -74,6 +74,8 @@ uint8_t speedDown = 100;
void IR_Home_Process() {
InputHandler = IR_Home_Process;
uint8_t isshotRcOverride = currentInfo.mode == ShotMode
&& currentInfo.state == RUN;
switch (data.command) {
case IR_SHOT:
paramEnter(onSelectShot);
@ -96,106 +98,104 @@ void IR_Home_Process() {
case IR_PAUSE:
if (currentInfo.state == RUN) {
currentInfo.state = PAUSE;
pauseShooting();
}
break;
case IR_START:
if (currentInfo.state == PAUSE) {
currentInfo.state = RUN;
switch (currentInfo.mode) {
case DebugShot:
case ShotMode:
shotApply(&currentInfo.shot);
break;
case ProgramMode:
shotApply(&currentInfo.program.currentShot);
break;
case MacroMode:
shotApply(&currentInfo.macro.currentProgram.currentShot);
break;
default:
break;
}
}
break;
case IR_ESC: {
// if (EEPROM_EARSE() != EEPROM_OK) {
// 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));
// }
IR_CMD_Clear();
break;
}
case IR_DEBUG: {
if (!(currentInfo.state == STOP || currentInfo.state == PAUSE))
break;
switch (currentInfo.mode) {
case ShotMode:
currentInfo.mode = DebugShot;
currentInfo.state = RUN;
shotApply(&currentInfo.shot);
break;
default:
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: {
speedUP = 100;
speedDown = 100;
screwSpeed = 0;
print("***********************");
stopShooting();
break;
}
case IR_TEMPO_INC:
if (currentInfo.shot.shot.speedScrew < 100) {
if (isshotRcOverride && currentInfo.shot.shot.speedScrew < 100) {
currentInfo.shot.shot.speedScrew++;
shotApply(&currentInfo.shot);
// led_progressbar(10, 19, currentInfo.shot.shot.speedScrew); //todo: led_progressbarTMP
onHoldRepeat = IR_Home_Process;
}
onHoldRepeat = IR_Home_Process;
break;
case IR_TEMPO_DEC:
if (currentInfo.shot.shot.speedScrew > 0) {
if (isshotRcOverride && currentInfo.shot.shot.speedScrew > 0) {
currentInfo.shot.shot.speedScrew--;
shotApply(&currentInfo.shot);
onHoldRepeat = IR_Home_Process;
}
onHoldRepeat = IR_Home_Process;
break;
case IR_ENGINE_UP_INC:
if (currentInfo.shot.shot.speedRollerTop < 200) {
if (isshotRcOverride && currentInfo.shot.shot.speedRollerTop < 200) {
currentInfo.shot.shot.speedRollerTop++;
shotApply(&currentInfo.shot);
onHoldRepeat = IR_Home_Process;
}
onHoldRepeat = IR_Home_Process;
break;
case IR_ENGINE_UP_DEC:
if (currentInfo.shot.shot.speedRollerTop > 0) {
if (isshotRcOverride && currentInfo.shot.shot.speedRollerTop > 0) {
currentInfo.shot.shot.speedRollerTop--;
shotApply(&currentInfo.shot);
onHoldRepeat = IR_Home_Process;
}
onHoldRepeat = IR_Home_Process;
break;
case IR_ENGINE_DOWM_INC:
if (currentInfo.shot.shot.speedRollerBottom < 200) {
if (isshotRcOverride && currentInfo.shot.shot.speedRollerBottom < 200) {
currentInfo.shot.shot.speedRollerBottom++;
shotApply(&currentInfo.shot);
onHoldRepeat = IR_Home_Process;
}
onHoldRepeat = IR_Home_Process;
break;
case IR_ENGINE_DOWM_DEC:
if (currentInfo.shot.shot.speedRollerBottom > 0) {
if (isshotRcOverride && currentInfo.shot.shot.speedRollerBottom > 0) {
currentInfo.shot.shot.speedRollerBottom--;
shotApply(&currentInfo.shot);
onHoldRepeat = IR_Home_Process;
}
onHoldRepeat = IR_Home_Process;
break;
/////////////////////////////////////////////////////////
@ -293,13 +293,19 @@ void IR_Home_Process() {
void IR_ShootingStart() {
InputHandler = IR_ShootingStart;
switch (data.command) {
case IR_START:
startShooting(infoBlock.hwInfo.timings.preRun);
break;
default:
InputHandler();
break;
case IR_START: {
InputHandler = IR_Home_Process;
startShooting(infoBlock.hwInfo.timings.preRun);
break;
}
default: {
InputHandler = IR_Home_Process;
IR_Home_Process();
break;
}
}
}