@@ -49,7 +49,7 @@ const microbit_pin_obj_t microbit_p19_obj = {{µbit_dig_pin_type}, 19, MICR
4949const microbit_pin_obj_t microbit_p20_obj = {{& microbit_dig_pin_type }, 20 , MICROBIT_HAL_PIN_P20 , MODE_I2C };
5050
5151const microbit_pin_obj_t microbit_pin_logo_obj = {{& microbit_touch_only_pin_type }, 30 , MICROBIT_HAL_PIN_FACE , MODE_UNUSED };
52- const microbit_pin_obj_t microbit_pin_speaker_obj = {{& microbit_speaker_pin_type }, 31 , MICROBIT_HAL_PIN_SPEAKER , MODE_UNUSED };
52+ const microbit_pin_obj_t microbit_pin_speaker_obj = {{& microbit_dig_pin_type }, 31 , MICROBIT_HAL_PIN_SPEAKER , MODE_UNUSED };
5353
5454static mp_obj_t microbit_pin_get_mode_func (mp_obj_t self_in ) {
5555 microbit_pin_obj_t * self = (microbit_pin_obj_t * )self_in ;
@@ -177,20 +177,6 @@ mp_obj_t microbit_pin_set_touch_mode(mp_obj_t self_in, mp_obj_t mode_in) {
177177}
178178MP_DEFINE_CONST_FUN_OBJ_2 (microbit_pin_set_touch_mode_obj , microbit_pin_set_touch_mode );
179179
180- STATIC mp_obj_t microbit_pin_speaker_disable (mp_obj_t self_in ) {
181- (void )self_in ;
182- microbit_pin_audio_speaker_enable (false);
183- return mp_const_none ;
184- }
185- STATIC MP_DEFINE_CONST_FUN_OBJ_1 (microbit_pin_speaker_disable_obj , microbit_pin_speaker_disable );
186-
187- STATIC mp_obj_t microbit_pin_speaker_enable (mp_obj_t self_in ) {
188- (void )self_in ;
189- microbit_pin_audio_speaker_enable (true);
190- return mp_const_none ;
191- }
192- STATIC MP_DEFINE_CONST_FUN_OBJ_1 (microbit_pin_speaker_enable_obj , microbit_pin_speaker_enable );
193-
194180#define PULL_CONSTANTS \
195181 { MP_ROM_QSTR(MP_QSTR_PULL_UP), MP_ROM_INT(MICROBIT_HAL_PIN_PULL_UP) }, \
196182 { MP_ROM_QSTR(MP_QSTR_PULL_DOWN), MP_ROM_INT(MICROBIT_HAL_PIN_PULL_DOWN) }, \
@@ -278,26 +264,9 @@ const mp_obj_type_t microbit_touch_only_pin_type = {
278264 .locals_dict = (mp_obj_dict_t * )& microbit_touch_only_pin_locals_dict ,
279265};
280266
281- STATIC const mp_rom_map_elem_t microbit_speaker_pin_locals_dict_table [] = {
282- { MP_ROM_QSTR (MP_QSTR_write_digital ), MP_ROM_PTR (& microbit_pin_write_digital_obj ) },
283- { MP_ROM_QSTR (MP_QSTR_write_analog ), MP_ROM_PTR (& microbit_pin_write_analog_obj ) },
284- { MP_ROM_QSTR (MP_QSTR_set_analog_period ), MP_ROM_PTR (& microbit_pin_set_analog_period_obj ) },
285- { MP_ROM_QSTR (MP_QSTR_set_analog_period_microseconds ), MP_ROM_PTR (& microbit_pin_set_analog_period_microseconds_obj ) },
286- { MP_ROM_QSTR (MP_QSTR_get_analog_period_microseconds ), MP_ROM_PTR (& microbit_pin_get_analog_period_microseconds_obj ) },
287- { MP_ROM_QSTR (MP_QSTR_disable ), MP_ROM_PTR (& microbit_pin_speaker_disable_obj ) },
288- { MP_ROM_QSTR (MP_QSTR_enable ), MP_ROM_PTR (& microbit_pin_speaker_enable_obj ) },
289- };
290- STATIC MP_DEFINE_CONST_DICT (microbit_speaker_pin_locals_dict , microbit_speaker_pin_locals_dict_table );
291-
292- const mp_obj_type_t microbit_speaker_pin_type = {
293- { & mp_type_type },
294- .name = MP_QSTR_MicroBitSpeakerPin ,
295- .locals_dict = (mp_obj_dict_t * )& microbit_speaker_pin_locals_dict ,
296- };
297-
298267const microbit_pin_obj_t * microbit_obj_get_pin (mp_obj_t o ) {
299268 const mp_obj_type_t * type = mp_obj_get_type (o );
300- if (type == & microbit_touch_pin_type || type == & microbit_ad_pin_type || type == & microbit_dig_pin_type || type == & microbit_speaker_pin_type ) {
269+ if (type == & microbit_touch_pin_type || type == & microbit_ad_pin_type || type == & microbit_dig_pin_type ) {
301270 return (microbit_pin_obj_t * )o ;
302271 } else {
303272 mp_raise_TypeError ("expecting a pin" );
0 commit comments