Skip to content

Commit 3f22f30

Browse files
committedSep 16, 2024·
codal_port/microbit_pin: Add pin.touch_calibrate() method.
Added to pins that have touch capabilities. Signed-off-by: Damien George <damien@micropython.org>
1 parent 24e75ff commit 3f22f30

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
 

Diff for: ‎src/codal_port/microbit_pin.c

+9
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ const microbit_pin_obj_t microbit_p20_obj = {{&microbit_dig_pin_type}, 20, MICR
5151
const microbit_pin_obj_t microbit_pin_logo_obj = {{&microbit_touch_only_pin_type}, 30, MICROBIT_HAL_PIN_LOGO, MODE_UNUSED};
5252
const microbit_pin_obj_t microbit_pin_speaker_obj = {{&microbit_dig_pin_type}, 31, MICROBIT_HAL_PIN_SPEAKER, MODE_UNUSED};
5353

54+
static mp_obj_t microbit_pin_touch_calibrate(mp_obj_t self_in) {
55+
microbit_pin_obj_t *self = MP_OBJ_TO_PTR(self_in);
56+
microbit_hal_pin_touch_calibrate(self->name);
57+
return mp_const_none;
58+
}
59+
static MP_DEFINE_CONST_FUN_OBJ_1(microbit_pin_touch_calibrate_obj, microbit_pin_touch_calibrate);
60+
5461
static mp_obj_t microbit_pin_get_mode_func(mp_obj_t self_in) {
5562
microbit_pin_obj_t *self = (microbit_pin_obj_t*)self_in;
5663
return MP_OBJ_NEW_QSTR(microbit_pin_get_mode(self)->name);
@@ -248,6 +255,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
248255
);
249256

250257
static const mp_rom_map_elem_t microbit_touch_pin_locals_dict_table[] = {
258+
{ MP_ROM_QSTR(MP_QSTR_touch_calibrate), MP_ROM_PTR(&microbit_pin_touch_calibrate_obj) },
251259
{ MP_ROM_QSTR(MP_QSTR_write_digital), MP_ROM_PTR(&microbit_pin_write_digital_obj) },
252260
{ MP_ROM_QSTR(MP_QSTR_read_digital), MP_ROM_PTR(&microbit_pin_read_digital_obj) },
253261
{ MP_ROM_QSTR(MP_QSTR_write_analog), MP_ROM_PTR(&microbit_pin_write_analog_obj) },
@@ -275,6 +283,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
275283
);
276284

277285
static const mp_rom_map_elem_t microbit_touch_only_pin_locals_dict_table[] = {
286+
{ MP_ROM_QSTR(MP_QSTR_touch_calibrate), MP_ROM_PTR(&microbit_pin_touch_calibrate_obj) },
278287
{ MP_ROM_QSTR(MP_QSTR_is_touched), MP_ROM_PTR(&microbit_pin_is_touched_obj) },
279288
{ MP_ROM_QSTR(MP_QSTR_was_touched), MP_ROM_PTR(&microbit_pin_was_touched_obj) },
280289
{ MP_ROM_QSTR(MP_QSTR_get_touches), MP_ROM_PTR(&microbit_pin_get_touches_obj) },

0 commit comments

Comments
 (0)
Please sign in to comment.