Function rename

This commit is contained in:
ZodiusInfuser 2022-02-19 20:13:18 +00:00
parent 565553b3a1
commit 55cbf23f45
6 changed files with 9 additions and 9 deletions

View File

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

View File

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

View File

@ -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();

View File

@ -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[] = {

View File

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

View File

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