diff --git a/qtserialport.cpp b/qtserialport.cpp deleted file mode 100644 index eac8f11..0000000 --- a/qtserialport.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "qtserialport.h" - -int QtSerialport::OpenSerialPort(string portName) -{ - QList infos = QSerialPortInfo::availablePorts(); - - //std::cout<<"number of availablePorts:"<isOpen())//如果串口已经打开了 先给他关闭了 - { - m_serial->clear(); - m_serial->close(); - } - - m_serial->setPortName(QString::fromStdString(portName)); - m_serial->open(QIODevice::ReadWrite); - - - bool x=SetBaudrate(9600); - if(x) - { - std::cout<<"波特率被成功设置为:"<baudRate()<close(); - return 0; -} - -int QtSerialport::SetBaudrate(int baudrate) -{ - bool x=m_serial->setBaudRate(baudrate); - return 0; -} - -int QtSerialport::SendData(const char chrMessage[], const unsigned short usLen) -{ - //QIODevice::write(const char *data, qint64 maxSize) - m_serial->write(chrMessage, usLen); - return 0; -} - -int QtSerialport::ReadData() -{ - return 0; -} diff --git a/qtserialport.h b/qtserialport.h deleted file mode 100644 index 49d946f..0000000 --- a/qtserialport.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef QTSERIALPORT_H -#define QTSERIALPORT_H - -#include "serialportbase.h" - -#include -#include - - -class QtSerialport :public SerialPortBase -{ -// Q_OBJECT - -public: -// QtSerialport(); -// ~QtSerialport(); - - - int OpenSerialPort(string portName); - int CloseSerialPort(); - int SetBaudrate(int baudrate); - int SendData(const char chrMessage[], const unsigned short usLen); - int ReadData(); - -protected: -private: - QSerialPort * m_serial; -}; - - -#endif // QTSERIALPORT_H diff --git a/qtserialport_copy.h b/qtserialport_copy.h deleted file mode 100644 index 2be93b3..0000000 --- a/qtserialport_copy.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef QTSERIALPORT_H -#define QTSERIALPORT_H - -#include "serialportbase.h" - -#include -#include - - -class QtSerialport :public SerialPortBase -{ -// Q_OBJECT - -public: - QtSerialport(double * nonlinearityCoeffs, int numberOfCoeffs); - ~QtSerialport(); - - - int OpenSerialPort(string portName); - int CloseSerialPort(); - int SetBaudrate(int baudrate); - int SendData(const char chrMessage[], const unsigned short usLen); - int ReadData(); - -protected: -private: - QSerialPort * m_serial; - - QString m_qPortName; - -}; - - -#endif // QTSERIALPORT_H diff --git a/register.h b/register.h index c1b1d2b..af3803e 100644 --- a/register.h +++ b/register.h @@ -30,6 +30,163 @@ #define IICADDR 0x1a #define LEDOFF 0x1b #define MAGRANGX 0x1c +#define MAGRANGY 0x1d +#define MAGRANGZ 0x1e +#define BANDWIDTH 0x1f +#define GYRORANGE 0x20 +#define ACCRANGE 0x21 +#define SLEEP 0x22 +#define ORIENT 0x23 +#define AXIS6 0x24 +#define FILTK 0x25 +#define GPSBAUD 0x26 +#define READADDR 0x27 +#define BWSCALE 0x28 +#define MOVETHR 0x28 +#define MOVESTA 0x29 +#define ACCFILT 0x2A +#define GYROFILT 0x2b +#define MAGFILT 0x2c +#define POWONSEND 0x2d +#define VERSION 0x2e +#define KEY 0x69 +#define TIMEZONE 0x6B + +/* KEY */ +#define KEY_UNLOCK 0xB588 + +/* SAVE */ +#define SAVE_PARAM 0x00 +#define SAVE_SWRST 0xFF + +/* algorithm */ +enum ALGROITHM_ENUM { + ALGROITHM9 = 0, + ALGROITHM6 = 1 +}; + +/* ORIENT */ +enum ORIENT_ENUM { + ORIENT_HORIZONTAL = 0, + ORIENT_VERTICAL +}; + +/* ORIENT */ +enum POWONSEND_ENUM { + CLOSE = 0, + OPEN +}; + +/* CALSW */ +enum CAL_ENUM { + EXIT = 0, + GYROACC, + MAGNETIC, + ALTITUDE, + ALANGLEZ +}; + +#define EXITCAL 0x00 +#define CALGYROACC 0x01 +#define CALMAG 0x02 +#define CALALTITUDE 0x03 +#define CALANGLEZ 0x04 + +/* time zone */ +enum TIMEZONE_ENUM { + UTC_N12 = 0, + UTC_N11, + UTC_N10, + UTC_N9, + UTC_N8, + UTC_N7, + UTC_N6, + UTC_N5, + UTC_N4, + UTC_N3, + UTC_N2, + UTC_N1, + UTC, + UTC_P1, + UTC_P2, + UTC_P3, + UTC_P4, + UTC_P5, + UTC_P6, + UTC_P7, + UTC_P8,//default + UTC_P9, + UTC_P10, + UTC_P11, + UTC_P12 +}; + +/* RETURN CONTENT */ +#define SetBit(VAR, Place) (VAR |= (1 << Place)) +#define ClrBit(VAR, Place) (VAR &= ((1 << Place) ^ 255)) + +enum RETURN_CONTENT_ENUM { + TIME = 0, + ACCELERATION, + ANGULAR_VELOCITY, + EULER_ANGLE, + MAGNETIC_FIELD, + PORT_STATUS, + ATMOSPHERIC_PRESSURE_ALTITUDE, + LATITUDE_LONGITUDE, + + GROUND_VELOCITY, + QUATERNION,//四元数 + SATELLITE_ACCURACY +}; + +/* BAUD */ +enum BAUD_ENUM { + WIT_BAUD_2400 = 0, + WIT_BAUD_4800, + WIT_BAUD_9600,//default + WIT_BAUD_19200, + WIT_BAUD_38400, + WIT_BAUD_57600, + WIT_BAUD_115200, + WIT_BAUD_230400, + WIT_BAUD_460800, + WIT_BAUD_921600 +}; + +/**RRATE*****/ +enum RRATE_ENUM { + RRATE_01HZ = 1, + RRATE_05HZ, + RRATE_1HZ, + RRATE_2HZ, + RRATE_5HZ, + RRATE_10HZ,//default + RRATE_20HZ, + RRATE_50HZ, + RRATE_100HZ, + RRATE_NONE,//保留 + RRATE_200HZ, + RRATE_ONCE +}; + +/* 端口模式 */ +enum MODEL_D0_D2_D3_ENUM { + AIN = 0,//default + DIN, + DOH, + DOL, + PWM +}; + +enum MODEL_D1_ENUM { + AIN_D1 = 0,//default + DIN_D1, + DOH_D1, + DOL_D1, + PWM_D1, + CLR_D1 +}; #endif // REGISTER_H diff --git a/serialportbase.h b/serialportbase.h index cd3ec67..63237ff 100644 --- a/serialportbase.h +++ b/serialportbase.h @@ -12,10 +12,11 @@ public: // SerialPortBase(); // ~SerialPortBase(); - virtual int OpenSerialPort(string portName) = 0; + virtual int OpenSerialPort(string portName, int baudrate) = 0; virtual int CloseSerialPort() = 0; virtual int SetBaudrate(int baudrate) = 0; - virtual int SendData(const char chrMessage[], const unsigned short usLen) = 0; + virtual int SendData1(const char *data, const unsigned int len) = 0; + virtual int SendData(const char chrSendBuffer[],const unsigned short usLen) = 0; virtual int ReadData() = 0; protected: private: diff --git a/witmotionDll.pro b/witmotionDll.pro index e506e26..6c23056 100644 --- a/witmotionDll.pro +++ b/witmotionDll.pro @@ -7,8 +7,6 @@ TARGET = witmotionDll TEMPLATE = lib -QT += serialport - DEFINES += WITMOTIONDLL_LIBRARY # The following define makes your compiler emit warnings if you use @@ -23,14 +21,12 @@ DEFINES += QT_DEPRECATED_WARNINGS #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ - witmotiondll.cpp \ - qtserialport.cpp + witmotiondll.cpp HEADERS += \ witmotiondll.h \ witmotiondll_global.h \ serialportbase.h \ - qtserialport.h \ register.h unix { diff --git a/witmotiondll.cpp b/witmotiondll.cpp index 8d0bb4c..3964be9 100644 --- a/witmotiondll.cpp +++ b/witmotiondll.cpp @@ -1,42 +1,674 @@ #include "witmotiondll.h" - WitmotionDll::WitmotionDll(SerialPortBase * serialPort) { m_SerialPort = serialPort; } -int WitmotionDll::algorithm(int algorithm) +int WitmotionDll::unlockInstruction() { + using std::this_thread::sleep_for; + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=KEY & 0xFF; + unBuffer[3]=KEY_UNLOCK & 0xff; + unBuffer[4]=KEY_UNLOCK >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + std::cout<<"WitmotionDll::unlockInstruction: "<< num <> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + std::cout<<"WitmotionDll::saveInstruction: "<< num <> 8; + + break; + } + case ALGROITHM9: + { + unBuffer[2]=AXIS6 & 0xFF; + unBuffer[3]=ALGROITHM9 & 0xff; + unBuffer[4]=ALGROITHM9 >> 8; + + break; + } + default: + break; + } + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + + return 0; +} + +int WitmotionDll::installationOrientation(ORIENT_ENUM orient) +{ + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=ORIENT & 0xFF; + unBuffer[3]=orient & 0xff; + unBuffer[4]=orient >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + std::cout<<"WitmotionDll::installationDirection: "<< num <> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + std::cout<<"WitmotionDll::installationDirection: "<< num <> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); return 0; } int WitmotionDll::magneticCalibration() { + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=CALSW & 0xFF; + unBuffer[3]=CALMAG & 0xff; + unBuffer[4]=CALMAG >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + return 0; } -int WitmotionDll::heightCalibration() +int WitmotionDll::setHeightToZero() { + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=CALSW & 0xFF; + unBuffer[3]=CALALTITUDE & 0xff; + unBuffer[4]=CALALTITUDE >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + return 0; } -int WitmotionDll::zAxisAngleCalibration() +int WitmotionDll::setZAxisAngleToZero() { + //需要读取参数,确保处于算法ALGROITHM6下 + + + + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=CALSW & 0xFF; + unBuffer[3]=CALANGLEZ & 0xff; + unBuffer[4]=CALANGLEZ >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + return 0; } int WitmotionDll::setAngleReference() { + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=CALSW & 0xFF; + unBuffer[3]=0x08; + unBuffer[4]=0x00; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + + return 0; +} + +void WitmotionDll::recordData() +{ + m_SerialPort->ReadData(); +} + +int WitmotionDll::setTimeZone(TIMEZONE_ENUM timeZone) +{ + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=TIMEZONE & 0xFF; + unBuffer[3]=timeZone & 0xff; + unBuffer[4]=timeZone >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + std::cout<<"WitmotionDll::installationDirection: "<< num <SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + + exitCalibration(); + return 0; +} + +int WitmotionDll::eulerAngle() +{ + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=RSW & 0xFF; + + //设置回传内容 + uint8_t RSWL = 0; + uint8_t RSWH = 0; + + SetBit(RSWL, EULER_ANGLE); + + unBuffer[3] = RSWL; + unBuffer[4] = RSWH; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + + exitCalibration(); + return 0; +} + +int WitmotionDll::setContent(RETURN_CONTENT_ENUM content) +{ + return 0; +} + +int WitmotionDll::clearContent(RETURN_CONTENT_ENUM content) +{ + return 0; +} + +int WitmotionDll::SetBaudrate(BAUD_ENUM baudrate) +{ + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=BAUD & 0xFF; + unBuffer[3]=baudrate & 0xff; + unBuffer[4]=baudrate >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + + return 0; +} + +int WitmotionDll::SetReturnRate(RRATE_ENUM returnRate) +{ + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=RRATE & 0xFF; + unBuffer[3]=returnRate & 0xff; + unBuffer[4]=returnRate >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + + return 0; +} + +int WitmotionDll::SetDeviceAddress(int deviceAddress) +{ + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=IICADDR & 0xFF; + unBuffer[3]=deviceAddress & 0xff; + unBuffer[4]=deviceAddress >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + + return 0; +} + +int WitmotionDll::setD0Model(MODEL_D0_D2_D3_ENUM model) +{ + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=D0MODE & 0xFF; + unBuffer[3]=model & 0xff; + unBuffer[4]=model >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + + return 0; +} + +int WitmotionDll::setD1Model(MODEL_D1_ENUM model) +{ + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=D1MODE & 0xFF; + unBuffer[3]=model & 0xff; + unBuffer[4]=model >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + + return 0; +} + +int WitmotionDll::setD2Model(MODEL_D0_D2_D3_ENUM model) +{ + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=D2MODE & 0xFF; + unBuffer[3]=model & 0xff; + unBuffer[4]=model >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + + return 0; +} + +int WitmotionDll::setD3Model(MODEL_D0_D2_D3_ENUM model) +{ + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=D3MODE & 0xFF; + unBuffer[3]=model & 0xff; + unBuffer[4]=model >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + + return 0; +} + +int WitmotionDll::setD0HighLevelPulseWidth(int PWMH) +{ + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=D0PWMH & 0xFF; + unBuffer[3]=PWMH & 0xff; + unBuffer[4]=PWMH >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + + return 0; +} + +int WitmotionDll::setD1HighLevelPulseWidth(int PWMH) +{ + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=D1PWMH & 0xFF; + unBuffer[3]=PWMH & 0xff; + unBuffer[4]=PWMH >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + + return 0; +} + +int WitmotionDll::setD2HighLevelPulseWidth(int PWMH) +{ + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=D2PWMH & 0xFF; + unBuffer[3]=PWMH & 0xff; + unBuffer[4]=PWMH >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + + return 0; +} + +int WitmotionDll::setD3HighLevelPulseWidth(int PWMH) +{ + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=D3PWMH & 0xFF; + unBuffer[3]=PWMH & 0xff; + unBuffer[4]=PWMH >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + + return 0; +} + +int WitmotionDll::setD0Period(int period) +{ + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=D0PWMT & 0xFF; + unBuffer[3]=period & 0xff; + unBuffer[4]=period >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + + return 0; +} + +int WitmotionDll::setD1Period(int period) +{ + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=D1PWMT & 0xFF; + unBuffer[3]=period & 0xff; + unBuffer[4]=period >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + + return 0; +} + +int WitmotionDll::setD2Period(int period) +{ + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=D2PWMT & 0xFF; + unBuffer[3]=period & 0xff; + unBuffer[4]=period >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + + return 0; +} + +int WitmotionDll::setD3Period(int period) +{ + using std::this_thread::sleep_for; + + unlockInstruction(); + + uint8_t unBuffer[8]; + unBuffer[0]=0xFF; + unBuffer[1]=0xAA; + unBuffer[2]=D3PWMT & 0xFF; + unBuffer[3]=period & 0xff; + unBuffer[4]=period >> 8; + + int num = m_SerialPort->SendData1((char *)unBuffer,5); + + sleep_for(std::chrono::milliseconds(TIME_TO_SLEEP)); + + saveInstruction(); + return 0; } diff --git a/witmotiondll.h b/witmotiondll.h index fa905a6..eba81c3 100644 --- a/witmotiondll.h +++ b/witmotiondll.h @@ -5,8 +5,10 @@ #include #include +#include #include "serialportbase.h" +#include "register.h" class WITMOTIONDLLSHARED_EXPORT WitmotionDll { @@ -14,18 +16,60 @@ class WITMOTIONDLLSHARED_EXPORT WitmotionDll public: WitmotionDll(SerialPortBase * serialPort); - int algorithm(int algorithm); - int installationDirection(int direction); - int instructStart();//文档中的通讯协议没有相关的设置????????????? + int unlockInstruction(); + int saveInstruction(); + void recordData(); + + //系统 + int algorithm(ALGROITHM_ENUM algorithm); + int installationOrientation(ORIENT_ENUM orient); + int instructStart(POWONSEND_ENUM command);//是否上电输出数据 + + + //校准:完成后,需要退出校准模式( 调用exitCalibration) + int exitCalibration();//退出校准模式 int magneticCalibration(); - int heightCalibration(); - int zAxisAngleCalibration(); - int setAngleReference(); + int setHeightToZero();//需要JY901B带有高度数据输出的模块才能进行高度校准,此为相对高度,短时间内有效 + int setZAxisAngleToZero();//Z轴角度归零,只在切换成 6 轴算法下才能成功置零; + int setAngleReference();//问的技术支持,文档没有,不建议使用,设置后只能在静态下运动,即原点旋转单轴,其他方式旋转出来会有比较大的误差 + + + //范围 + int setTimeZone(TIMEZONE_ENUM timeZone); + + //设置回传内容:操作位?????????????????????? + int latitudeLongitude(); + int eulerAngle(); + int setContent(RETURN_CONTENT_ENUM content); + int clearContent(RETURN_CONTENT_ENUM content); + + //通讯 + 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); + private: SerialPortBase * m_SerialPort; + int TIME_TO_SLEEP = 500;//毫秒 };