Browse Source

添加转动标志,并测试

devtest
zwsd 3 years ago
parent
commit
41d4ae3a18
  1. 3
      main/ble_parse_data.c
  2. 1
      main/ble_parse_data.h
  3. 9
      main/main.c
  4. 1
      main/motor_drive.c
  5. 3
      main/motor_drive.h

3
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);

1
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;

9
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;

1
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; }

3
main/motor_drive.h

@ -5,4 +5,5 @@
#include <string.h>
void motor_drive_uart_init();
void motor_drive_turn(int direction, int speed_level, double position);
void motor_drive_turn(int direction, int speed_level, double position);
double motor_drive_read_encoder();
Loading…
Cancel
Save