forked from wled/WLED
-
-
Notifications
You must be signed in to change notification settings - Fork 134
M5Stack Core S3 Audio Display #364
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
Open
troyhacks
wants to merge
8
commits into
MoonModules:mdev
Choose a base branch
from
troyhacks:M5Stack_Core_S3_Display
base: mdev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8006cb5
S3 LTO Script
troyhacks 986a0ad
Merge branch 'MoonModules:mdev' into mdev
troyhacks 4bd5960
Initial version for submission - needs fixes.
troyhacks 4ae70a4
Fixes after audit, improved docs.
troyhacks b1feafa
Docs update
troyhacks 208c1e9
Rabbit Droppings
troyhacks 365a7b1
Fixes to LTO script, not really related to the overall PR
troyhacks b9ea1b1
null fixes
troyhacks 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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,72 @@ | ||
| #!/usr/bin/env python3 | ||
| """ | ||
| Enable Link Time Optimization (LTO) for PlatformIO / Xtensa ESP32-S3 builds. | ||
|
|
||
| Simply adding -flto to build_flags is not sufficient: LTO also requires the | ||
| linker to receive -flto and the archiver/ranlib to be the GCC-LTO-aware | ||
| variants (gcc-ar / gcc-ranlib). This script wires all three up so that the | ||
| flag is consistently applied and the static-library archives are built in a | ||
| way that LTO can see through them. | ||
| """ | ||
| ## This script was created with the help of an AI, reviewed by @troyhacks | ||
|
|
||
| Import("env") | ||
| import os | ||
| import shutil | ||
|
|
||
| def _find_tool(name, cc_dir): | ||
| """Locate a toolchain binary: check cc_dir first, then PATH.""" | ||
| if cc_dir: | ||
| for suffix in ("", ".exe"): | ||
| candidate = os.path.join(cc_dir, name + suffix) | ||
| if os.path.isfile(candidate): | ||
| return candidate | ||
| # Fall back to searching PATH | ||
| return shutil.which(name) | ||
|
|
||
| def enable_lto(env): | ||
| # -flto: LTO itself. | ||
| # -fipa-pta: interprocedural pointer analysis — requires whole-program IR, only useful with LTO. | ||
| # -ffunction-sections / -fdata-sections / -Wl,--gc-sections: linker dead-code elimination; | ||
| # far more effective with LTO because the linker has cross-TU visibility. | ||
| LTO_CCFLAGS = ["-flto", "-fipa-pta", "-ffunction-sections", "-fdata-sections"] | ||
| LTO_LDFLAGS = ["-flto", "-Wl,--gc-sections"] | ||
|
|
||
| for flaglist, new_flags in (("CCFLAGS", LTO_CCFLAGS), | ||
| ("CXXFLAGS", LTO_CCFLAGS), | ||
| ("LINKFLAGS", LTO_LDFLAGS)): | ||
| existing = env.get(flaglist, []) | ||
| to_add = [f for f in new_flags if f not in existing] | ||
| if to_add: | ||
| env.Append(**{flaglist: to_add}) | ||
|
|
||
| # Swap ar / ranlib for the LTO-aware GCC wrappers so that static | ||
| # library archives carry IR that the linker can optimise across. | ||
| cc = str(env.get("CC", "")) | ||
| if cc: | ||
| toolchain_prefix = cc.replace("gcc", "").replace("g++", "") | ||
| # toolchain_prefix is something like "xtensa-esp32s3-elf-" | ||
| new_ar = toolchain_prefix + "gcc-ar" | ||
| new_ranlib = toolchain_prefix + "gcc-ranlib" | ||
|
|
||
| # Resolve CC to its real path so we can search the same directory | ||
| cc_resolved = shutil.which(cc) or cc | ||
| cc_dir = os.path.dirname(cc_resolved) | ||
|
|
||
| ar_path = _find_tool(new_ar, cc_dir) | ||
| if ar_path: | ||
| env.Replace(AR=ar_path) | ||
| print(f"enable_lto: AR -> {ar_path}") | ||
| else: | ||
| print(f"enable_lto: gcc-ar '{new_ar}' not found, keeping default AR") | ||
|
|
||
| ranlib_path = _find_tool(new_ranlib, cc_dir) | ||
| if ranlib_path: | ||
| env.Replace(RANLIB=ranlib_path) | ||
| print(f"enable_lto: RANLIB -> {ranlib_path}") | ||
| else: | ||
| print(f"enable_lto: gcc-ranlib '{new_ranlib}' not found, keeping default RANLIB") | ||
|
|
||
| print("enable_lto: -flto added to CCFLAGS / CXXFLAGS / LINKFLAGS") | ||
|
|
||
| enable_lto(env) |
This file contains hidden or 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,63 @@ | ||
| # M5Stack Core S3 Display Usermod | ||
|
|
||
| Display usermod for the ILI9342C 320x240 TFT display on the M5Stack Core S3, using LovyanGFX. | ||
|
|
||
| ## Pin Mapping (M5Stack Core S3) | ||
|
|
||
| | ESP32-S3 | ILI9342C | Description | | ||
| |----------|----------|-----------------| | ||
| | G37 | MOSI | SPI Data | | ||
| | G36 | SCLK | SPI Clock | | ||
| | G3 | CS | Chip Select | | ||
| | G35 | DC | Data/Command | | ||
|
|
||
| Reset is controlled via the AW9523B GPIO expander (P1_1). Backlight is powered via AXP2101 PMU (DLDO1). | ||
|
|
||
| ## Building | ||
|
|
||
| In `platformio_override.ini` for your M5Stack Core S3 environment: | ||
|
|
||
| ```build_flags = | ||
| -D USERMOD_M5STACK_CORE_S3_DISPLAY | ||
| ;; For the M5Stack ModuleAudio: | ||
| -D SR_ENABLE_DEFAULT | ||
| -D SR_DMTYPE=6 | ||
| -D I2S_SDPIN=13 | ||
| -D I2S_WSPIN=6 | ||
| -D I2S_CKPIN=0 | ||
| -D MCLK_PIN=7 | ||
| -D HW_SDA_PIN=12 | ||
| -D HW_SCL_PIN=11 | ||
|
|
||
| lib_deps = | ||
| https://github.com/lovyan03/LovyanGFX``` | ||
|
|
||
| ## Features | ||
|
|
||
| - SSID and IP address in header bar | ||
| - 16-band graphic equalizer bars (differential drawing) | ||
| - Real audio reactive data when Audioreactive usermod is enabled | ||
| - Simulated bouncing bars when no audio data | ||
| - Rainbow color per bar (red → violet) | ||
| - Maximum of 100 FPS to match AudioReactive | ||
| - Minimum of 5 FPS so it updates even if you use unlimited FPS mode. | ||
|
|
||
| ## Display Notes | ||
|
|
||
| - Uses LovyanGFX with `SPI3_HOST` (HSPI) | ||
| - Native landscape 320x240 resolution | ||
| - BGR color order, display inversion enabled | ||
| - Backlight always on (controlled by AXP2101 DLDO1) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| ## TroyHacks Recommended AudioReactive Settings | ||
|
|
||
| For the M5Stack Core S3 + ModuleAudio line-in: | ||
|
|
||
| - The ModuleAudio uses an ES8388 | ||
| - Squelch & Gain at 1 | ||
| - AGC is Normal | ||
| - MicLev is Freeze | ||
| - Mic Quality is Perfect | ||
| - FFT Window is Nutall (or whatever you prefer) | ||
| - Profile is Generic Line-In | ||
| - Limiter is Enabled, with a rise of 1 and a fall of 250 (to 500). | ||
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.
Uh oh!
There was an error while loading. Please reload this page.