microbit-foundation / micropython-microbit-v2

Temporary home for MicroPython for micro:bit v2 as we stablise it before pushing upstream
MIT License
42 stars 23 forks source link

microbit_hal: Consistent values for mic levels #109

Closed microbit-matt-hillsdon closed 1 year ago

microbit-matt-hillsdon commented 2 years ago

HAL implementers need to work with both microbit_hal_level_detector_callback and microbit_hal_microphone_set_threshold. It's confusing for the former to use 1 and 2 and the latter 0 and 1 to represent low and high.

Consistently use 1 and 2 via the HAL defines.

dpgeorge commented 2 years ago

Instead of this I think we should make two new defines to set the threshold (the existing ones are event numbers), because these two sets are conceptually independent.

Eg:

#define MICROBIT_HAL_MICROPHONE_SET_THRESHOLD_LOW (0)
#define MICROBIT_HAL_MICROPHONE_SET_THRESHOLD_HIGH (1)

And probably rename the existing ones to:

#define MICROBIT_HAL_MICROPHONE_EVT_THRESHOLD_LOW (1)
#define MICROBIT_HAL_MICROPHONE_EVT_THRESHOLD_HIGH (2)
dpgeorge commented 1 year ago

As discussed elsewhere, I implemented my above suggestion in a1be53a8ed0501609d869c3147bf47effa38a0a5 and 804c5fee4fd12e786e3815ef37aaefd5649153fa