-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sound hesitation bug fix, event triggered sounds, host sounds #2852
Sound hesitation bug fix, event triggered sounds, host sounds #2852
Conversation
Changes the buzzer from polling to even triggered, saving resouces Solves the sound hesitation sound bug Support for host sounds, M300 support from host
Just a minor cleanup on indentation (tabs, spaces etc.) and removed some comments. SOUND_SILENCE was missing. Added in SOUND typedef in BuzzerControl.h as (if it was your intention). |
Thanks, very appreciated. You did a lot of small cleanup work, you even killed my Easter egg. I will try to follow you example.
|
ok understood. You can simply override your files with mine and apply your changes on it. Use an editor not providing tabs or trailing empty spaces. Use two spaces for Inline comments (with //) |
Clear, thanks. Did you try "M300 S100 P10"? It a suitable as a keypress sound in your view? |
not yet tried. Shall I issue command M300 S100 P10 from ESP3D? |
Some cleanup, thanks digant73, added sound mute/unmute with M300
Yes, or in the terminal. Or if you really want to try how this feels change the values in Configuration.h
|
ok understood. I will make the test this night |
here a review. Please overrides your files with the attached ones. |
Thanks again, great fixes like usual, I will use more brackets, even for one-liners, and I will add the "resolves" line, currently I'm still awaiting a workflow approval of the maintainer. Indeed, there is not much difference in sound for the I replaced all files, except 1 item. You swapped the position of You can use the keyword "TFT" to play the sound on the TFT: "M300 TFT P1000 S500". |
use no brackets when you have both statements in the |
OK, understood, thanks, very appreciated! |
if your PR is ready to be merged exit from draft mode so BTT can consider the PR as ready to be merged. |
@rondlh Is it ready for merge yet? |
@rondlh I'm using your buzzer implementation since some time now and it seems properly working. I see that the function: EDIT:
I created a PR on your repo with all the above changes. It should be enough to merge my PR and it should be ok also here |
Description
This pull request consists out of 3 parts, here they are in order of importance:
1. Print hesitation bugfix. The current TFT sound playback system has a queue of 5 slots that stores the sounds to be played before playback starts. The problem with the current implementation is that if the queue is full, the sound system will block all processes until a sound queue slot becomes available. During this time even printing will be paused because the system is just waiting for a sound slot to become available. This behavior can cause hesitations in the printing process. This PR solves this issue by prioritizing the printing process over sound playback system so no print hesitation can occur because of sound playback.
2. Event driven sounds, no polling. Currently sounds are stored in the sound queue by gcode commands or if the system wants to playback a notification/error/warning sound. These events don't actually start the playback of the sounds. This happens in the main processLoop, where a check is done to see if there are sounds ready for playback in the queue. This process is called polling. This PR makes this process event driven, which means that the arrival of a sound for playback immediately start the sound playback, and the playback of any sounds that arrived afterwards. No check is required in the main loopProcess anymore. This will result in a small efficiency/speed improvement, and can serve as a example of how to efficiently implement event driven processes. Polling should be avoided when possible.
3. Host sounds. Most printer motherboards do not have a speaker/buzzer, one can be added of course, buy why not use the buzzer of the TFT? This process is supported by the Marlin ExtUI interface and works by forwarding the sound that should be played by the motherboard to the TFT. The TFT then takes care of the playback. This PR adds this capability.
4. Remote sound mute/unmute.
Additional functionality is added to give the user remote sound control by allowing sounds to be enabled and disabled via the M300 commands. A ESP3D can be used to mute or unmute sounds remotely without using the touch screen.
Benefits
Note
This PR affects hardware dependent code (interrupts), which requires testing to make sure the code works on all supported hardware platforms. Actually the changes made are quite small, sounds were already using interrupts. The main difference is that when a sound playback is completed, the process doesn't just exit to let the loopProcess restart it, instead the process check if more sounds need to be played and starts this task immediately, so no attention from loopProcess is needed.
This code has been tested on STM32F1xx, STM32F2xx, STM32F4xx and GD32F2xx.
resolves #2845