Skip to content

Commit c57910c

Browse files
committed
codal_port/microbit_microphone: Make is_event use current event.
Instead of the last sound event in the history, which will stop working when the history buffer gets full. The semantics of microphone.is_event() now match accelerometer.is_gesture(). Signed-off-by: Damien George <damien@micropython.org>
1 parent a76e141 commit c57910c

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/codal_port/microbit_microphone.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,7 @@ STATIC mp_obj_t microbit_microphone_is_event(mp_obj_t self_in, mp_obj_t sound_in
117117
(void)self_in;
118118
microphone_init();
119119
uint8_t sound = sound_event_from_obj(sound_in);
120-
if (sound_event_history_index > 0) {
121-
return mp_obj_new_bool(sound == sound_event_history_array[sound_event_history_index - 1]);
122-
}
123-
return mp_const_false;
120+
return mp_obj_new_bool(sound == sound_event_current);
124121
}
125122
STATIC MP_DEFINE_CONST_FUN_OBJ_2(microbit_microphone_is_event_obj, microbit_microphone_is_event);
126123

0 commit comments

Comments
 (0)