diff --git a/main/ble_parse_data.c b/main/ble_parse_data.c index 9de90aa..7664089 100644 --- a/main/ble_parse_data.c +++ b/main/ble_parse_data.c @@ -1,4 +1,5 @@ #include "ble_parse_data.h" + #include "motor_drive.h" #define BLE_PARSE_DATA_TAG "BLE_PARSE_DATA" @@ -172,6 +173,8 @@ void receipt_json_get_status() { return; } + parse_bluetooth_processer->motor_drive_turn_flag = true; + cJSON_AddStringToObject(pRoot, "order", "receipt"); //添加一个节点 cJSON_AddNumberToObject(pRoot, "index", parse_bluetooth_processer->index); cJSON_AddStringToObject(pRoot, "deviceState", parse_bluetooth_processer->deviceState); diff --git a/main/ble_parse_data.h b/main/ble_parse_data.h index d1a1dec..1a3e240 100644 --- a/main/ble_parse_data.h +++ b/main/ble_parse_data.h @@ -44,6 +44,7 @@ typedef struct bluetooth_processer { bool cmd_flag; bool auto_report_flag; + bool motor_drive_turn_flag; } bluetooth_processer_t; diff --git a/main/main.c b/main/main.c index d154237..d1dfbac 100644 --- a/main/main.c +++ b/main/main.c @@ -8,8 +8,8 @@ #include "string.h" // #include "ble_spp_server_demo.h" -#include "timer_u.h" #include "motor_drive.h" +#include "timer_u.h" #define MAIN_TAG "MAIN" @@ -44,12 +44,14 @@ bluetooth_processer_t s_bluetooth_processer = { .cmd_flag = false, .auto_report_flag = false, + .motor_drive_turn_flag = false, }; void app_main(void) { constructor_bluetooth_processer(&s_bluetooth_processer); ble_spp_server_demo_app_main(&s_bluetooth_processer); timer_group_init(TIMER_GROUP_0, TIMER_0, false, timer_group0_interval_num, timer_interval_ms); + motor_drive_uart_init(); while (true) { bluetooth_gatts_try_process_data(); @@ -57,6 +59,11 @@ void app_main(void) { receipt_json_get_status(); s_bluetooth_processer.auto_report_flag = false; } + + if ((motor_drive_read_encoder() == s_bluetooth_processer.position) && s_bluetooth_processer.motor_drive_turn_flag == true) { + ESP_LOGI("test", "info log ok\n"); + s_bluetooth_processer.motor_drive_turn_flag = false; + } } return; diff --git a/main/motor_drive.c b/main/motor_drive.c index c397465..d9e6ad3 100644 --- a/main/motor_drive.c +++ b/main/motor_drive.c @@ -4,3 +4,4 @@ void motor_drive_uart_init() {} void motor_drive_turn(int direction, int speed_level, double position) {} +double motor_drive_read_encoder() { return 0.0; } diff --git a/main/motor_drive.h b/main/motor_drive.h index a89130b..16eb122 100644 --- a/main/motor_drive.h +++ b/main/motor_drive.h @@ -5,4 +5,5 @@ #include void motor_drive_uart_init(); -void motor_drive_turn(int direction, int speed_level, double position); \ No newline at end of file +void motor_drive_turn(int direction, int speed_level, double position); +double motor_drive_read_encoder(); \ No newline at end of file