mirror of
https://github.com/DashyFox/StackSport.git
synced 2025-06-28 05:09:32 +00:00
fix logic
This commit is contained in:
@ -143,11 +143,12 @@ void RobotTick() {
|
||||
|
||||
uint8_t prepareShot(uint8_t number) {
|
||||
Shot shot;
|
||||
memset(&shot, 0x00, sizeof(shot));
|
||||
getShot(number, &shot);
|
||||
if (shot.isExist) {
|
||||
currentInfo.mode = ShotMode;
|
||||
currentInfo.shot.shot = shot;
|
||||
currentInfo.shot.currentBallCount = 0;
|
||||
currentInfo.shot.indexGlobal = number;
|
||||
return 1;
|
||||
} else {
|
||||
// TODO: sound_ERR(); ledFX_ERR();
|
||||
@ -157,13 +158,12 @@ uint8_t prepareShot(uint8_t number) {
|
||||
}
|
||||
uint8_t prepareProgramm(uint8_t number) {
|
||||
Program program;
|
||||
memset(&program, 0x00, sizeof(program));
|
||||
getProg(number, &program);
|
||||
if (program.header.shotCount) { // isExist
|
||||
currentInfo.mode = ProgramMode;
|
||||
currentInfo.program.program = program;
|
||||
currentInfo.program.indexGlobal = number;
|
||||
currentInfo.program.currentShotIndexLocal = 0;
|
||||
currentInfo.program.currentBallCount = 0;
|
||||
return 1;
|
||||
} else {
|
||||
// TODO: sound_ERR(); ledFX_ERR();
|
||||
@ -174,13 +174,12 @@ uint8_t prepareProgramm(uint8_t number) {
|
||||
|
||||
uint8_t prepareMacro(uint8_t number) {
|
||||
Macro macro;
|
||||
memset(¯o, 0x00, sizeof(macro));
|
||||
getMacro(number, ¯o);
|
||||
if (macro.header.programmCount) {
|
||||
currentInfo.mode = MacroMode;
|
||||
currentInfo.macro.macro = macro;
|
||||
currentInfo.macro.indexGlobal = number;
|
||||
currentInfo.macro.currentProgramIndexLocal = 0;
|
||||
currentInfo.macro.currentBallCount = 0;
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
@ -283,11 +282,13 @@ uint8_t loadNextShotInProgram(CurrentProgram *currentProg) {
|
||||
|
||||
if (random) {
|
||||
*currentProgramShotId = rand() % currentProg->program.header.shotCount;
|
||||
|
||||
} else {
|
||||
if ((*currentProgramShotId) + 1
|
||||
< currentProg->program.header.shotCount) {
|
||||
++(*currentProgramShotId);
|
||||
} else {
|
||||
currentProg->doneCount++;
|
||||
*currentProgramShotId = 0;
|
||||
}
|
||||
}
|
||||
@ -344,6 +345,7 @@ uint8_t loadNextProgramInMacro(CurrentMacro *currentMacro) {
|
||||
currentMacro->currentProgramIndexLocal++;
|
||||
} else {
|
||||
currentMacro->currentProgramIndexLocal = 0;
|
||||
currentMacro->doneCount++;
|
||||
}
|
||||
return loadProgramFromMacro(currentMacro);
|
||||
}
|
||||
@ -365,6 +367,7 @@ uint8_t nextBallInShot(CurrentShot *shot) {
|
||||
return 0;
|
||||
} else {
|
||||
print("Shot DONE\n");
|
||||
shot->doneCount++;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -394,25 +397,24 @@ uint8_t nextShotInProgram(CurrentProgram *prog) {
|
||||
}
|
||||
|
||||
uint8_t nextProgramInMacro(CurrentMacro *currentMacro) {
|
||||
// uint8_t shotApply_f = 0;
|
||||
uint8_t shotApply_f = 0;
|
||||
if (nextShotInProgram(¤tMacro->currentProgram)) {
|
||||
print("\nSwitch program\n");
|
||||
if (!loadNextProgramInMacro(currentMacro)) {
|
||||
print("loadNextProgramInMacro ERR\n");
|
||||
return 0;
|
||||
}
|
||||
shotApply(¤tMacro->currentProgram.currentShot);
|
||||
// shotApply_f = 1;
|
||||
shotApply_f = 1;
|
||||
}
|
||||
|
||||
// Проверка на завершение макро
|
||||
// if (currentMacro->currentProgramIndexLocal < currentMacro->macro.header.programmCount) {
|
||||
// } else {
|
||||
// print("Macro DONE\n");
|
||||
// return 1;
|
||||
// }
|
||||
// if (shotApply_f)
|
||||
// shotApply(¤tMacro->currentProgram.currentShot);
|
||||
if (currentMacro->doneCount) {
|
||||
print("Macro DONE\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (shotApply_f)
|
||||
shotApply(¤tMacro->currentProgram.currentShot);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user