diff --git a/user/config/config.c b/user/config/config.c index 29ad342..6c8c17c 100644 --- a/user/config/config.c +++ b/user/config/config.c @@ -28,11 +28,8 @@ static void rov_info_write_initial_value(struct rov_info* info) memset(info, 0, sizeof(rov_info_t));//变量初始化 propeller_params_all_init(&info->propeller); - rocket_ratio_params_all_init(&info->rocket); - pid_ctl_params_all_init(&info->pidScale); - dev_ctl_params_all_init(&info->devCtl); } diff --git a/user/config/parameters/propeller.c b/user/config/parameters/propeller.c index e1d1be4..ad5b8d7 100644 --- a/user/config/parameters/propeller.c +++ b/user/config/parameters/propeller.c @@ -25,11 +25,11 @@ cJSON* propeller_params_add_to_root(struct propeller_parameters *params) return node; } -void propeller_freq_read_from_root(double *freq, cJSON *node) +void propeller_freq_read_from_root(uint16_t *freq, cJSON *node) { if (node == NULL) return; - *freq = node->valuedouble; + *freq = node->valueint; } /** @@ -54,7 +54,7 @@ void propeller_params_read_from_root(struct propeller_parameters *params, cJSON * @brief 单个推进器频率初始化(默认50 HZ ) * @param params 推进器PWM频率参数(propeller.pwm_freq_calibration) */ -void propeller_params_init_freq(double *params) +void propeller_params_init_freq(uint16_t *params) { *params = 50; } diff --git a/user/config/parameters/propeller.h b/user/config/parameters/propeller.h index 0114593..cbd9b55 100644 --- a/user/config/parameters/propeller.h +++ b/user/config/parameters/propeller.h @@ -9,9 +9,9 @@ #include "data_define.h" cJSON* propeller_params_add_to_root(struct propeller_parameters *params); -void propeller_freq_read_from_root(double *freq, cJSON *node); +void propeller_freq_read_from_root(uint16_t *freq, cJSON *node); void propeller_params_read_from_root(struct propeller_parameters *params, cJSON *node); -void propeller_params_init_freq(double *params); +void propeller_params_init_freq(uint16_t *params); void propeller_params_init(struct propeller_parameters *params); void propeller_params_all_init(propeller_t *params); diff --git a/user/data-type/propeller.h b/user/data-type/propeller.h index 3502f2d..f95cb85 100644 --- a/user/data-type/propeller.h +++ b/user/data-type/propeller.h @@ -19,7 +19,7 @@ struct propeller_parameters typedef struct propeller { - double pwm_freq_calibration; + uint16_t pwm_freq_calibration; struct propeller_parameters front_left; struct propeller_parameters front_right; struct propeller_parameters center_left; diff --git a/user/server/handler/control.c b/user/server/handler/control.c index c4c55ad..53038f3 100644 --- a/user/server/handler/control.c +++ b/user/server/handler/control.c @@ -1,20 +1,8 @@ +#include "config/parameters/utils.h" #include "data_define.h" #include "control.h" -static double cjson_value_analysis_double(cJSON *params,const char *str) -{ - cJSON* cjson_temp = NULL; - double value; - cjson_temp = cJSON_GetObjectItem(params, str); - if (cjson_temp != NULL) //如果没收到则返回 - { - value = cjson_temp->valuedouble; - } - else value = 0; - return value; -} - static cJSON *move_analysis(cJSON* params, struct rov_info* info, move_mode_t mode) { if (params == NULL) diff --git a/user/server/handler/debug.c b/user/server/handler/debug.c index 7af011b..df6d87e 100644 --- a/user/server/handler/debug.c +++ b/user/server/handler/debug.c @@ -1,25 +1,13 @@ #include "config/parameters/pid_ctl.h" #include "config/parameters/propeller.h" #include "device/application/pwm_controller.h" +#include "config/parameters/utils.h" #include "config/config.h" #include "data_define.h" #include "debug.h" -static int cjson_value_analysis_int(cJSON *params, const char *str) -{ - cJSON* cjson_temp = NULL; - int value; - cjson_temp = cJSON_GetObjectItem(params, str); - if (cjson_temp != NULL) //如果没收到则返回 - { - value = cjson_temp->valueint; - } - else value = 0; - return value; -} - cJSON *set_debug_mode_enabled_handler(jrpc_context *ctx, cJSON *params, cJSON *id) { if (params == NULL) @@ -32,7 +20,7 @@ cJSON *set_propeller_pwm_freq_calibration_handler(jrpc_context *ctx, cJSON *para { if (params == NULL) return cJSON_CreateNull(); - pwm_controller_set_freq((uint16_t)params->child->valuedouble); + pwm_controller_set_freq((uint16_t)params->child->valueint); return cJSON_CreateNull(); }