Repository navigation
M5StickCPlus2 Shot Timer Release Candidate
Pre-release
Pre-release
Shot Timer Release Notes - May 7, 2025
This release incorporates significant updates, including major code refactoring, Bluetooth audio integration, multicore processing for audio, and various functional improvements and bug fixes.
Key New Features & Major Changes
-
Code Refactoring:
- The original single
.inofile has been split into multiple logical units (.hand.cppfiles) for improved maintainability and organization. This includes modules for configuration, global variables, display utilities, input handling, timer modes, audio utilities, Bluetooth utilities, NVS storage, and system utilities.
- The original single
-
Bluetooth A2DP Audio Output:
- Added the capability to stream audio (start beeps, par beeps, UI feedback) to a connected Bluetooth A2DP speaker or headset.
- Implemented Bluetooth device scanning using the A2DP discovery protocol.
- Added a dedicated "Bluetooth Settings" menu with options to:
- Connect to the last selected/saved device.
- Disconnect from the current device.
- Adjust Bluetooth audio volume (saved to NVS).
- Scan for nearby A2DP devices.
- Toggle auto-reconnect on startup (saved to NVS).
- Calibrate audio synchronization (see below).
- Selecting a device from the scan list now saves it and attempts an immediate connection.
- A near-silent "keep-alive" signal is sent when connected but idle to help maintain the connection.
-
Bluetooth Audio Offset Calibration:
- Introduced a "BT Audio Offset" setting (saved to NVS) to compensate for inherent Bluetooth audio latency.
- Added a calibration screen where users can adjust the offset (in milliseconds, -1000ms to +500ms range, 50ms steps).
- During calibration, a test tone plays simultaneously on the buzzer (immediate) and Bluetooth (with the test offset) to allow visual/auditory synchronization.
- The saved offset is automatically applied only to timer start beeps when playing over Bluetooth, ensuring synchronization with the timer's actual start time.
-
Multicore Buzzer Control:
- Buzzer tone generation has been moved to a dedicated FreeRTOS task running on Core 0.
- A queue (
buzzerQueue) is used to send beep requests from the main application loop (Core 1) to the buzzer task, preventing the main loop from being blocked by buzzer delays.
-
Audio Output Logic:
- Created distinct functions:
playTone(): Used for timer start beeps. Applies the BT audio offset if connected via Bluetooth, otherwise queues the beep for the buzzer task.playFeedbackTone(): Used for UI sounds (e.g., success/failure). Does not apply the BT audio offset, ensuring immediate feedback. Plays on BT if connected, otherwise queues for the buzzer task.playSyncCalibrationTone(): Used only during offset calibration. Plays on both buzzer (queued) and BT (with the test offset) simultaneously.
- Created distinct functions:
-
Improved Start Beep Handling:
- Implemented logic (
is_listening_active,beep_audio_end_time) to delay the activation of microphone listening in Live Fire and Noisy Range modes until after the calculated end time of the start beep audio (considering duration and BT offset). micPeakRMS.update()is now only called when listening is active.- Increased
POST_BEEP_DELAY_MSto 750ms to further reduce the chance of the start beep triggering the timer.
- Implemented logic (
Bug Fixes & Refinements
- Resolved "multiple definition" linker errors by correctly using
externdeclarations in headers and defining variables/constants in.cppfiles. - Fixed header include path typos (e.g.,
freertos/task.h). - Improved Bluetooth scanning stability by refining the process of stopping/starting A2DP services.
- Ensured the buzzer does not play simultaneously with Bluetooth audio, except during the specific offset calibration process.
- Adjusted delays in multi-tone sequences (
playSuccessBeeps,playUnsuccessBeeps) to better accommodate potential Bluetooth latency. - Enabled access to the Settings menu via long-press of BtnB from the Mode Selection screen.
- Refined microphone peak reset logic within timer loops.
Updated Dependencies
- Requires the
ESP32-A2DPlibrary by pschatzmann.