IR_CMD_Handler

This commit is contained in:
2024-08-25 20:27:17 +03:00
parent 55e8424f78
commit 148d748c20
17 changed files with 853 additions and 469 deletions

View File

@ -13,19 +13,19 @@
#define MAX_NUMBER_SHOTS_IN_PROGRAMS 31
#define MAX_NUMBER_PROGRAMS_IN_MACRO 16
struct StructNumberScrewCount{
unsigned char number;
typedef struct MacroProgram{
unsigned char id;
unsigned char speedScrew;
unsigned char countRepeat;
unsigned char options;
};
}MacroProgram;
struct StructNumberScrew{
unsigned char number;
typedef struct ProgramShot{
unsigned char id;
unsigned char speedScrew;
};
}ProgramShot;
struct StructShot {
typedef struct Shot {
unsigned char countRepeatShot;
unsigned char speedRollerTop;
unsigned char speedRollerBottom;
@ -33,20 +33,20 @@ struct StructShot {
unsigned char rotationAxial;
unsigned char rotationHorizontal;
unsigned char rotationVertical;
};
}Shot;
struct StructProgram {
typedef struct Program {
unsigned char countRepeat;
unsigned char options;
struct StructNumberScrew numberScrew[MAX_NUMBER_SHOTS_IN_PROGRAMS];
};
ProgramShot shots[MAX_NUMBER_SHOTS_IN_PROGRAMS];
}Program;
struct StructMacro {
struct StructNumberScrewCount numberScrewCount[MAX_NUMBER_PROGRAMS_IN_MACRO];
};
typedef struct Macro {
MacroProgram programs[MAX_NUMBER_PROGRAMS_IN_MACRO];
} Macro;
void SaveShot(unsigned char number, struct StructShot* shot);
void SaveShot(unsigned char number, struct Shot* shot);
void FLASH_WriteBlock(uint8_t *writeAddr, unsigned char *flashWrBufPtr);
struct StructShot GetShot( unsigned char number );
Shot GetShot( unsigned char number );

13
Core/Inc/GlobalDefines.h Normal file
View File

@ -0,0 +1,13 @@
/*
* GlobalDefines.h
*
* Created on: Aug 25, 2024
* Author: DashyFox
*/
#ifndef INC_GLOBALDEFINES_H_
#define INC_GLOBALDEFINES_H_
#define UART_BUFFER_SIZE 64
#endif /* INC_GLOBALDEFINES_H_ */

View File

@ -8,45 +8,16 @@
extern unsigned char IR_Command;
extern unsigned char IR_Address;
extern unsigned char IR_CommandNumber[3];
extern unsigned char IRStatus;
void IR_handler(void);
void ClearIRStatus(void);
void ClearIRCommand(void);
void ClearIR(void);
void SetShiftReg_inline (unsigned char b1, unsigned char b2, unsigned char b3);
void SetShiftReg (unsigned char shiftreg[3]);
//extern unsigned char IR_CommandNumber[3];
enum IR_CMD_LIST {
IR_FRONT_LEFT = 20,
IR_FRONT_MID = 58,
IR_FONT_RIGHT = 21,
IR_MACRO = 63,
IR_PROG = 37,
IR_SHOT = 56,
IR_NUM_1 = 0,
IR_NUM_2 = 1,
IR_NUM_3 = 2,
IR_NUM_4 = 3,
IR_NUM_5 = 4,
IR_NUM_6 = 5,
IR_NUM_7 = 6,
IR_NUM_8 = 7,
IR_NUM_9 = 8,
IR_NUM_0 = 9,
IR_DEBUG = 29, // -/--
IR_PAUSE = 43,
IR_STOP = 116,
IR_START = 124,
IR_F_BTN = 23,
IR_ESC = 117,
IR_ENTER = 97,
IR_TEMPO_INC = 60,
IR_TEMPO_DEC = 54,
IR_ENGINE_UP_INC = 18, // скорость верхнего мотора
IR_ENGINE_UP_DEC = 19,
IR_ENGINE_DOWM_INC = 16,
IR_ENGINE_DOWM_DEC = 17
};
typedef struct IRData{
unsigned char address;
unsigned char command;
} IRData;
void IR_handler(void);
IRData getIRData(void);
unsigned char IR_Available();
void ClearIRStatus(void);

47
Core/Inc/IR_CMD_Handler.h Normal file
View File

@ -0,0 +1,47 @@
/*
* IR_CMD_Handler.h
*
* Created on: Aug 25, 2024
* Author: DashyFox
*/
#ifndef INC_IR_CMD_HANDLER_H_
#define INC_IR_CMD_HANDLER_H_
#include "stm32f1xx_hal.h"
void IR_CMD_Handler();
enum IR_CMD_LIST {
IR_FRONT_LEFT = 20,
IR_FRONT_MID = 58,
IR_FONT_RIGHT = 21,
IR_MACRO = 63,
IR_PROG = 37,
IR_SHOT = 56,
IR_NUM_1 = 0,
IR_NUM_2 = 1,
IR_NUM_3 = 2,
IR_NUM_4 = 3,
IR_NUM_5 = 4,
IR_NUM_6 = 5,
IR_NUM_7 = 6,
IR_NUM_8 = 7,
IR_NUM_9 = 8,
IR_NUM_0 = 9,
IR_DEBUG = 29, // -/--
IR_PAUSE = 43,
IR_STOP = 116,
IR_START = 124,
IR_F_BTN = 23,
IR_ESC = 117,
IR_ENTER = 97,
IR_TEMPO_INC = 60,
IR_TEMPO_DEC = 54,
IR_ENGINE_UP_INC = 18, // скорость верхнего мотора
IR_ENGINE_UP_DEC = 19,
IR_ENGINE_DOWM_INC = 16,
IR_ENGINE_DOWM_DEC = 17
};
#endif /* INC_IR_CMD_HANDLER_H_ */

39
Core/Inc/RobotFunctions.h Normal file
View File

@ -0,0 +1,39 @@
/*
* RobotFunctions.h
*
* Created on: Aug 24, 2024
* Author: DashyFox
*/
#ifndef INC_ROBOTFUNCTIONS_H_
#define INC_ROBOTFUNCTIONS_H_
#include "pca9685.h"
void doShot();
void doShotForever();
void prepareShot();
void stopShooting();
void setPos();
void setPosDefault();
// 0 .. 100
void setShneckSpeed(uint8_t speed);
//(-v) 0 .. 100(stop) .. 200(+v)
void setRollersSpeed(uint8_t speed); //(-v) 0 . 100(stop) . 200(+v)
void startProgram(); // shot sequence
void startMacro(); // shot sequence
#endif /* INC_ROBOTFUNCTIONS_H_ */

17
Core/Inc/ShiftReg.h Normal file
View File

@ -0,0 +1,17 @@
/*
* ShiftReg.h
*
* Created on: Aug 25, 2024
* Author: DashyFox
*/
#ifndef SRC_SHIFTREG_H_
#define SRC_SHIFTREG_H_
#include "stm32f1xx_hal.h"
void SetShiftReg_inline (unsigned char b1, unsigned char b2, unsigned char b3);
void SetShiftReg (unsigned char shiftreg[3]);
#endif /* SRC_SHIFTREG_H_ */

23
Core/Inc/SimpleTimer.h Normal file
View File

@ -0,0 +1,23 @@
/*
* SimpleTimer.h
*
* Created on: Aug 24, 2024
* Author: DashyFox
*/
#ifndef INC_SIMPLETIMER_H_
#define INC_SIMPLETIMER_H_
#include "stm32f1xx_hal.h"
#define forTimer(name, time) \
static uint32_t name##_previousMillis = 0; \
if (millis() - name##_previousMillis >= time)
#define resetForTimer(name) \
name##_previousMillis = millis();
uint32_t millis();
#endif /* INC_SIMPLETIMER_H_ */

View File

@ -61,6 +61,7 @@ void USB_LP_CAN1_RX0_IRQHandler(void);
void TIM3_IRQHandler(void);
void I2C1_EV_IRQHandler(void);
void I2C1_ER_IRQHandler(void);
void USART3_IRQHandler(void);
/* USER CODE BEGIN EFP */
/* USER CODE END EFP */