Browse Source

update

master
zwsd 3 years ago
parent
commit
5305255239
  1. 22
      main/main.c

22
main/main.c

@ -103,24 +103,14 @@ void process_setPosition(RxContext_t *context, cJSON *rxjson) {
construct_set_position_packet_and_report(context->index, setPosition_code);
}
void process_getStatus(cJSON *rxjson) {
int index = 0;
if (cJSON_IsNumber(cJSON_GetObjectItem(rxjson, "index"))) {
index = cJSON_GetNumberValue(cJSON_GetObjectItem(rxjson, "index"));
}
void process_getStatus(RxContext_t *context, cJSON *rxjson) {
double motor_position = motor_get_position_degree();
construct_get_status_packet_and_report(index, motor_position);
}
void process_setMotorCurrentSize(cJSON *rxjson) {
int index = 0;
if (cJSON_IsNumber(cJSON_GetObjectItem(rxjson, "index"))) {
index = cJSON_GetNumberValue(cJSON_GetObjectItem(rxjson, "index"));
construct_get_status_packet_and_report(context->index, motor_position);
}
void process_setMotorCurrentSize(RxContext_t *context, cJSON *rxjson) {
motor_set_zero_point();
construct_set_motorCurrentSize_packet_and_report(index);
construct_set_motorCurrentSize_packet_and_report(context->index);
}
void processrxjson(cJSON *rxjson) {
@ -140,9 +130,9 @@ void processrxjson(cJSON *rxjson) {
if (strcmp(rxcontext.order, "setPosition") == 0) {
process_setPosition(&rxcontext, rxjson);
} else if (strcmp(rxcontext.order, "getStatus") == 0) {
process_getStatus(rxjson);
process_getStatus(&rxcontext, rxjson);
} else if (strcmp(rxcontext.order, "setMotorCurrentSize") == 0) {
process_setMotorCurrentSize(rxjson);
process_setMotorCurrentSize(&rxcontext, rxjson);
}
}

Loading…
Cancel
Save