mirror of
https://github.com/DashyFox/StackSport.git
synced 2025-05-04 07:10:17 +00:00
104 lines
2.0 KiB
C
104 lines
2.0 KiB
C
/*
|
|
* RobotFunctions.h
|
|
*
|
|
* Created on: Aug 24, 2024
|
|
* Author: DashyFox
|
|
*/
|
|
|
|
#ifndef INC_ROBOTFUNCTIONS_H_
|
|
#define INC_ROBOTFUNCTIONS_H_
|
|
|
|
#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,
|
|
SERVO_VERTICAL = 2
|
|
}ServoMap;
|
|
|
|
typedef enum Mode {
|
|
NoneMode, ShotMode, ProgramMode, MacroMode,
|
|
} Mode;
|
|
|
|
typedef enum State{
|
|
STOP,
|
|
RUN,
|
|
PAUSE,
|
|
PRERUN_WAIT
|
|
}State;
|
|
|
|
typedef struct CurrentShot {
|
|
uint8_t indexGlobal;
|
|
uint16_t currentBallCount;
|
|
Shot shot;
|
|
uint16_t doneCount;
|
|
} CurrentShot;
|
|
|
|
typedef struct CurrentProgram {
|
|
uint8_t indexGlobal;
|
|
Program program;
|
|
CurrentShot currentShot;
|
|
uint8_t currentShotIndexLocal;
|
|
uint16_t currentBallCount;
|
|
uint16_t doneCount;
|
|
} CurrentProgram;
|
|
|
|
typedef struct CurrentMacro {
|
|
uint8_t indexGlobal;
|
|
Macro macro;
|
|
CurrentProgram currentProgram;
|
|
uint8_t currentProgramIndexLocal;
|
|
uint16_t currentBallCount;
|
|
uint16_t doneCount;
|
|
} CurrentMacro;
|
|
|
|
typedef struct CurrentInfo {
|
|
Mode mode;
|
|
State state;
|
|
CurrentShot shot;
|
|
CurrentProgram program;
|
|
CurrentMacro macro;
|
|
uint32_t startDelay;
|
|
} CurrentInfo;
|
|
|
|
extern CurrentInfo currentInfo;
|
|
|
|
void Robot_INIT();
|
|
|
|
void shotApply(CurrentShot*);
|
|
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(uint32_t delayTime);
|
|
void stopShooting();
|
|
|
|
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)
|
|
|
|
#endif /* INC_ROBOTFUNCTIONS_H_ */
|