From 55cbf23f45968e3c71f92751720c71abfdc183ef Mon Sep 17 00:00:00 2001 From: ZodiusInfuser Date: Sat, 19 Feb 2022 20:13:18 +0000 Subject: [PATCH] Function rename --- drivers/servo/calibration.cpp | 2 +- drivers/servo/calibration.hpp | 2 +- drivers/servo/servo_state.cpp | 2 +- micropython/modules/servo/servo.c | 4 ++-- micropython/modules/servo/servo.cpp | 6 +++--- micropython/modules/servo/servo.h | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/servo/calibration.cpp b/drivers/servo/calibration.cpp index aa86c925..9e84db50 100644 --- a/drivers/servo/calibration.cpp +++ b/drivers/servo/calibration.cpp @@ -191,7 +191,7 @@ namespace servo { return success; } - bool Calibration::value_from_pulse(float pulse, float &value_out, float &pulse_out) const { + bool Calibration::pulse_to_value(float pulse, float &value_out, float &pulse_out) const { bool success = false; if(calibration_size >= 2) { uint8_t last = calibration_size - 1; diff --git a/drivers/servo/calibration.hpp b/drivers/servo/calibration.hpp index 1df6230e..b1c28d75 100644 --- a/drivers/servo/calibration.hpp +++ b/drivers/servo/calibration.hpp @@ -72,7 +72,7 @@ namespace servo { void limit_to_calibration(bool lower, bool upper); bool value_to_pulse(float value, float &pulse_out, float &value_out) const; - bool value_from_pulse(float pulse, float &value_out, float &pulse_out) const; + bool pulse_to_value(float pulse, float &value_out, float &pulse_out) const; static float map_float(float in, float in_min, float in_max, float out_min, float out_max); diff --git a/drivers/servo/servo_state.cpp b/drivers/servo/servo_state.cpp index 3db7428e..5931046e 100644 --- a/drivers/servo/servo_state.cpp +++ b/drivers/servo/servo_state.cpp @@ -49,7 +49,7 @@ namespace servo { float ServoState::set_pulse(float pulse) { if(pulse >= MIN_VALID_PULSE) { float value_out, pulse_out; - if(table.value_from_pulse(pulse, value_out, pulse_out)) { + if(table.pulse_to_value(pulse, value_out, pulse_out)) { servo_value = value_out; last_enabled_pulse = pulse_out; return _enable(); diff --git a/micropython/modules/servo/servo.c b/micropython/modules/servo/servo.c index 6f4cb171..8e223ee6 100644 --- a/micropython/modules/servo/servo.c +++ b/micropython/modules/servo/servo.c @@ -14,7 +14,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(Calibration_first_point_obj, 1, Calibration_first_poi MP_DEFINE_CONST_FUN_OBJ_KW(Calibration_last_point_obj, 1, Calibration_last_point); MP_DEFINE_CONST_FUN_OBJ_KW(Calibration_limit_to_calibration_obj, 3, Calibration_limit_to_calibration); MP_DEFINE_CONST_FUN_OBJ_KW(Calibration_value_to_pulse_obj, 2, Calibration_value_to_pulse); -MP_DEFINE_CONST_FUN_OBJ_KW(Calibration_value_from_pulse_obj, 2, Calibration_value_from_pulse); +MP_DEFINE_CONST_FUN_OBJ_KW(Calibration_pulse_to_value_obj, 2, Calibration_pulse_to_value); MP_DEFINE_CONST_FUN_OBJ_1(Servo___del___obj, Servo___del__); MP_DEFINE_CONST_FUN_OBJ_1(Servo_pin_obj, Servo_pin); @@ -63,7 +63,7 @@ STATIC const mp_rom_map_elem_t Calibration_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_last_point), MP_ROM_PTR(&Calibration_last_point_obj) }, { MP_ROM_QSTR(MP_QSTR_limit_to_calibration), MP_ROM_PTR(&Calibration_limit_to_calibration_obj) }, { MP_ROM_QSTR(MP_QSTR_value_to_pulse), MP_ROM_PTR(&Calibration_value_to_pulse_obj) }, - { MP_ROM_QSTR(MP_QSTR_value_from_pulse), MP_ROM_PTR(&Calibration_value_from_pulse_obj) }, + { MP_ROM_QSTR(MP_QSTR_pulse_to_value), MP_ROM_PTR(&Calibration_pulse_to_value_obj) }, }; STATIC const mp_rom_map_elem_t Servo_locals_dict_table[] = { diff --git a/micropython/modules/servo/servo.cpp b/micropython/modules/servo/servo.cpp index 89bfac57..cf5a316e 100644 --- a/micropython/modules/servo/servo.cpp +++ b/micropython/modules/servo/servo.cpp @@ -471,7 +471,7 @@ mp_obj_t Calibration_value_to_pulse(size_t n_args, const mp_obj_t *pos_args, mp_ return mp_const_none; } -mp_obj_t Calibration_value_from_pulse(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +mp_obj_t Calibration_pulse_to_value(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_self, ARG_pulse }; static const mp_arg_t allowed_args[] = { { MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -487,14 +487,14 @@ mp_obj_t Calibration_value_from_pulse(size_t n_args, const mp_obj_t *pos_args, m float pulse = mp_obj_get_float(args[ARG_pulse].u_obj); float value_out, pulse_out; - if(self->calibration->value_from_pulse(pulse, value_out, pulse_out)) { + if(self->calibration->pulse_to_value(pulse, value_out, pulse_out)) { mp_obj_t tuple[2]; tuple[0] = mp_obj_new_float(pulse_out); tuple[1] = mp_obj_new_float(value_out); return mp_obj_new_tuple(2, tuple); } else { - mp_raise_msg(&mp_type_RuntimeError, "Unable to convert value from pulse. Calibration invalid"); + mp_raise_msg(&mp_type_RuntimeError, "Unable to convert pulse to value. Calibration invalid"); } return mp_const_none; } diff --git a/micropython/modules/servo/servo.h b/micropython/modules/servo/servo.h index 4d74b1fb..eeebc499 100644 --- a/micropython/modules/servo/servo.h +++ b/micropython/modules/servo/servo.h @@ -21,7 +21,7 @@ extern mp_obj_t Calibration_first_point(size_t n_args, const mp_obj_t *pos_args, extern mp_obj_t Calibration_last_point(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); extern mp_obj_t Calibration_limit_to_calibration(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); extern mp_obj_t Calibration_value_to_pulse(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); -extern mp_obj_t Calibration_value_from_pulse(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); +extern mp_obj_t Calibration_pulse_to_value(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args); extern void Servo_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind); extern mp_obj_t Servo_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args);