From c597b00ae213477b9fb1b80fc3329e52fde2a014 Mon Sep 17 00:00:00 2001 From: zwsd Date: Thu, 4 Aug 2022 10:23:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=B5=E6=9C=BA=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=BD=93=E5=89=8D=E4=BD=8D=E7=BD=AE=E4=B8=BA=E9=9B=B6?= =?UTF-8?q?=E7=82=B9=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/main.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/main/main.c b/main/main.c index ddca680..4ceb901 100644 --- a/main/main.c +++ b/main/main.c @@ -99,6 +99,14 @@ void order_receipt_getStatus(int index) { bleuart_notify_send(buffer, strlen((char *)buffer)); } +void order_receipt_setMotorCurrentSize(int index) { + ESP_LOGI(MAIN_LOG_TAG, "Command setMotorCurrentSize execution complete!"); + uint8_t buffer[256] = {0}; + + sprintf((char *)buffer, "{ \"order\": \"receipt\", \"index\": %d }", index); + bleuart_notify_send(buffer, strlen((char *)buffer)); +} + void process_setPosition(cJSON *rxjson) { // { "order": "setPosition", "ble_uart_index": 0, "speedLevel": 1, "position": 120.3, "direction": 0 } int index = 0; @@ -131,6 +139,17 @@ void process_getStatus(cJSON *rxjson) { order_receipt_getStatus(index); } +void process_setMotorCurrentSize(cJSON *rxjson) { + int index = 0; + if (cJSON_IsNumber(cJSON_GetObjectItem(rxjson, "index"))) { + index = cJSON_GetNumberValue(cJSON_GetObjectItem(rxjson, "index")); + } + + motor_set_zero_point(); + + order_receipt_setMotorCurrentSize(index); +} + void processrxjson(cJSON *rxjson) { if (!cJSON_IsString(cJSON_GetObjectItem(rxjson, "order"))) { return; @@ -140,9 +159,10 @@ void processrxjson(cJSON *rxjson) { if (strcmp(order, "setPosition") == 0) { process_setPosition(rxjson); - } else if (strcmp(order, "getStatus") == 0) { process_getStatus(rxjson); + } else if (strcmp(order, "setMotorCurrentSize") == 0) { + process_setMotorCurrentSize(rxjson); } }