File tree Expand file tree Collapse file tree 1 file changed +10
-13
lines changed Expand file tree Collapse file tree 1 file changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -118,20 +118,17 @@ void microbit_music_tick(void) {
118
118
} else {
119
119
note = ((mp_obj_t * )music_data -> async_note )[music_data -> async_notes_index ];
120
120
}
121
- if (note == mp_const_none ) {
122
- // a rest (is this even used anymore?)
123
- music_output_amplitude (MUSIC_OUTPUT_AMPLITUDE_OFF );
124
- music_data -> async_wait_ticks = 60000 / music_data -> bpm ;
125
- music_data -> async_state = ASYNC_MUSIC_STATE_NEXT_NOTE ;
126
- } else {
127
- // a note
128
- mp_uint_t note_len ;
129
- const char * note_str = mp_obj_str_get_data (note , & note_len );
130
- uint32_t delay_on = start_note (note_str , note_len );
131
- music_data -> async_wait_ticks = mp_hal_ticks_ms () + delay_on ;
132
- music_data -> async_notes_index += 1 ;
133
- music_data -> async_state = ASYNC_MUSIC_STATE_ARTICULATE ;
121
+ if (!mp_obj_is_str_or_bytes (note )) {
122
+ mp_printf (& mp_plat_print , "TypeError: expecting a str for note\n" );
123
+ music_data -> async_state = ASYNC_MUSIC_STATE_IDLE ;
124
+ return ;
134
125
}
126
+ mp_uint_t note_len ;
127
+ const char * note_str = mp_obj_str_get_data (note , & note_len );
128
+ uint32_t delay_on = start_note (note_str , note_len );
129
+ music_data -> async_wait_ticks = mp_hal_ticks_ms () + delay_on ;
130
+ music_data -> async_notes_index += 1 ;
131
+ music_data -> async_state = ASYNC_MUSIC_STATE_ARTICULATE ;
135
132
}
136
133
}
137
134
You can’t perform that action at this time.
0 commit comments