-
-
Notifications
You must be signed in to change notification settings - Fork 284
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
Improve Sound #80
Merged
ClemensElflein
merged 88 commits into
ClemensElflein:main
from
Apehaenger:feature/Improve-Sound
Dec 14, 2024
Merged
Improve Sound #80
Changes from 59 commits
Commits
Show all changes
88 commits
Select commit
Hold shift + click to select a range
5b53be4
Switch to Makuna/DFMiniMp3 and simplified USB debugging
Apehaenger caff476
Adapt SD-Card folder and track names
Apehaenger b7aa048
SD-Card folder description
Apehaenger f697371
Implement own advert functionality
Apehaenger 73ed5a1
Docs
Apehaenger 037be58
Add cosmetic pause functionality
Apehaenger 1b747a1
Add high_level_state parameter
Apehaenger 039498c
Cleanup
Apehaenger ab9605d
Add emergency sound processing
Apehaenger df3f71d
New sounds & ROS startup successful
Apehaenger 1f6fdc9
Fix new timing issue, add Mode & GPS handling
Apehaenger f7af392
Fix ROS startup sound order and protected redundancy call of OnPlayFi…
Apehaenger 3844414
Fix emergencies
Apehaenger 72a08d4
Restrict GPS ping to area recording mode
Apehaenger c2121c5
Fix GPS ping, add rain handling
Apehaenger 869c6db
Add randomized mowing background sounds & further GPS ping fixes
Apehaenger 44e4ffb
Add new and german sound files
Apehaenger 50bdb20
Merge remote-tracking branch 'origin/main' into feature/Improve-Sound
Apehaenger 2425868
Add soundfiles from alfakenzo
Apehaenger 21abc0d
Soundfile corrections
Apehaenger e95600c
Add Sound "IMU init failed"
Apehaenger a6f5ef6
Add repeatDuration
Apehaenger ebe0dee
Fix rand mow sound during waiting for GPS fix
Apehaenger 12cac4d
Add debug prefix string
Apehaenger 17daa87
Restructure SoundSystem from OOP to FP
Apehaenger ac31e13
Work around playFolderTrack16()
Apehaenger 36821b0
Work around non working stop() when OnPlayFinish ed()
Apehaenger b2f47d9
Improved emergency handling
Apehaenger 2bc7539
Change translation
Apehaenger b752c30
Skip needless namespace
Apehaenger 7f5258c
Fix emergency during flash & docked. Add/change sounds
Apehaenger 32cd1ed
Add VCC warning
Apehaenger 88859d9
Add volume and language control via LL buttons
Apehaenger f5bb630
Change some sounds, add collision sound for SA/SC models
Apehaenger 9ec6374
Merge branch 'ClemensElflein:main' into feature/Improve-Sound
Apehaenger f9db1c0
Default Volume
Apehaenger 51ce80d
No "Bida bida" on stop-button
Apehaenger 1b21909
Squashed commit of the following:
Apehaenger 1245e4e
Fix missing soundsystem.cpp for 0_13_X
Apehaenger 9e96ae7
Current measurements on 3.3V line
Apehaenger f4085ac
Implemented SD-Card type/format detection (old/new) and old SD-Card f…
Apehaenger cb87656
Merge commit 'aa152dae86770dac64b26686c5c891ed1606b2b3' into feature/…
Apehaenger 2a8ecbd
Fix missing -DENABLE_SOUND_MODULE
Apehaenger 137d196
Add DFPIS5V compile flag
Apehaenger d0336ee
PR cleanup
Apehaenger 8bd4cab
PR cleanup
Apehaenger d970755
Stick to previous DFP lib 1.2.2
Apehaenger 134c717
Removed or replaced problematic sound files
Apehaenger 7791017
Merge branch 'main' into feature/Improve-Sound
Apehaenger d199148
Merge branch 'main'
Apehaenger fe4670d
Merge branch 'feature/nv-config'
Apehaenger fd94321
Merge branch 'main' into feature/Improve-Sound
Apehaenger 80c435f
Merged 'nv_config' PR and integrated LL/HL config packet
Apehaenger 0b48eba
Fix CI
Apehaenger bea6d3b
Fix volume down announcement
Apehaenger edbfa69
Add "ROS stopped" announcement
Apehaenger 3f991f7
Update ci.yaml
ClemensElflein f4bc42a
Update ci.yaml
ClemensElflein 7f6324a
Update ci.yaml
ClemensElflein 9e30aad
Add 0.13.x resistor comment, update button description, update some m…
Apehaenger 4a15413
Fix SD-Card detection tampering by volume change
Apehaenger a9bb52d
DFP lib version bump
Apehaenger 8b3590d
Merge branch 'main' into feature/Improve-Sound
Apehaenger ca9d1c1
Cut-off Pin-11 (IO2) recommendation for DFPlayer-Clones
Apehaenger 0d8a83f
Add forgotten readme img
Apehaenger 62e7abd
Add new 'JL AB23A799755' clone
Apehaenger 396f15f
Add new 'JL AB23A799755' clone
Apehaenger c9525d2
Merge branch 'main' into feature/Improve-Sound
Apehaenger 46c1746
Merge branch 'main' into feature/Improve-Sound
ClemensElflein 457319e
PlayMowSounds only if ROS is running as well as some minor (comment) …
Apehaenger b72f658
Minor code corrections
Apehaenger 5dce80d
Align HighLevel States and SubStates with ROS
Apehaenger 2287720
Simple HighLevelState class for easier handling of HighLevel-Mode and…
Apehaenger 3b6aaae
Tiny code adaptions and HighLevelState class usage
Apehaenger 23a3129
Add Docking advert and randomized background, move Darth-Vader backgr…
Apehaenger 37fbb70
Add Docking advert and background as well as some minor code adaptions
Apehaenger 7eb73d9
Merge commit '97629f8160853a00dcdcfed90c05e5cf490f190e' into feature/…
Apehaenger 8ad6504
Code review
Apehaenger c2ff588
Prepare background-sound option and small code corrections
Apehaenger dd050da
Transitional config packet & background sound option
Apehaenger 63a52c9
Merge main
Apehaenger 06f838e
Merge branch 'main' into feature/Improve-Sound
Apehaenger e540925
Restructure sound in OtherCore as well as Autoplay Detection
Apehaenger b9d135c
Restructured sound track naming and handling
Apehaenger fc034ab
LL/HL logic handling cleanup
Apehaenger 11a0abf
Add new DFPlayer clone, adapt some description
Apehaenger 3cef309
Fix comment
Apehaenger c24c859
Enable sound module @ HW 0.13.x
Apehaenger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Sound via "DFPlayer Mini" | ||
|
||
> **Warning** | ||
> Consider about switching your DFPlayer's VCC from 3.3V to 5V | ||
> (via solder jumper JP1 on your OpenMower MainBoard) | ||
|
||
**Explanation:**<br> | ||
I'm with sound since June 2023.<br> | ||
In the first month, I killed 2 Picos because his tiny Buck-Boost Converter "RT6150" cracked.<br> | ||
After a short correspondence with Clemens, he pointed me to the DFPlayer | ||
as a possible reason.<br> | ||
Because: By OM default design, the DFPlayer's VCC is 3.3V (via JP1), | ||
which is provided by the small Buck-Boost Converter on the Pico.<br> | ||
After I switched my DFPlayer's VCC to 5V (via JP1), I didn't lost any Pico anymore.<br> | ||
It's not confirmed yet if that really was the reason for my killed Pico's, | ||
and you're invited to validate the assumption by leaving your DFPlayer on 3.3V. **But be warned**, even if the Pico is cheap, it's awful to replace it! | ||
|
||
### Update 10/13/2023 | ||
|
||
As I was still in doubt if it's really necessary to switch DFPlayer's VCC to 5V, | ||
I did some measuring today: | ||
|
||
- Placed an 0.2Ω resistor (4W) within Pico's 3V3 output line | ||
- Measured with an oscilloscope the occuring voltage over the resistor:<br> | ||
0.028 V<sub>AVG</sub> => divided by 0.2Ω = 140mA => looks fine<br> | ||
0.195 V<sub>PP</sub> => divided by 0.2Ω = 975mA => hugh :-/ but this is V<sub>PP</sub>! | ||
- Within the Pico Datasheet it's written (somewhere), thats allowed to draw up to 300mA | ||
- The specs of the Buck-Boost Converter "RT6150" (used on the Pico) say:<br> | ||
"*Up to 800mA Continuous Output Current*", as well as<br> | ||
"*... current limit.*" | ||
|
||
End of October 2023, I discussed my doubts with Clemens and he answered: | ||
> The short peaks are also what worries me. The overcurrent protection will probably only take effect in the event of a longer overload. That's how you run it above the spec (even if for a short time) and that potentially breaks it at some point | ||
|
||
> **Important** | ||
> You may run `..._DFPIS5V` (to get full sound support), even if **not** switched to 5V, but we worry that you might kill your Pico's VREG on long time | ||
|
||
## Sound Buttons | ||
|
||
| Button<br>C500(B) | Button<br>RM-ECOW-V1.0.0 | Function | | ||
| ------ | -------- | --- | ||
| <kbd>Mon</kbd> | <kbd>4H</kbd> | Volume up | | ||
| <kbd>Tue</kbd> | <kbd>6H</kbd> | Volume down | ||
| <kbd>Wed</kbd> | <kbd>8H</kbd> | ~~Language switch (English, German)~~ | ||
|
||
## DFPlayer Module / Clones | ||
|
||
Beside the original [DFPlayer by DFRobot](https://www.dfrobot.com/product-1121.html) module, there are a couple of "DFPlayer-Mini" clones in the wild. | ||
|
||
If you order a "DFPlayer-Mini" by Amazon or the like, there's a >90% chance that you get one of these clones, instead of the original one. | ||
|
||
That's why I tried to adapt the code in that way, that some of these clones get also supported. | ||
|
||
Check the larger chip on the backside of the module, to verify if your DFPlayer is supported. The following DFPlayer chips are supported/tested at the moment: | ||
|
||
- `DFROBOT LISP3` is the one on my original [DFPlayer by DFRobot](https://www.dfrobot.com/product-1121.html) module | ||
- `MH2024K-24SS` which is one of the older clones | ||
- `GD3200B` is one of the newer clones, but partly fail in support | ||
|
||
The used DFPlayer library also indicate support for `YX5200-24SS` and `MH2024K-16SS`, but I couldn't test these by myself. If you've one of these, give it a try. | ||
|
||
## SD-Card | ||
|
||
Look like all DFPlayer support a SD-Card size up to 32GB. | ||
As we don't have a lot soundfiles (<10MB), choose the smallest one you can find, format it with a FAT32 file system (or if it's already formatted, remove all existing files) and copy all these [files and folder](./soundfiles/) to your SD-Card. | ||
|
||
### Folder/Track Structure | ||
|
||
Due to some incompatibilities with the libs and the clone chips, we unfortunately can't use DFPlayer's internal "advert" functionality for our usage. | ||
|
||
So we had to trick a little bit with the folder structure: | ||
|
||
- OM's old original sounds are now (partly) converted, translated, extended and reside now in a 2 digit, language specific subfolder. They're mainly 'advert' tracks as they're typically spoken adverts, which may interrupt background sounds like noises or music. | ||
- Folder 'mp3' contain background sounds (noises or music), which are hardcoded in the sources. | ||
- The single soundfile in the root folder, is used/required for (old/new) SD-Card-Structure detection, as well as for those DFPlayer types (i.e. DFRobot), | ||
which start autoplaying directly after power-on, or after reset().<br> | ||
You shouldn't change it, unless you take care that your replaced soundfile isn't shorter than the current one. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Created by Apehaenger on 02/02/23. | ||
// | ||
// This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. | ||
// | ||
// Feel free to use the design in your private/educational projects, but don't try to sell the design or products based on it without getting my consent first. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
// | ||
// | ||
#ifndef _DEBUG_H_ | ||
#define _DEBUG_H_ | ||
|
||
// Define to stream debugging messages via USB | ||
//#define USB_DEBUG | ||
#define DEBUG_PREFIX "" // You may define a debug prefix string | ||
|
||
#ifdef USB_DEBUG | ||
#define DEBUG_SERIAL Serial | ||
// #define DfMiniMp3Debug DEBUG_SERIAL // Also output DFPlayer IN/OUT cmd data | ||
|
||
// Some bloody simple debug macros which superfluous '#ifdef USB_DEBUG' ... | ||
#define DEBUG_BEGIN(b) \ | ||
DEBUG_SERIAL.begin(b); \ | ||
while (!DEBUG_SERIAL) \ | ||
; | ||
#define DEBUG_PRINTF(fmt, ...) \ | ||
do \ | ||
{ \ | ||
DEBUG_SERIAL.printf(DEBUG_PREFIX fmt, ##__VA_ARGS__); \ | ||
} while (0) | ||
#else | ||
#define DEBUG_BEGIN(b) | ||
#define DEBUG_PRINTF(fmt, ...) | ||
#endif | ||
|
||
#define PRINTF_BINARY_PATTERN_INT8 "%c%c%c%c%c%c%c%c" | ||
#define PRINTF_BYTE_TO_BINARY_INT8(i) \ | ||
(((i)&0x80ll) ? '1' : '0'), (((i)&0x40ll) ? '1' : '0'), (((i)&0x20ll) ? '1' : '0'), (((i)&0x10ll) ? '1' : '0'), \ | ||
(((i)&0x08ll) ? '1' : '0'), (((i)&0x04ll) ? '1' : '0'), (((i)&0x02ll) ? '1' : '0'), (((i)&0x01ll) ? '1' : '0') | ||
|
||
#endif // _DEBUG_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright 2024 Jörg Ebeling (Apehaenger) | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE.* Testing/examples for reading/writing flash on the RP2040. | ||
* | ||
* Heavily inspired, copied from, as well as must-read: | ||
* https://github.com/MakerMatrix/RP2040_flash_programming | ||
*/ | ||
|
||
#ifndef _NV_CONFIG_H | ||
#define _NV_CONFIG_H | ||
|
||
#include <Arduino.h> | ||
|
||
#ifdef ENABLE_SOUND_MODULE | ||
#include "soundsystem.h" | ||
#else | ||
#define VOLUME_DEFAULT 80 | ||
#endif | ||
|
||
#include "../src/datatypes.h" | ||
|
||
#define NV_CONFIG_MAX_SAVE_INTERVAL 60000UL // Don't save more often than once a minute | ||
|
||
// config_bitmask. Don't mistake with LL_HIGH_LEVEL_CONFIG_BIT. Similar, but not mandatory equal! | ||
#define NV_CONFIG_BIT_DFPIS5V 1 << 0 // DFP is set to 5V | ||
|
||
#define NV_RECORD_ID 0x4F4D4331 // Record struct identifier "OMC1" for future flexible length Record.config | ||
#define NV_RECORD_ALIGNMENT (_Alignof(uint32_t)) // Ptr alignment of Record.id for quick in memory access | ||
|
||
namespace nv_config { | ||
#pragma pack(push, 1) | ||
// This is where our application values should go. | ||
// It's possible to extended it, but any extension should add an extension related CRC so that an old/last stored Record.config isn't lost. | ||
// (a new extension-crc isn't valid with a old Record.config. Thus the new extension values may get set i.e. with default values) | ||
struct Config { | ||
// Config bitmask: | ||
// Bit 0: DFP is 5V (enable full sound). See NV_CONFIG_BIT_DFPIS5V | ||
uint8_t config_bitmask = 0; // Don't mistake with LL_HIGH_LEVEL_CONFIG_BIT. Similar, but not mandatory equal! | ||
uint8_t volume = VOLUME_DEFAULT; // Sound volume (0-100%) | ||
iso639_1 language = {'e', 'n'}; // Default to 'en' | ||
uint32_t rain_threshold = 700; // If (stock CoverUI) rain value < rain_threshold then it rains. Expected to differ between C500, SA and SC types | ||
|
||
/* Possible future config settings | ||
uint16_t free; // Future config setting | ||
uint16_t free_n; // Future config setting | ||
uint16_t crc_n; // Future config CRC16 (for the new member) for detection if loaded (possibly old) config already has the new member */ | ||
} __attribute__((packed)); | ||
|
||
// Record(s) get placed sequentially into a flash page. | ||
// The Record structure shouldn't get changed, because it would make old flash Record's unusable. Instead of, change Record.config | ||
struct Record { | ||
const uint32_t id = NV_RECORD_ID; // Fixed record identifier, used to identify a possible Record within a flash page. If width get changed, change also NV_RECORD_ALIGNMENT | ||
uint32_t num_sector_erase = 0; // For wear level stats | ||
uint32_t num_page_write = 0; // For informational purposes | ||
uint16_t crc; // Required to ensure that a found NV_RECORD_ID is really a Record | ||
Config config; | ||
} __attribute__((packed)); | ||
#pragma pack(pop) | ||
|
||
Config *get(); // Returned Config pointer hold the data of the last saved Record.config, or a default one. Config member are writable, see delayedSaveChanges() | ||
void delayedSaveChanges(); // Handle a possible changed nv_config::config member and save it to flash, but only within NV_CONFIG_MAX_SAVE_INTERVAL timeout for wear level protection | ||
|
||
} // namespace nv_config | ||
|
||
#endif // _NV_CONFIG_H |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't work anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed/noticed in my readme.
Will check about the official docs (fully outdated regarding the official docs because I still use the first ones).
We probably also need to notice somewhere, that "save to flash" happen only once a minute?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a while to get it running with Hugo. After I realized that docsys template is to old for recent Hugo versions, and downgraded to Hugo v0.110.0, all looks as expected (for me).
Integrated now all sound relevant infos to the official docs ClemensElflein/openmower.de#33.
Or do you notice anything wrong or missing?