ports: Use mp_obj_is_float instead of mp_obj_is_type.

`mp_obj_is_float` must be used in case the object representation is C or D.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George
2026-04-08 11:43:41 +10:00
parent 234bac45d3
commit 416eadf962
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -339,7 +339,7 @@ static mp_obj_t pyb_timer_freq(size_t n_args, const mp_obj_t *args) {
uint32_t freq;
if (0) {
#if MICROPY_PY_BUILTINS_FLOAT
} else if (mp_obj_is_type(args[1], &mp_type_float)) {
} else if (mp_obj_is_float(args[1])) {
freq = (int)mp_obj_get_float(args[1]);
#endif
} else {
+2 -2
View File
@@ -450,7 +450,7 @@ static uint32_t compute_prescaler_period_from_freq(pyb_timer_obj_t *self, mp_obj
uint32_t period;
if (0) {
#if MICROPY_PY_BUILTINS_FLOAT
} else if (mp_obj_is_type(freq_in, &mp_type_float)) {
} else if (mp_obj_is_float(freq_in)) {
float freq = mp_obj_get_float_to_f(freq_in);
if (freq <= 0) {
goto bad_freq;
@@ -545,7 +545,7 @@ static uint32_t compute_pwm_value_from_percent(uint32_t period, mp_obj_t percent
uint32_t cmp;
if (0) {
#if MICROPY_PY_BUILTINS_FLOAT
} else if (mp_obj_is_type(percent_in, &mp_type_float)) {
} else if (mp_obj_is_float(percent_in)) {
mp_float_t percent = mp_obj_get_float(percent_in);
if (percent <= 0.0) {
cmp = 0;