esp32-car/include/handlers.h

46 lines
1.5 KiB
C
Raw Normal View History

2024-12-27 09:47:56 +08:00
#ifndef HANDLERS_H
#define HANDLERS_H
#include "motor.h"
#include "storage.h"
#include "ble.h"
#include "ultrasound.h"
#include "transmit.h"
2024-12-27 10:34:06 +08:00
#include "pid.h"
2024-12-27 11:32:09 +08:00
#include "ir.h"
2024-12-27 09:47:56 +08:00
#include "utils.h"
// 指令定义
#define CMD_GET_BT_STATUS 0x10
#define CMD_GET_SPIFFS_STATUS 0x11
#define CMD_GET_DISTANCE 0x12
2024-12-27 10:16:08 +08:00
#define CMD_SET_NAME 0xA1
2024-12-27 10:34:06 +08:00
#define CMD_SET_PID 0xA2
2024-12-27 09:47:56 +08:00
#define CMD_MOTOR_MOVE_CONTROL 0x20
#define CMD_MOTOR_STEER_CONTROL 0x21
#define CMD_MOTOR_SINGLE_CONTROL 0x22
#define CMD_MOTOR_ROTATE_CONTROL 0x23
#define CMD_DEMO_PID 0xf0
#define CMD_DEMO_PATH 0xf1
#define CMD_MOTOR_XYR_CONTROL 0x24 // XYR轴向控制指令
#define CMD_STATUS_MOTOR 0xE0
class Handlers
{
public:
static void getBTStatus(BLECharacteristic &characteristic);
static void getSPIFFSStatus(BLECharacteristic &characteristic);
static void getDistance(BLECharacteristic &characteristic);
2024-12-27 10:16:08 +08:00
static void setName(BLECharacteristic &characteristic, uint8_t *packet);
2024-12-27 10:34:06 +08:00
static void setPID(BLECharacteristic &characteristic, uint8_t *packet);
2024-12-27 09:47:56 +08:00
static void motorMoveControl(BLECharacteristic &characteristic, uint8_t *packet);
static void motorSteerControl(BLECharacteristic &characteristic, uint8_t *packet);
static void motorRotateControl(BLECharacteristic &characteristic, uint8_t *packet);
static void motorSingleControl(BLECharacteristic &characteristic, uint8_t *packet);
static void motorXYRControl(BLECharacteristic &characteristic, uint8_t *packet);
static void demoPID(BLECharacteristic &characteristic, uint8_t *packet);
};
#endif