添加蓝牙功能
This commit is contained in:
138
src/VSMD_command_handler.h
Normal file
138
src/VSMD_command_handler.h
Normal file
@ -0,0 +1,138 @@
|
||||
#ifndef VSMD_COMMAND_HANDLER_H
|
||||
#define VSMD_COMMAND_HANDLER_H
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include "vsmd_parser.h"
|
||||
|
||||
// 外部变量声明
|
||||
extern bool deviceEnabled;
|
||||
extern int32_t pulsePerSecond;
|
||||
extern uint8_t sendBuffer[];
|
||||
extern int32_t packedLength;
|
||||
extern VSMDParser parser;
|
||||
|
||||
// 串口通信函数
|
||||
void send_vsmd_cmd(const char* cmd, int value = -1);
|
||||
// send_vsmd_cmd("dev"); // 不带参数,使用默认值-1
|
||||
// send_vsmd_cmd("pos", value); // 带参数
|
||||
|
||||
// 打印Serial串口收到的原始数据
|
||||
void printSerialRawData(const uint8_t* buffer, int bytesRead);
|
||||
//VSMD串口数据解析
|
||||
String readAndParseSerialData();
|
||||
|
||||
// JSON响应函数
|
||||
void sendJsonResponse(const char* command, const char* status, int value = -1);
|
||||
// 打包并发送字符串响应
|
||||
void sendStringResponse(const char* response);
|
||||
|
||||
// JSON命令处理函数
|
||||
void processJsonCommand(const char* jsonString);
|
||||
// 处理字符串命令
|
||||
void processStringCommand(const char* stringData);
|
||||
|
||||
//获取参数值
|
||||
void handle_cfg_cmd();
|
||||
//握手,获取型号和版本号
|
||||
void handle_dev_cmd();
|
||||
//获取运行状态(速度、位置、状态)
|
||||
void handle_sts_cmd();
|
||||
//电机使能
|
||||
void handle_ena_cmd();
|
||||
//电机脱机
|
||||
void handle_off_cmd();
|
||||
//以指定速度连续运转
|
||||
void handle_mov_cmd();
|
||||
//移动到指定位置
|
||||
void handle_pos_cmd(int value);
|
||||
//相对移动
|
||||
void handle_rmv_cmd(int value);
|
||||
//移动到预设位置,有value时,预设目标位置
|
||||
void handle_pps_cmd(int value = -1);
|
||||
//指定当前位置位原点
|
||||
void handle_org_cmd();
|
||||
//停止
|
||||
void handle_stp_cmd(int value = 0);
|
||||
//执行归零
|
||||
void handle_zero_start_cmd();
|
||||
//停止归零
|
||||
void handle_zero_stop_cmd();
|
||||
//设置波特率
|
||||
void handle_cfg_bdr_cmd(int baudrate);
|
||||
//设置微步细分
|
||||
void handle_cfg_mcs_cmd(int value);
|
||||
//设置速度
|
||||
void handle_cfg_spd_cmd(int value);
|
||||
//设置加速速度
|
||||
void handle_cfg_accSpeed_cmd(int value);
|
||||
//设置减速度
|
||||
void handle_cfg_decSpeed_cmd(int value);
|
||||
//设置加速时电流
|
||||
void handle_cfg_cra_cmd(float value);
|
||||
//设置匀速时电流
|
||||
void handle_cfg_crn_cmd(float value);
|
||||
//设置HOLD电流
|
||||
void handle_cfg_crh_cmd(float value);
|
||||
|
||||
// ***************************SENSOR事件、工作模式处理**********************/
|
||||
void handle_cfg_sensor_cmd(const char* sensorType, int value);
|
||||
// ***************************SENSOR端口输出控制处理**********************/
|
||||
void handle_port_output_cmd(const char* portType, const char* action);
|
||||
|
||||
// //设置S1下降沿触发事件
|
||||
// void handle_cfg_s1f_cmd(int value);
|
||||
// //设置S1上升沿触发事件
|
||||
// void handle_cfg_s1r_cmd(int value);
|
||||
// //设置S2下降沿触发事件
|
||||
// void handle_cfg_s2f_cmd(int value);
|
||||
// //设置S2上升沿触发事件
|
||||
// void handle_cfg_s2r_cmd(int value);
|
||||
|
||||
//设置归零功能
|
||||
void handle_cfg_zmd_cmd(int value);
|
||||
//设置归零用传感器
|
||||
void handle_cfg_snr_cmd(int value);
|
||||
//设置归零传感器OPEN时电平
|
||||
void handle_cfg_osv_cmd(int value);
|
||||
//设置归零速度
|
||||
void handle_cfg_zsd_cmd(int value);
|
||||
//设置归零后的安全位置
|
||||
void handle_cfg_zsp_cmd(int value);
|
||||
//设置离线运行模式
|
||||
void handle_cfg_dmd_cmd(int value);
|
||||
//设置无握手启动时间
|
||||
void handle_cfg_dar_cmd(int value);
|
||||
//设置负极限传感器
|
||||
void handle_cfg_msr_cmd(int value);
|
||||
//设置负极限触发电平
|
||||
void handle_cfg_msv_cmd(int value);
|
||||
//设置正极限传感器
|
||||
void handle_cfg_psr_cmd(int value);
|
||||
//设置正极限触发电平
|
||||
void handle_cfg_psv_cmd(int value);
|
||||
//设置上电使能
|
||||
void handle_cfg_pae_cmd(int value);
|
||||
|
||||
//***************************编码器相关配置*********************************/
|
||||
|
||||
// 编码器模式
|
||||
void handle_cfg_emod_cmd(int value);
|
||||
// 编码器线数
|
||||
void handle_cfg_elns_cmd(int value);
|
||||
// 电机每圈整步数
|
||||
void handle_cfg_estp_cmd(int value);
|
||||
// 堵转后重试次数
|
||||
void handle_cfg_erty_cmd(int value);
|
||||
// 编码器方向
|
||||
void handle_cfg_edir_cmd(int value);
|
||||
// 编码器灵敏度
|
||||
void handle_cfg_ez_cmd(int value);
|
||||
// 堵转后动作
|
||||
void handle_cfg_ewr_cmd(int value);
|
||||
//*********************************************************************/
|
||||
|
||||
|
||||
//保存参数到FLASH
|
||||
void handle_sav_cmd();
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user