Closed microbit-carlos closed 3 years ago
To capture the current 'loud' and 'quiet' options and give us the possibility to expand it in the future to other types of events.
Something along these lines:
class MicroBitSoundEvent: LOUD = None QUIET = None def __init__(self, event_name: string) -> None: self.event_name = event_name def __str__(self) -> string: return "SoundEvent('{}')".format(self.event_name) def __repr__(self) -> string: return self.__str__() MicroBitSoundEvent.LOUD = MicroBitSoundEvent("loud") MicroBitSoundEvent.QUIET = MicroBitSoundEvent("quiet") SoundEvent = MicroBitSoundEvent
So that the user code will end up:
microphone.was_event(SoundEvent.LOUD)
@microbit-giles is currently drafting resources against this speculative API so important that the first public relese uses this.
Done in 18eb9de1e88afca0fb2615a2bc483d0e3a214fd3
To capture the current 'loud' and 'quiet' options and give us the possibility to expand it in the future to other types of events.
Something along these lines:
So that the user code will end up: