diff --git a/PlatformIO_ESP32_oscilloscope/lib/myBlueTooth/myBlueTooth.cpp b/PlatformIO_ESP32_oscilloscope/lib/myBlueTooth/myBlueTooth.cpp index e8e94ba972fbdba0972a15a6fd7515588c420fbd..9ee84d140201fa6f9508f8292ce71a9511693991 100644 --- a/PlatformIO_ESP32_oscilloscope/lib/myBlueTooth/myBlueTooth.cpp +++ b/PlatformIO_ESP32_oscilloscope/lib/myBlueTooth/myBlueTooth.cpp @@ -771,7 +771,7 @@ void RemoteControlOnDataReceive(const uint8_t *buffer, size_t size) // 使用结构体的成员方法 RemoteControlInterruptMode22(&outputBuffer); // 使用 switch case 模式 - // RemoteControlInterruptMode33(cmd, data, outputBuffer.LEFT_x, outputBuffer.LEFT_y, outputBuffer.RIGHT_x, outputBuffer.RIGHT_y); + RemoteControlInterruptMode33(cmd, data, outputBuffer.LEFT_x, outputBuffer.LEFT_y, outputBuffer.RIGHT_x, outputBuffer.RIGHT_y); } // 获取摇杆数值 @@ -996,6 +996,17 @@ struct myStruct char e; }; +void struct_number_size() +{ + student stu = {}; // 修正拼写错误 + int mySize = sizeof(stu); // 使用已声明的变量 stu + int numberSize = sizeof(stu.begin); // 使用已声明的变量 stu + int size = mySize / numberSize; // 计算剩余字节数 + Serial.printf("%d / %d = %d\r\n", mySize, numberSize, size); +} + + + /* 如何把结构体像数组一样使用?可以做到,前提条件时是结构体成员是单一类型时,结构体内部就像一个数组, 获取结构体的首地址,在基础上进行偏移,可以像数组一样访问了 diff --git a/PlatformIO_ESP32_oscilloscope/lib/myXHZS/myXHZS.cpp b/PlatformIO_ESP32_oscilloscope/lib/myXHZS/myXHZS.cpp index 70404265fe5a35713b6dcf233ea8dd7d0359a28b..e0ff85130e319ea83980ac5a364abb817fc8b084 100644 --- a/PlatformIO_ESP32_oscilloscope/lib/myXHZS/myXHZS.cpp +++ b/PlatformIO_ESP32_oscilloscope/lib/myXHZS/myXHZS.cpp @@ -3,7 +3,7 @@ WiFiController espWifi; BluetoothController espBT; -enum WIRELESS_DEVICE wireless_device = BLUETOOTH_DEVICE; +enum enumWirelessDevice wireless_device = BLUETOOTH_DEVICE; void XHZS_begin(const char *device_name, const char *device_password) { @@ -24,6 +24,27 @@ void XHZS_begin(const char *device_name, const char *device_password) } } +// 接收数据缓冲区 +char *uart_receiveBuffer() +{ + switch (wireless_device) + { + case BLUETOOTH_DEVICE: + return espBT.receiveBuffer; + break; + + case WIFI_DEVICE: + return espWifi.receiveBuffer; + break; + + case EMPTY: + default: + Serial.printf("receiveBuffer error, no wireless device.\r\n"); + return nullptr; + break; + } +} + void uart_printf(const char *format, ...) { char printfBuffer[100]; @@ -35,42 +56,48 @@ void uart_printf(const char *format, ...) Uart_SendArray((uint8_t *)printfBuffer, strlen(printfBuffer)); } -// 接收数据缓冲区 -char *uart_receiveBuffer() +// 发送一个字节 +void Uart_SendByte(uint8_t *dataByte) +{ + Uart_SendArray(dataByte, 1); +} + +// 发送数组 +void Uart_SendArray(uint8_t *dataArray, size_t dataSize) { switch (wireless_device) { + case BLUETOOTH_DEVICE: - return espBT.receiveBuffer; + espBT.sendArray(dataArray, dataSize); break; case WIFI_DEVICE: - return espWifi.receiveBuffer; + espWifi.sendArray(dataArray, dataSize); break; case EMPTY: default: - Serial.printf("receiveBuffer error, no wireless device.\r\n"); - return nullptr; + Serial.printf("No wireless device, please connect to WiFi or Bluetooth.\r\n"); break; } } /** * @brief 蓝牙串口接收数据回调函数 - * - * 需要提前准备好,一个函数用于回调函数和处理接收到的数据 + * + * 需要提前准备好一个函数,用于回调函数的接收和逻辑处理 */ void uart_EnableSerialCallback() { switch (wireless_device) { case BLUETOOTH_DEVICE: - espBT.setDataReceivedCallback(bluetooth_SerialReceiveCallback); + espBT.setDataReceivedCallback(uart_bluetoothDataReceivedCallback); break; case WIFI_DEVICE: - espWifi.setDataReceivedCallback(wifi_SerialReceiveCallback); + espWifi.setDataReceivedCallback(uart_wifiDataReceivedCallback); break; case EMPTY: @@ -80,45 +107,18 @@ void uart_EnableSerialCallback() } } -void bluetooth_SerialReceiveCallback(const uint8_t *buffer, size_t size) +void uart_bluetoothDataReceivedCallback(const uint8_t *buffer, size_t size) { espBT.write(buffer, size); Serial.write(buffer, size); } -void wifi_SerialReceiveCallback(void *arg, AsyncClient *client, void *data, size_t len) +void uart_wifiDataReceivedCallback(void *arg, AsyncClient *client, void *data, size_t len) { client->write((char *)data, len); Serial.write((char *)data, len); } -// 发送一个字节 -void Uart_SendByte(uint8_t *dataByte) -{ - Uart_SendArray(dataByte, 1); -} - -// 发送数组 -void Uart_SendArray(uint8_t *dataArray, size_t dataSize) -{ - switch (wireless_device) - { - - case BLUETOOTH_DEVICE: - espBT.sendArray(dataArray, dataSize); - break; - - case WIFI_DEVICE: - espWifi.sendArray(dataArray, dataSize); - break; - - case EMPTY: - default: - Serial.printf("No wireless device, please connect to WiFi or Bluetooth.\r\n"); - break; - } -} - /************************************************************** *函数名称:XHZS_SendWave *简 介:学会助手APP虚拟示波器下位机程序(兼容山外) @@ -241,7 +241,7 @@ char OscGetValue(const char *p, const char *name, float *value) * @brief 示波器的发送数据和接收数据 * */ -void OscilloscopeSendsAndReceivesData() +void Oscilloscope_SendsAndReceivesData() { float value1, value2, value3, value4; char *USART_RX_BUF = uart_receiveBuffer(); @@ -259,207 +259,232 @@ void OscilloscopeSendsAndReceivesData() } } -#if false -void wifi_onData(void *arg, AsyncClient *client, void *data, size_t len) +void RemoteControl_EnableCallbackReceive() { - client->write((char *)data, len); - Serial.write((char *)data, len); -} + switch (wireless_device) + { + case BLUETOOTH_DEVICE: + espBT.setDataReceivedCallback(RemoteControl_BluetoothCallbackReceive); + break; -void blueTooth_onData(const uint8_t *buffer, size_t size) -{ - espBT.send(buffer, size); - Serial.write(buffer, size); + case WIFI_DEVICE: + espWifi.setDataReceivedCallback(RemoteControl_WifiCallbackReceive); + break; + + case EMPTY: + default: + Serial.printf("begin error, no wireless device.\r\n"); + break; + } } -void XHZS_begin(const char *wifi_name, const char *wifi_password) +void RemoteControl_BluetoothCallbackReceive(const uint8_t *buffer, size_t size) { - espWifi.begin(wifi_name, wifi_password); - - // espBT.begin(wifi_name); + RemoteControl_CallbackReceiveAnalysis(buffer, size); } -void uart_EnableSerialFunction(bool isEnable) +void RemoteControl_WifiCallbackReceive(void *arg, AsyncClient *client, void *data, size_t len) { - // espWifi.onDataCallback(wifi_onData); - - // espBT.onDataCallback(blueTooth_onData); + RemoteControl_CallbackReceiveAnalysis((uint8_t *)data, len); } -void status_update() +void RemoteControl_CallbackReceiveAnalysis(const uint8_t *buffer, size_t size) { -} -#endif + structRemoteControlDataFormat buttonBuffer = {}; // 输出的缓冲区 + buttonBuffer.end = sizeof(buttonBuffer) / sizeof(buttonBuffer.start); + short *ptr = &buttonBuffer.start; -#if false + uint8_t cmd[4] = {}; // 指令 + uint8_t data[4] = {}; // 数据 -#include "stm32f10x.h" -#include "sys.h" -#include "led.h" -#include "delay.h" -#include "usart.h" -#include "math.h" -#include "string.h" + char orderBuffer[4] = {}; + memcpy(orderBuffer, buffer, size); -// 发送一个字节 -void Uart_SendByte(USART_TypeDef *UARTx, u8 byte) -{ - USART_SendData(UARTx, byte); - while ((UARTx->SR & 0X40) == 0) - ; // 等待发送结束 -} -// 发送数组 -void Uart_SendArray(USART_TypeDef *UARTx, uint8_t *array, uint32_t num) -{ - while (num--) + // 判断是否摇杆数据,在进行解释 + switch (size) { - Uart_SendByte(UARTx, *array); - array++; + case 4: + if ((orderBuffer[0] & 0xF0) == 0x10) + { + cmd[0] = 0x9A; + RemoteControl_getJoystickValueXY(orderBuffer, buttonBuffer.LEFT_x_axis, buttonBuffer.LEFT_y_axis); + } + else if ((orderBuffer[0] & 0xF0) == 0x50) + { + cmd[0] = 0x9C; + RemoteControl_getJoystickValueXY(orderBuffer, buttonBuffer.RIGHT_x_axis, buttonBuffer.RIGHT_y_axis); + } + break; + + case 1: + + cmd[0] = (orderBuffer[0] & 0xF0) / 16; + data[0] = (orderBuffer[0] & 0x0F); + + // 把结构体当成数组 + ptr[cmd[0]] = data[0]; + break; } +#if true + RemoteControl_StructureArrayProcessingData(buttonBuffer); +#else + cmd[0] = cmd[0] * 16; + RemoteControl_SwitchCaseProcessingData(&buttonBuffer, cmd[0], data[0]); +#endif } -/************************************************************** - *函数名称:XHZS_SendWave - *简 介:学会助手APP虚拟示波器下位机程序(兼容山外) - *输 入:wareaddr:数据数组起始地址 waresize:数组大小 - *输 出:无 - *注意事项:无 - **************************************************************/ -void XHZS_SendWave(uint8_t *waveaddr, uint16_t wavesize) +void RemoteControl_getJoystickValueXY(char (&inputButtonData)[4], short &output_x_axis, short &output_y_axis) { - uint8_t cmdf[2] = {0x03, 0xFC}; // 帧头 - uint8_t cmdr[2] = {0xFC, 0x03}; // 帧尾 + // 摇杆接收格式: 1A 23 31 46 + uint8_t data[4] = {0}; + short x, y; - Uart_SendArray(USART1, cmdf, sizeof(cmdf)); // 发送帧头 - Uart_SendArray(USART1, waveaddr, wavesize); // 发送数据 - Uart_SendArray(USART1, cmdr, sizeof(cmdr)); // 发送帧尾 -} -/************************************************************** - *函数名称:SendWave - *简 介:发送数据到学会助手APP虚拟示波器 - *输 入:无 - *输 出:无 - *注意事项:将要发送的数据赋值给Wave数组即可,通道依次对应 - **************************************************************/ -void SendWave() -{ - float i; - float Wave[4] = {0}; // 注意数据类型;数组大小即为通道数量,最多四条通道 + data[0] = inputButtonData[0] & 0x0F; + data[1] = inputButtonData[1] & 0x0F; - // 正弦波测试 - for (i = 0; i < 500; i += 0.1) - { - Wave[0] = sin(i); - Wave[1] = cos(i); - Wave[2] = -sin(i); - Wave[3] = -cos(i); - XHZS_SendWave((uint8_t *)Wave, sizeof(Wave)); + data[2] = inputButtonData[2] & 0x0F; + data[3] = inputButtonData[3] & 0x0F; - delay_ms(20); - } + // 对默认数值修改,中心数值为0, left 100~0~100 right + x = (data[0] * 16 + data[1]) - 100; + output_x_axis = ((x > 0) ? x : -x); + + y = (data[2] * 16 + data[3]) - 100; + output_y_axis = ((y > 0) ? y : -y); } -/************************************************************** - *函数名称:OscGetFloat - *简 介:将字符转为浮点数 - *输 入:p:字符串;value:用于获取输出值 - *输 出:(==0)转成功;(!=0)转失败 - *注意事项:虚拟示波器调参用,以','为数据分隔符 - **************************************************************/ -char OscGetFloat(const char *p, float *value) +void RemoteControl_StructureArrayProcessingData(structRemoteControlDataFormat &remoteControlData) { - int i; - int negative_flag = 1; - int float_flag = 0; - float tmp_value = 0; - for (i = 0; i < 16; i++) + short *ptr = &remoteControlData.start; // 获取结构体首地址 + for (size_t i = 0; i <= remoteControlData.end; i++) { - if (*p == ',') // 检测到分隔符,返回值 - { - tmp_value *= negative_flag; - *value = tmp_value; - return 0; - } - else if (*p == '-') // 检测到负号 - { - negative_flag = -1; - } - else if (*p == '.') // 检测到小数点 - { - float_flag = -1; - } - else if (*p >= '0' && *p <= '9') - { - if (float_flag == 0) - { - tmp_value = tmp_value * 10 + (*p - 0x30); - } - else - { - tmp_value += (*p - 0x30) * pow(10, float_flag); - float_flag--; - } - } - else - { - return 1; - } - p++; + Serial.printf("%d-%d ", i, ptr[i]); } - return 2; + Serial.println(); } -/************************************************************** - *函数名称:OscGetValue - *简 介:从字符串中获取指定参数数值 - *输 入:p:字符串,以'\0'结尾,否则将出错 - * name:指定参数名称,如"c12"获取第1组第2个参数; - * value:用于获取输出值; - *输 出:(==0)转成功;(!=0)转失败 - *注意事项:虚拟示波器调参用,字符串中以'\0'为结束符 - **************************************************************/ -char OscGetValue(const char *p, const char *name, float *value) + +void RemoteControl_SwitchCaseProcessingData(structRemoteControlDataFormat &remoteControlData, uint8_t &cmd, uint8_t &value) { - float tmp_value; - int feedback; - p = strstr(p, name); - if (p == NULL) - { - return 1; - } - p += 4; - feedback = OscGetFloat(p, &tmp_value); - if (feedback == 0) + switch (cmd) { - *value = tmp_value; - return 0; + case LEFT_UP: + uart_printf("LEFT_UP: %d\r\n", value); + break; + case LEFT_DOWN: + uart_printf("LEFT_DOWN: %d\r\n", value); + break; + case LEFT_LEFT: + uart_printf("LEFT_LEFT: %d\r\n", value); + break; + case LEFT_RIGHT: + uart_printf("LEFT_RIGHT: %d\r\n", value); + break; + + case RIGHT_UP: + uart_printf("RIGHT_UP: %d\r\n", value); + break; + case RIGHT_DOWN: + uart_printf("RIGHT_DOWN: %d\r\n", value); + break; + case RIGHT_LEFT: + uart_printf("RIGHT_LEFT: %d\r\n", value); + break; + case RIGHT_RIGHT: + uart_printf("RIGHT_RIGHT: %d\r\n", value); + break; + + case LEFT_X_AXIS: + uart_printf("x: %d y: %d\r\n", remoteControlData.LEFT_x_axis, remoteControlData.LEFT_y_axis); + break; + + case RIGHT_X_AXIS: + uart_printf("x: %d y: %d\r\n", remoteControlData.RIGHT_x_axis, remoteControlData.RIGHT_y_axis); + break; + + case A_BUTTON: + uart_printf("A_BUTTON: %d\r\n", value); + break; + case B_BUTTON: + uart_printf("B_BUTTON: %d\r\n", value); + break; + case C_BUTTON: + uart_printf("C_BUTTON: %d\r\n", value); + break; + case D_BUTTON: + uart_printf("D_BUTTON: %d\r\n", value); + break; + case E_BUTTON: + uart_printf("E_BUTTON: %d\r\n", value); + break; + case F_BUTTON: + uart_printf("F_BUTTON: %d\r\n", value); + break; } - return 2; } -int main(void) -{ - float v1 = 0, v2 = 0, v3 = 0, v4 = 0; - NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); - LED_Init(); - delay_init(); - uart_init(115200); +#if false - while (1) +void RemoteControl_TimedReceive() +{ + structRemoteControlDataFormat buttonBuffer = {}; // 输出的缓冲区 + buttonBuffer.start = 0; + buttonBuffer.end = 20; + char tempBuffer[20] = {0}; // 临时缓冲区 + + // 判断手柄的方向按钮和摇杆的组合 + char handle = (RemoteControlLayoutLeft == JOYSTICK_SIZE ? JOYSTICK_AND_DIRECTIONAL_PAD : DIRECTIONAL_PAD) + + (RemoteControlLayoutRight == JOYSTICK_SIZE ? DIRECTIONAL_PAD_AND_JOYSTICK : DIRECTIONAL_PAD); + + size_t data_len = strlen(Uart_getReceiveData()); // 获取长度用于复制 + memcpy(tempBuffer, Uart_getReceiveData(), data_len); // 内存复制 + + //// 尝试使用 cmd 串口改变,手柄的组合,失败 + // if (tempBuffer[0] == 's' && tempBuffer[1] == 'e' && tempBuffer[2] == 't') + // { + // char *end; + // char tempBufferCopy[data_len]; + + // substring(tempBufferCopy, tempBuffer, 4, 4); // 截取字符串 + // tempBufferCopy[0] = (char)strtol(tempBufferCopy, &end, 16); // 字符串转换十六进制 + // // _serialBT.printf("%s-%d\n", "pad", tempBufferCopy[0]); + + // if (tempBufferCopy[0] == 0x00 || tempBufferCopy[0] == 0x01 || tempBufferCopy[0] == 0x10 || tempBufferCopy[0] == 0x11) + // { + // // handle = *tempBufferCopy; + // handle = tempBufferCopy[0]; + // tempBufferCopy[0] = 100; + // _serialBT.printf("%s-%d\n", "ok", tempBufferCopy[0]); + // } + // } + + // 确定,方向按钮和摇杆组合方式 + switch (handle) { - if (USART_RX_STA == 2) - { - USART_RX_BUF[USART_RX_NUM] = '\0'; - OscGetValue((const char *)USART_RX_BUF, "c11", &v1); - OscGetValue((const char *)USART_RX_BUF, "c12", &v2); - OscGetValue((const char *)USART_RX_BUF, "c13", &v3); - OscGetValue((const char *)USART_RX_BUF, "c14", &v4); - - printf("w:%.2f,%.2f,%.2f,%.2f\r\n", v1, v2, v3, v4); - USART_RX_NUM = 0; - USART_RX_STA = 0; - } - delay_ms(50); + case DIRECTIONAL_PAD: + // 获取结构体的首地址,在基础上移动到指定位置,进行赋值或者读取操作 + getDirectionalPad(&outputBuffer.begin, 1, tempBuffer, 0); + getDirectionalPad(&outputBuffer.begin, 5, tempBuffer, 4); + getFunctionButtonValue(&outputBuffer.begin, 10, tempBuffer, 8); + break; + + case DIRECTIONAL_PAD_AND_JOYSTICK: + getDirectionalPad(&outputBuffer.begin, 1, tempBuffer, 0); + getJoystickValue(&outputBuffer.begin, 18, tempBuffer, 4); + getFunctionButtonValue(&outputBuffer.begin, 10, tempBuffer, 10); + break; + + case JOYSTICK_AND_DIRECTIONAL_PAD: + getJoystickValue(&outputBuffer.begin, 16, tempBuffer, 0); + getDirectionalPad(&outputBuffer.begin, 5, tempBuffer, 6); + getFunctionButtonValue(&outputBuffer.begin, 10, tempBuffer, 10); + break; + + case JOYSTICKS: + getJoystickValue(&outputBuffer.begin, 16, tempBuffer, 0); + getJoystickValue(&outputBuffer.begin, 18, tempBuffer, 6); + getFunctionButtonValue(&outputBuffer.begin, 10, tempBuffer, 12); + break; } + return outputBuffer; } - #endif \ No newline at end of file diff --git a/PlatformIO_ESP32_oscilloscope/lib/myXHZS/myXHZS.h b/PlatformIO_ESP32_oscilloscope/lib/myXHZS/myXHZS.h index b79d5b0b2c97a853e8c5ac6c565f5fc66bb90fc6..ef7e722e4e5199bc3932032c5d7769b127585200 100644 --- a/PlatformIO_ESP32_oscilloscope/lib/myXHZS/myXHZS.h +++ b/PlatformIO_ESP32_oscilloscope/lib/myXHZS/myXHZS.h @@ -4,37 +4,112 @@ #include "myBlueTooth.h" #include "myWiFi.h" -enum WIRELESS_DEVICE +// 无线设备类型 +enum enumWirelessDevice { EMPTY, BLUETOOTH_DEVICE, WIFI_DEVICE }; +// 遥控器数据格式 +struct structRemoteControlDataFormat +{ + short start; // 起始标志 + + short LEFT_up; // 向上 // 1 + short LEFT_down; // 向下 + short LEFT_left; // 向左 + short LEFT_right; // 向右 + + short RIGHT_up; // 向上 // 5 + short RIGHT_down; // 向下 + short RIGHT_left; // 向左 + short RIGHT_right; // 向右 + + short middle; + + short A_button; // 按钮A // 10 + short B_button; // 按钮B + short C_button; // 按钮C + short D_button; // 按钮D + short E_button; // 按钮E + short F_button; // 按钮F + + short LEFT_x_axis; // 左摇杆X轴 // 16 + short LEFT_y_axis; // 左摇杆Y轴 + short RIGHT_x_axis; // 右摇杆X轴 + short RIGHT_y_axis; // 右摇杆Y轴 + + short end; // 结束标志位 // 20 +}; + +enum enumRemoteControlOrderFormat +{ + LEFT_UP = 0X10, // 左侧方向键上 + LEFT_DOWN = 0X20, // 左侧方向键下 + LEFT_LEFT = 0X30, // 左侧方向键左 + LEFT_RIGHT = 0X40, // + + RIGHT_UP = 0X50, // 右侧方向键上 + RIGHT_DOWN = 0X60, // 右侧方向键下 + RIGHT_LEFT = 0X70, // 右侧方向键左 + RIGHT_RIGHT = 0X80, // + + LEFT_X_AXIS = 0X9A, // 左侧摇杆的指令 + LEFT_Y_AXIS = 0X9B, + RIGHT_X_AXIS = 0X9C, // 右侧摇杆的指令 + RIGHT_Y_AXIS = 0X9D, + + A_BUTTON = 0XA0, // 左侧A功能键 + B_BUTTON = 0XB0, // 左侧B功能键 + C_BUTTON = 0XC0, // 右侧C功能键 + D_BUTTON = 0XD0, // 右侧D功能键 + E_BUTTON = 0XE0, // 中间开关E + F_BUTTON = 0XF0 // 中间开关F +}; + +// struct structJoystickDataFormat +// { +// short x_axis; // 左右摇杆X轴 +// short y_axis; // 左右摇杆Y轴 +// }; + +// 基础输入输出函数 start -------------------- void XHZS_begin(const char *device_name, const char *device_password); -void uart_printf(const char *format, ...); char *uart_receiveBuffer(); - +void uart_printf(const char *format, ...); void Uart_SendByte(uint8_t *dataByte); void Uart_SendArray(uint8_t *dataArray, size_t dataSize); +// 基础输入输出函数 end -------------------- // 串口功能 start void uart_EnableSerialCallback(); -void bluetooth_SerialReceiveCallback(const uint8_t *buffer, size_t size); -void wifi_SerialReceiveCallback(void *arg, AsyncClient *client, void *data, size_t len); -// 串口功能 start +void uart_bluetoothDataReceivedCallback(const uint8_t *buffer, size_t size); +void uart_wifiDataReceivedCallback(void *arg, AsyncClient *client, void *data, size_t len); +// 串口功能 start -------------------- -// 示波器功能 start +// 示波器功能 start -------------------- void XHZS_SendWave(uint8_t *waveAddr, uint16_t waveSize); char OscGetFloat(const char *p, float *value); char OscGetValue(const char *p, const char *name, float *value); void SendWave(); -void OscilloscopeSendsAndReceivesData(); -// 示波器功能 end +void Oscilloscope_SendsAndReceivesData(); +// 示波器功能 end -------------------- + +// 遥控器功能 start -------------------- +void RemoteControl_EnableCallbackReceive(); +void RemoteControl_BluetoothCallbackReceive(const uint8_t *buffer, size_t size); +void RemoteControl_WifiCallbackReceive(void *arg, AsyncClient *client, void *data, size_t len); +void RemoteControl_CallbackReceiveAnalysis(const uint8_t *buffer, size_t size); +void RemoteControl_getJoystickValueXY(char (&inputButtonData)[4], short &output_x_axis, short &output_y_axis); +void RemoteControl_StructureArrayProcessingData(structRemoteControlDataFormat &remoteControlData); +void RemoteControl_SwitchCaseProcessingData(structRemoteControlDataFormat &remoteControlData, uint8_t &cmd, uint8_t &value); + +void RemoteControl_TimedReceive(); -// 遥控器功能 start +// 遥控器功能 end -------------------- -// 遥控器功能 end #endif diff --git a/PlatformIO_ESP32_oscilloscope/src/main.cpp b/PlatformIO_ESP32_oscilloscope/src/main.cpp index b5cf9a9d2cf7880bf3a0f039e1b158b262501f7a..f30ab0d4ef259ee375065b34815f3e7941d3ff16 100644 --- a/PlatformIO_ESP32_oscilloscope/src/main.cpp +++ b/PlatformIO_ESP32_oscilloscope/src/main.cpp @@ -1,15 +1,15 @@ #include #include "myXHZS.h" - void setup() { + Serial.begin(115200); + XHZS_begin("esp32_BT", "12345678"); - uart_EnableSerialCallback(); - - // OscilloscopeSendsAndReceivesData(); + // uart_EnableSerialCallback(); + // OscilloscopeSendsAndReceivesData(); } void loop() @@ -17,19 +17,6 @@ void loop() delay(3000); } - - - - - - - - - - - - - #if false #include