prepare EEPROM and logic funcs

This commit is contained in:
2024-09-08 22:20:30 +03:00
parent 962333bfec
commit 400ee6dee0
7 changed files with 241 additions and 105 deletions

View File

@ -9,23 +9,19 @@
#include "EEPROM.h"
#include "Print.h"
typedef enum Mode {
NoneMode,
ShotMode,
ProgramMode,
MacroMode,
NoneMode, ShotMode, ProgramMode, MacroMode,
} Mode;
uint8_t isPause = 0;
uint8_t isShooting = 0;
typedef struct CurrentProgram{
typedef struct CurrentProgram {
Program program;
uint8_t shot_index;
} CurrentProgram;
typedef struct CurrentMacro{
typedef struct CurrentMacro {
Macro macro;
uint8_t program_index;
} CurrentMacro;
@ -39,10 +35,24 @@ typedef struct Current {
Current current;
HardwareInit_t hwSettings = {
/*DelayTimes*/ {
/*preRun*/ 0
},
/*ServoSetting*/{
{0, 0, 90, 180},
{0, 0, 90, 180},
{0, 0, 90, 180}
},
/*Motors*/{
0, 0
}
};
extern int16_t Vz1;
extern int16_t Vz2;
void doShot(Shot* shot){
void doShot(Shot *shot) {
SetServo(0, shot->rotationHorizontal);
SetServo(1, shot->rotationVertical);
SetServo(2, shot->rotationAxial);
@ -51,7 +61,7 @@ void doShot(Shot* shot){
setScrewkSpeed(shot->speedScrew);
}
void startShooting(){
void startShooting() {
switch (current.mode) {
case ShotMode:
print("StartShooting\n");
@ -86,11 +96,11 @@ void startShooting(){
}
}
void stopShooting(){
void stopShooting() {
isShooting = 0;
isPause = 0;
setScrewkSpeed(0);
setRollersSpeed(100,100);
setRollersSpeed(100, 100);
setPosDefault();
Vz1 = 100;
Vz2 = 100;
@ -98,13 +108,14 @@ void stopShooting(){
TIM1->CCR2 = 0;
}
void doShotForever(uint8_t number){
void doShotForever(uint8_t number) {
}
uint8_t prepareShot(uint8_t number){
Shot shot = GetShot(number);
if(shot.isExist){
uint8_t prepareShot(uint8_t number) {
Shot shot;
getShot(number, &shot);
if (shot.isExist) {
current.mode = ShotMode;
current.shot = shot;
return 1;
@ -114,32 +125,41 @@ uint8_t prepareShot(uint8_t number){
}
}
void setPos(uint8_t axial, uint8_t horizontal, uint8_t vertical) {
void setPos(){
//todo:
// hwSettings.servos[SERVO_AXIAL].invert
SetServo(SERVO_AXIAL, axial); // Axial
SetServo(SERVO_HORIZONTAL, horizontal); // Horizontal
SetServo(SERVO_VERTICAL, vertical); // Vertical
}
void setPosDefault(){
SetServo(0, 90);
SetServo(1, 90);
SetServo(2, 90);
void setPosDefault() {
SetServo(0, 90); // Axial
SetServo(1, 90); // Horizontal
SetServo(2, 90); // Vertical
}
// 0 .. 100
void setScrewkSpeed(uint8_t speed){
void setScrewkSpeed(uint8_t speed) {
if(speed && speed < hwSettings.motors.speed_Screw_min)
speed = hwSettings.motors.speed_Screw_min;
TIM1->CCR1 = 0;
TIM1->CCR2 = (uint16_t)(40 * speed);
}
//(-v) 0 .. 100(stop) .. 200(+v)
void setRollersSpeed(uint8_t up, uint8_t down){
void setRollersSpeed(uint8_t up, uint8_t down) {
Vz1 = up;
Vz2 = down;
}
// shot sequence
void startProgram(){
void startProgram() {
}
// shot sequence
void startMacro(){
void startMacro() {
}