shooting process

This commit is contained in:
2024-09-22 00:19:50 +03:00
parent 6746f19cf0
commit b98846eac1
12 changed files with 393 additions and 151 deletions

View File

@ -11,6 +11,12 @@
#include "pca9685.h"
#include "EEPROM.h"
// 0 - setPos AFTER preRun delay
// 1 - setPos IMMEDIATELY
#define PRE_RUN_DELAY_MODE 0
#define NOBALL_TIMEOUT_MULTIPLIER 4.2
typedef enum ServoMap{
SERVO_AXIAL = 0,
SERVO_HORIZONTAL = 1,
@ -21,8 +27,16 @@ typedef enum CurrentMode {
NoneMode, ShotMode, ProgramMode, MacroMode,
} Mode;
typedef enum State{
STOP,
RUN,
PAUSE,
PRERUN_WAIT
}State;
typedef struct CurrentShot {
uint8_t index;
uint16_t currentRepeatCount;
Shot shot;
} CurrentShot;
@ -38,43 +52,47 @@ typedef struct CurrentMacro {
uint8_t program_index;
} CurrentMacro;
typedef struct CurrentState {
uint8_t isPause;
uint8_t isShooting;
} CurrentState;
//typedef struct CurrentState {
// uint8_t isPause;
// uint8_t isShooting;
//} CurrentState;
typedef struct CurrentInfo {
Mode mode;
CurrentState state;
State state;
CurrentShot shot;
CurrentProgram program;
CurrentMacro macro;
uint32_t startDelay;
} CurrentInfo;
void Robot_INIT();
void doShot(Shot*);
void shotApply(Shot*);
void doShotForever(uint8_t number);
void BallEXT();
void RobotTick();
uint8_t prepareShot(uint8_t number);
//uint8_t prepareProgramm(uint8_t number);
//uint8_t prepareMacro(uint8_t number);
void startShooting();
void startShooting(uint32_t delayTime);
void stopShooting();
int16_t map(int16_t x, int16_t in_min, int16_t in_max, int16_t out_min,
int16_t out_max);
long map(long x, long in_min, long in_max, long out_min, long out_max);
void setPos(uint8_t axial, uint8_t horizontal, uint8_t vertical);
void setPosSingle(ServoMap servo, uint8_t value);
void setPosFromShot(Shot* shot);
void setPosDefault();
void setPosDefaultSingle(ServoMap servo);
// 0 .. 100
void setScrewkSpeed(uint8_t speed);
//(-v) 0 .. 100(stop) .. 200(+v)
void setRollersSpeed(uint8_t up, uint8_t down); //(-v) 0 . 100(stop) . 200(+v)