Working UART

This commit is contained in:
2024-09-16 19:43:48 +03:00
parent cad6b45c5d
commit 2ef50d8b07
6 changed files with 142 additions and 90 deletions

View File

@ -9,31 +9,10 @@
#include "EEPROM.h"
#include "Print.h"
typedef enum Mode {
NoneMode, ShotMode, ProgramMode, MacroMode,
} Mode;
uint8_t isPause = 0;
uint8_t isShooting = 0;
typedef struct CurrentProgram {
Program program;
uint8_t shot_index;
} CurrentProgram;
typedef struct CurrentMacro {
Macro macro;
uint8_t program_index;
} CurrentMacro;
typedef struct Current {
Mode mode;
Shot shot;
CurrentProgram program;
CurrentMacro macro;
} Current;
Current current;
CurrentInfo currentInfo;
HardwareInit_t hwSettings = {
/*DelayTimes*/{
@ -59,31 +38,31 @@ void doShot(Shot *shot) {
}
void startShooting() {
switch (current.mode) {
switch (currentInfo.mode) {
case ShotMode:
print("StartShooting\n");
if (current.shot.isExist) {
if (currentInfo.shot.shot.isExist) {
print("Fire!\n");
print("isExist ");
printNumber(current.shot.isExist);
printNumber(currentInfo.shot.shot.isExist);
print("countRepeatShot; ");
printNumber(current.shot.countRepeatShot);
printNumber(currentInfo.shot.shot.countRepeatShot);
print("speedRollerTop; ");
printNumber(current.shot.speedRollerTop);
printNumber(currentInfo.shot.shot.speedRollerTop);
print("speedRollerBottom; ");
printNumber(current.shot.speedRollerBottom);
printNumber(currentInfo.shot.shot.speedRollerBottom);
print("speedScrew; ");
printNumber(current.shot.speedScrew);
printNumber(currentInfo.shot.shot.speedScrew);
print("rotationAxial; ");
printNumber(current.shot.rotationAxial);
printNumber(currentInfo.shot.shot.rotationAxial);
print("rotationHorizontal; ");
printNumber(current.shot.rotationHorizontal);
printNumber(currentInfo.shot.shot.rotationHorizontal);
print("rotationVertical; ");
printNumber(current.shot.rotationVertical);
printNumber(currentInfo.shot.shot.rotationVertical);
isShooting = 1;
doShot(&current.shot);
currentInfo.state.isShooting = 1;
doShot(&currentInfo.shot.shot);
} else {
print("Current Shot is NULL\n");
// TODO: sound_ERR(); ledFX_ERR();
@ -101,8 +80,8 @@ void startShooting() {
}
void stopShooting() {
isShooting = 0;
isPause = 0;
currentInfo.state.isPause = 0;
currentInfo.state.isShooting = 0;
setScrewkSpeed(0);
setRollersSpeed(100, 100);
@ -117,8 +96,8 @@ uint8_t prepareShot(uint8_t number) {
Shot shot;
getShot(number, &shot);
if (shot.isExist) {
current.mode = ShotMode;
current.shot = shot;
currentInfo.mode = ShotMode;
currentInfo.shot.shot = shot;
return 1;
} else {
// TODO: sound_ERR(); ledFX_ERR();