Skip to content
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

Open
wants to merge 64 commits into
base: main
Choose a base branch
from

Conversation

Apehaenger
Copy link
Contributor

@Apehaenger Apehaenger commented Nov 8, 2023

Think this is how it can be done.

This PR mainly:

  • Switch to Makuna's DFMiniMp3 lib for a better support of DFPlayer clones
  • Adds a couple of advert and background sounds
  • Support volume control and language switch (English and German) via CoverUI (but will not save it at the moment)

SD-Card Structure Problem (old/new sound implementation):

I assumed that >90% of the installations in the wild, will have the original DFRobot DFPlayer with the old SD-Card-Structure installed.
Because DFRobot's DFPlayer has the quirk to auto-play the first sound in SD-Cards root, after a reset(), I detect an old SD-Card-Structure in that way, that if there's an auto-played sound with a specific length (shorter than the one of the new SD-Card-Structure) then it's identified as "old SD-Card-Structure". For sure, this works only for those who have an DFRobot DFPlayer.

This (shall) result in the following behavior (tested with a couple of DFPlayer and SD-Cards):

DFPlayer SD-Card-Structure Plays
DFRobot old "Hi", krk, "Hi, I'm Steve ...". No further sound output
DFRobot new "Ping" (3-5 times), "Hi I'm Steve ...". No further sound output

Overcurrent problem on 3.3V (Pico) line

All current OM installation (with sound) already play "Hi", krk, "Hi, I'm Steve ..." and we haven't heard of died Pico (VREG) till now.
So this sound PR also stop (by default) after "Hi, I'm Steve ...", except it got compiled with DFPIS5V (already added to CI firmware build)
For sure this doubles our firmware binaries :-/ But does it matter?

Warning
Of course, everybody is free to install a DFPIS5V firmware without changing his DFPlayer to 5V, but we should expect that he has read README-Sound, DFPIS5V.md before, and knows about the risk

firmware.zip

@Apehaenger
Copy link
Contributor Author

Apehaenger commented Mar 31, 2024

Did a quick look to open_mower_ros for this sound + #84 PR integration.
Doesn't look very complicated.

  1. I could add a ll_config struct with i.e. 'dfp_is_5v' as well as a 'language' member (ll_datatypes.h & mower_comms.cpp) and let him fire the packet i.e. once a second
  2. Mod openmower FW in that way that
    1. a received ll_config member get stored in flash
    2. Emergency only get released once there's a valid config stored

But I've some questions/doubts:

  1. Once LL FW has a valid config stored, it wouldn't wait for a ll_config packet again and play sound immediately (with the option that an ll_config get received which disabled sound again via dfp_is_5v=false
  2. Wouldn't it be better if LL FW request HL for an ll_config packet instead of cyclic send by HL?

@Apehaenger
Copy link
Contributor Author

Yes exactly, I thought about a configuration packet where we can set key/value pairs. LL board shall store the configuration and only allow to exit emergency once it has some valid configuration.

Just checked how to implement ClemensElflein/open_mower_ros#79 in LowLevel code.
Think we shouldn't lock in emergency due to our latest discussion about packet (backward) compatibility.
In addition my current ClemensElflein/open_mower_ros#79 implementation will be somehow fragile when i.e. flashing pico with a running open_mower_ros. In special if someone change to DFPIS5V=false and flashes Pico afterwards. He wouldn't get a config packet but would use the old flash-stored configuration probably with a previous DFPIS5V=true!

Think we either need a cyclic send (i.e. 1-10s) config packet from HL side, or a separate "getConfig" packet from LL which request HL to send the config packet.
I personally would prefer the cyclic send config packet, because it would give us easier possibility to change settings on the fly (some when)

@Apehaenger Apehaenger marked this pull request as draft April 7, 2024 19:56
@Apehaenger
Copy link
Contributor Author

Merged all together now.
Did a couple of tests:

  • All mower_config configurations
  • Both languages
  • Config storage into flash
  • Config read from flash storage on reboot
  • Validated nv_config's sector_erase as well as page_write's for not wear level flash

Look all fine and it's working on my desktop.
If weather is good on Sunday, I'll do some final practice tests.

Please take into account that the following PR is also needed: ClemensElflein/open_mower_ros#80

If interested in a quick test, binaries are already available in my fork: https://github.com/Apehaenger/OpenMower/releases/tag/latest

@Apehaenger Apehaenger marked this pull request as ready for review April 12, 2024 21:55
@Apehaenger
Copy link
Contributor Author

Just started a real practice test on my SA type mower. All looks working as expected. Don't see any issues.

| ------ | -------- | ---
| <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)~~
Copy link
Owner

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

Copy link
Contributor Author

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?

Copy link
Contributor Author

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?

@ClemensElflein
Copy link
Owner

before merging we should mention the "the player just plays everything"-issue somewhere (missing resistors in 0.13 kit); also if there is a guide somewhere we should mention those resistors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants