window clip variant

This commit is contained in:
2024-09-17 23:01:04 +03:00
parent 2ef50d8b07
commit 953593d32a
9 changed files with 842 additions and 646 deletions

View File

@ -3,10 +3,13 @@
#ifndef INC_EEPROM_H_
#define INC_EEPROM_H_
#include <assert.h>
#define AT24C_ADRESS 0x50 // i2c slave adress EEPROM
#define START_ADR_STAT 0x0000 //00000
#define STAT_BLOCKSIZE sizeof(InfoBlock)
#define STAT_BLOCKSIZE 128
#define START_ADR_SHOT (START_ADR_STAT+STAT_BLOCKSIZE)
#define SHOT_BLOCKSIZE 10
@ -34,7 +37,7 @@ typedef enum MemoryStatus {
EEPROM_OK
} MemoryStatus;
typedef struct Shot {
typedef struct __attribute__((packed)) {
unsigned char isExist;
unsigned char countRepeatShot; // 0 = inf
unsigned char speedRollerTop; // 0 .. 100 .. 200
@ -45,83 +48,87 @@ typedef struct Shot {
unsigned char rotationVertical; // 0 .. 90 .. 180
} Shot;
typedef struct ProgramHeader {
typedef struct __attribute__((packed)) {
unsigned char isExist;
unsigned char countRepeat;
unsigned char options;
} ProgramHeader;
typedef struct ProgramShot {
typedef struct __attribute__((packed)) {
unsigned char id;
unsigned char speedScrew;
} ProgramShot;
typedef struct Program {
typedef struct __attribute__((packed)) {
ProgramHeader header;
ProgramShot shots[MAX_SHOT_COUNT_IN_PROGRAMS];
} Program;
typedef struct MacroHeader {
typedef struct __attribute__((packed)) {
unsigned char isExist;
} MacroHeader;
typedef struct MacroProgram {
typedef struct __attribute__((packed)) {
unsigned char id;
unsigned char speedScrew;
unsigned char countRepeat;
unsigned char options;
} MacroProgram;
typedef struct Macro {
typedef struct __attribute__((packed)) {
MacroHeader header;
MacroProgram programs[MAX_PROGRAM_COUNT_IN_MACRO];
} Macro;
typedef struct ServoSetting {
typedef struct __attribute__((packed)) {
uint8_t invert;
uint16_t min;
uint16_t def;
uint16_t max;
} ServoSetting;
typedef struct DelayTimes{
typedef struct __attribute__((packed)) {
uint16_t preRun;
}DelayTimes;
} DelayTimes;
typedef struct Motors{
typedef struct __attribute__((packed)) {
uint16_t speed_Rollers_min;
// uint16_t speed_Rollers_max;
uint16_t speed_Screw_min;
// uint16_t speed_Screw_max;
}Motors;
} Motors;
typedef struct HardwareInit_t{
typedef struct __attribute__((packed)) {
DelayTimes timings;
ServoSetting servos[3];
Motors motors;
}HardwareInit_t;
} HardwareInit_t;
typedef struct Statistics{
typedef struct __attribute__((packed)) {
uint32_t totalShots;
uint32_t totalPrograms;
uint32_t totalMacros;
}Statistics;
} Statistics;
typedef struct InfoBlock{
typedef struct __attribute__((packed)) {
char init_uid[11];
HardwareInit_t hwInfo;
Statistics statInfo;
}InfoBlock;
} InfoBlock;
_Static_assert(sizeof(InfoBlock) <= STAT_BLOCKSIZE, "Error: InfoBlock size exceeds 128 bytes.");
extern InfoBlock infoBlock;
// read from EEPROM infoBlock
// or write to EEPROM default infoBlock
MemoryStatus EEPROM_INIT();
MemoryStatus EEPROM_EARSE();
MemoryStatus FLASH_WriteBlock(uint16_t startAddr, uint8_t number, uint8_t *writeData, uint16_t dataSize);
MemoryStatus FLASH_ReadBlock(uint16_t startAddr, uint8_t number, uint8_t *readData, uint16_t dataSize);
MemoryStatus FLASH_WriteBlock(uint16_t startAddr, uint8_t number,
uint8_t *writeData, uint16_t dataSize);
MemoryStatus FLASH_ReadBlock(uint16_t startAddr, uint8_t number,
uint8_t *readData, uint16_t dataSize);
MemoryStatus saveShot(unsigned char number, Shot *shot);
MemoryStatus getShot(unsigned char number, Shot *shot);
@ -132,7 +139,7 @@ MemoryStatus getProg(unsigned char number, Program *prog);
MemoryStatus saveMacro(unsigned char number, Macro *macro);
MemoryStatus getMacro(unsigned char number, Macro *macro);
MemoryStatus saveInfoBlock(InfoBlock *infoBlock);
MemoryStatus getInfoBlock(InfoBlock *infoBlock);
MemoryStatus saveInfoBlock();
MemoryStatus getInfoBlock();
#endif /* INC_EEPROM_H_ */

View File

@ -51,6 +51,7 @@ typedef struct CurrentInfo {
CurrentMacro macro;
} CurrentInfo;
void Robot_INIT();
void doShot(Shot*);
void doShotForever(uint8_t number);
@ -60,11 +61,13 @@ uint8_t prepareShot(uint8_t number);
void startShooting();
void stopShooting();
int16_t map(int16_t x, int16_t in_min, int16_t in_max, int16_t out_min,
int16_t out_max);
void setPos(uint8_t axial, uint8_t horizontal, uint8_t vertical);
void setPosSingle(ServoMap servo, uint8_t value);
void setPosDefault();
void setPosDefaultSingle(ServoMap servo);
// 0 .. 100
void setScrewkSpeed(uint8_t speed);

View File

@ -26,6 +26,8 @@ void UART3_SetServoOffset(uint8_t *dataPtr, uint8_t len);
void UART3_GetServoOffset(uint8_t *dataPtr, uint8_t len);
void UART3_SetServoMaxAngle(uint8_t *dataPtr, uint8_t len);
void UART3_GetServoMaxAngle(uint8_t *dataPtr, uint8_t len);
void UART3_SetServoMinAngle(uint8_t *dataPtr, uint8_t len);
void UART3_GetServoMinAngle(uint8_t *dataPtr, uint8_t len);
void UART3_MoveServoToInitialPosition(uint8_t *dataPtr, uint8_t len);
void UART3_SetStartupDelay(uint8_t *dataPtr, uint8_t len);
void UART3_GetStartupDelay(uint8_t *dataPtr, uint8_t len);