lancaster-university / codal-microbit-v2

CODAL target for the micro:bit v2.x series of devices
MIT License
43 stars 52 forks source link

In MakeCode beta the mic light sometimes stays off when woken from deep sleep, and sound levels are low #382

Closed martinwork closed 11 months ago

martinwork commented 12 months ago

This project sends sound level to serial. Press B to enter sleep. Press A to wake https://makecode.microbit.org/_gyDebV9CpUgF

In MakeCode beta the mic light sometimes stays off when woken from sleep. Then the sound levels reported are low.

I noticed a compiler warning that the new MicroBitAudio::deepSleepCallback does not return a value. https://github.com/lancaster-university/codal-microbit-v2/blob/master/source/MicroBitAudio.cpp#L231

Note that this is an override of the base class deepSleepCallback, that calls setSleep, so I don't think MicroBitAudio::setSleep is called now. Also note deepSleepCallback is called when waking up as well as when going to sleep..

JohnVidler commented 11 months ago

Oops. Caused by my own unfamiliarity with the sleep hooks, this should now be fixed in master, with the inclusion of a deactivateMic() and activateMic() calls on the required sides of a wake event.

This will however briefly wake the mic when waking the board, but it is immediately shut down by the demand-wake code.