2022-05-29 23:24:27 +08:00
|
|
|
|
#ifndef WITMOTIONDLL_H
|
|
|
|
|
#define WITMOTIONDLL_H
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
2022-06-05 21:03:12 +08:00
|
|
|
|
#include <string>
|
2022-05-31 22:44:39 +08:00
|
|
|
|
#include <thread>
|
2022-05-29 23:24:27 +08:00
|
|
|
|
|
|
|
|
|
#include "serialportbase.h"
|
2022-05-31 22:44:39 +08:00
|
|
|
|
#include "register.h"
|
2022-07-15 22:09:06 +08:00
|
|
|
|
#include "witcommand.h"
|
2022-05-29 23:24:27 +08:00
|
|
|
|
|
2022-06-05 21:03:12 +08:00
|
|
|
|
typedef void (*delay)(uint32_t millisecond);
|
|
|
|
|
typedef void (*witPrintf)(const char* text);
|
|
|
|
|
|
2022-06-20 15:30:16 +08:00
|
|
|
|
class WitmotionDll
|
2022-05-29 23:24:27 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
WitmotionDll(SerialPortBase * serialPort);
|
|
|
|
|
|
2022-06-05 21:03:12 +08:00
|
|
|
|
int delayMsRegister(delay delayFunction);
|
|
|
|
|
int printfRegister(witPrintf printfFunction);
|
|
|
|
|
void setDelayTimeMs(uint32_t millisecond);
|
|
|
|
|
|
|
|
|
|
int constructAndSendInstruction(int registerAddress, int registerContent);
|
|
|
|
|
|
2022-05-31 22:44:39 +08:00
|
|
|
|
int unlockInstruction();
|
|
|
|
|
int saveInstruction();
|
2022-05-29 23:24:27 +08:00
|
|
|
|
|
2022-05-31 22:44:39 +08:00
|
|
|
|
void recordData();
|
|
|
|
|
|
|
|
|
|
//系统
|
|
|
|
|
int algorithm(ALGROITHM_ENUM algorithm);
|
|
|
|
|
int installationOrientation(ORIENT_ENUM orient);
|
2022-06-05 21:03:12 +08:00
|
|
|
|
int instructStart(POWONSEND_ENUM command);//是否上电输出数据,可以防止鼠标乱跳
|
2022-05-31 22:44:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//校准:完成后,需要退出校准模式( 调用exitCalibration)
|
|
|
|
|
int exitCalibration();//退出校准模式
|
2022-05-29 23:24:27 +08:00
|
|
|
|
|
|
|
|
|
int magneticCalibration();
|
2022-05-31 22:44:39 +08:00
|
|
|
|
int setHeightToZero();//需要JY901B带有高度数据输出的模块才能进行高度校准,此为相对高度,短时间内有效
|
|
|
|
|
int setZAxisAngleToZero();//Z轴角度归零,只在切换成 6 轴算法下才能成功置零;
|
2022-06-05 21:03:12 +08:00
|
|
|
|
int setAngleReference();//询问技术支持,文档没有,不建议使用,设置后只能在静态下运动,即原点旋转单轴,其他方式旋转出来会有比较大的误差
|
2022-05-31 22:44:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//范围
|
|
|
|
|
int setTimeZone(TIMEZONE_ENUM timeZone);
|
|
|
|
|
|
2022-06-05 21:03:12 +08:00
|
|
|
|
//设置回传内容
|
|
|
|
|
int setContent(RETURN_CONTENT_STRUCT content);
|
|
|
|
|
int clearContent(RETURN_CONTENT_STRUCT content);
|
2022-05-31 22:44:39 +08:00
|
|
|
|
|
|
|
|
|
//通讯
|
|
|
|
|
int SetBaudrate(BAUD_ENUM baudrate);
|
|
|
|
|
int SetReturnRate(RRATE_ENUM returnRate);
|
|
|
|
|
int SetDeviceAddress(int deviceAddress);//(1)只用于IIC协议,串口不用(2)设置、保存后,重新上电生效(3)最大为0x7f(124)
|
|
|
|
|
|
|
|
|
|
//接口
|
|
|
|
|
int setD0Model(MODEL_D0_D2_D3_ENUM model);
|
|
|
|
|
int setD1Model(MODEL_D1_ENUM model);
|
|
|
|
|
int setD2Model(MODEL_D0_D2_D3_ENUM model);
|
|
|
|
|
int setD3Model(MODEL_D0_D2_D3_ENUM model);
|
|
|
|
|
|
|
|
|
|
int setD0HighLevelPulseWidth(int PWMH);
|
|
|
|
|
int setD1HighLevelPulseWidth(int PWMH);
|
|
|
|
|
int setD2HighLevelPulseWidth(int PWMH);
|
|
|
|
|
int setD3HighLevelPulseWidth(int PWMH);
|
|
|
|
|
|
|
|
|
|
int setD0Period(int period);
|
|
|
|
|
int setD1Period(int period);
|
|
|
|
|
int setD2Period(int period);
|
|
|
|
|
int setD3Period(int period);
|
|
|
|
|
|
2022-05-29 23:24:27 +08:00
|
|
|
|
private:
|
|
|
|
|
SerialPortBase * m_SerialPort;
|
2022-06-05 21:03:12 +08:00
|
|
|
|
uint32_t TIME_TO_SLEEP = 500;//毫秒
|
|
|
|
|
|
|
|
|
|
delay m_delayFunction;
|
|
|
|
|
witPrintf m_witPrintf;
|
|
|
|
|
|
2022-05-29 23:24:27 +08:00
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // WITMOTIONDLL_H
|