Skip to content

Create SoundEvent class #20

@microbit-carlos

Description

@microbit-carlos

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions