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

Convert usermods to static libraries #4480

Draft
wants to merge 57 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
b8685f2
Convert usermods to static libraries
willmmiles Sep 14, 2024
4d5e0ca
load_usermods: Expand name search
willmmiles Jan 11, 2025
71b0e8e
Convert AnimARTrix usermod to library
willmmiles Jan 11, 2025
90b1815
Convert usermods from header to library
netmindz Jan 11, 2025
a5575bc
Fix naming of usermod files to match library name
netmindz Jan 11, 2025
6e76a72
Convert usermods from header to library
netmindz Jan 11, 2025
67022be
Build all usermods
netmindz Jan 11, 2025
cbed841
Include basic usermods in CI
netmindz Jan 11, 2025
c16d83f
Build custom_usermods = audioreactive auto_save animartrix
netmindz Jan 11, 2025
d64cedd
Build custom_usermods = audioreactive auto_save animartrix
netmindz Jan 11, 2025
2381e32
Define dependencies for ADS1115 usermod
netmindz Jan 11, 2025
79bac91
use bigger partitions for usermods env
netmindz Jan 11, 2025
d3eec72
Defining more usermod dependencies
netmindz Jan 12, 2025
3521732
fix env:userods
netmindz Jan 12, 2025
52b784e
fix env:usermods
netmindz Jan 12, 2025
52bee88
fix word_clock_matrix naming
netmindz Jan 12, 2025
075fd4d
Defining more usermod dependencies
netmindz Jan 12, 2025
4c19341
Merge branch 'usermod-libs-migration' of github.com:netmindz/WLED int…
netmindz Jan 12, 2025
8527d23
audioreactive: Move flags to library
willmmiles Jan 12, 2025
cc9e9b1
Fix usermod library builds
willmmiles Jan 12, 2025
f2626b0
Remove now-obsolete AR_build_flags
willmmiles Jan 12, 2025
24accf9
Remove now redundant build section from library.json
netmindz Jan 13, 2025
b380d5e
reinstate libArchive:false
netmindz Jan 14, 2025
2c9c413
Merge branch 'usermod-libs' into usermod-libs-migration
netmindz Jan 14, 2025
1dbd706
Revert LOROL_LITTLEFS hack
netmindz Jan 14, 2025
e471487
typo in usermods/sensors_to_mqtt/library.json
netmindz Jan 14, 2025
869e275
typo in usermods/sensors_to_mqtt/library.json
netmindz Jan 14, 2025
0b8721c
Fix usermod libArchive setting
willmmiles Jan 14, 2025
270d75a
Update usermod deps earlier
willmmiles Jan 14, 2025
8fd9052
Integrate usermods environment
willmmiles Jan 14, 2025
30559cd
Fix dependency for EleksTube_IPS usermod
willmmiles Jan 14, 2025
32607ee
Revert incorrect testing platformio.ini
willmmiles Jan 15, 2025
ef2eb07
Merge branch 'main' into usermod-libs
Jan 15, 2025
2adf745
Update env:usermods to use V4
Jan 15, 2025
5da380e
Update dependencies for sensors_to_mqtt
Jan 15, 2025
59a79a3
Add deps for usermods/BME280_v2
Jan 15, 2025
0afd2fe
Destructor must be public
Jan 15, 2025
5d05d79
Add usermod dependencies
Jan 15, 2025
8487dd7
Disable build of usermods that are broken at the moment
Jan 15, 2025
15edfcd
Fix usermod platformio integration
willmmiles Jan 16, 2025
193926c
usermods: Remove #pragma once from cpps
willmmiles Jan 17, 2025
2b07be1
usermod mpu6050: Fix incorrect int type
willmmiles Jan 19, 2025
44a1a1e
usermods: Fix MQTT checks
willmmiles Jan 19, 2025
48372bc
platformio: Fix audioreactive usermod for ESP8266
willmmiles Jan 19, 2025
0233dae
usermods/sensors_to_mqtt: Fix char type
willmmiles Jan 19, 2025
30a697e
usermods/PWM_fan: Disable pending cross-mod check
willmmiles Jan 19, 2025
1d558e8
platformio.ini: Add extra flags for usermod test
willmmiles Jan 19, 2025
0d44e7e
Usermods: Remove libArchive
willmmiles Jan 21, 2025
86f9761
platformio.ini: Fix esp32dev_V4 usermods
willmmiles Jan 31, 2025
5d392d8
load_usermods: Improve include path assembly
willmmiles Jan 31, 2025
4bc3408
load_usermods: Don't cross usermod includes
willmmiles Jan 31, 2025
a5b972d
Merge remote-tracking branch 'upstream/main' into usermod-libs
willmmiles Jan 31, 2025
51db63d
load_usermods: Also search for mod_v2
willmmiles Jan 31, 2025
851e9ec
Remove deprecated mqtt_switch_v2 usermod
willmmiles Jan 31, 2025
070b08a
Rename usermod EXAMPLE_v2 to EXAMPLE
willmmiles Jan 31, 2025
b3f9983
First half of usermod readme updates
willmmiles Jan 31, 2025
7a40ef7
Fix up PWM_fan
willmmiles Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions pio-scripts/load_usermods.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Import('env')
import os

def find_usermod(mod_dir: str, mod: str):
"""Locate this library in the usermods folder.
We do this to avoid needing to rename a bunch of folders;
this could be removed later
"""
# Check name match
mp = f"{mod_dir}/{mod}"
if os.path.exists(mp):
return mp
mp = f"{mod_dir}/usermod_v2_{mod}"
if os.path.exists(mp):
return mp
raise RuntimeError(f"Couldn't locate module {mod} in usermods directory!")

usermods = env.GetProjectOption("custom_usermods","")
if usermods:
proj = env.GetProjectConfig()
deps = env.GetProjectOption('lib_deps')
src_dir = proj.get("platformio", "src_dir")
src_dir = src_dir.replace('\\','/')
mod_paths = {mod: find_usermod(f"{src_dir}/../usermods", mod) for mod in usermods.split(" ")}
usermods = [f"{mod} = symlink://{path}" for mod, path in mod_paths.items()]
proj.set("env:" + env['PIOENV'], 'lib_deps', deps + usermods)
38 changes: 17 additions & 21 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ extra_scripts =
post:pio-scripts/output_bins.py
post:pio-scripts/strip-floats.py
pre:pio-scripts/user_config_copy.py
pre:pio-scripts/load_usermods.py
pre:pio-scripts/build_ui.py
; post:pio-scripts/obj-dump.py ;; convenience script to create a disassembly dump of the firmware (hardcore debugging)

Expand Down Expand Up @@ -165,13 +166,8 @@ lib_deps =
; https://github.com/adafruit/Adafruit_MAX1704X @ 1.0.2
#For MPU6050 IMU uncomment follwoing
;electroniccats/MPU6050 @1.0.1
# For -D USERMOD_ANIMARTRIX
# CC BY-NC 3.0 licensed effects by Stefan Petrick, include this usermod only if you accept the terms!
;https://github.com/netmindz/animartrix.git#18bf17389e57c69f11bc8d04ebe1d215422c7fb7
# SHT85
;robtillaart/SHT85@~0.3.3
# Audioreactive usermod
;kosme/arduinoFFT @ 2.0.1

extra_scripts = ${scripts_defaults.extra_scripts}

Expand Down Expand Up @@ -261,11 +257,11 @@ lib_deps =
https://github.com/lorol/LITTLEFS.git
https://github.com/pbolduc/AsyncTCP.git @ 1.2.0
${env.lib_deps}
# additional build flags for audioreactive
AR_build_flags = -D USERMOD_AUDIOREACTIVE
-D sqrt_internal=sqrtf ;; -fsingle-precision-constant ;; forces ArduinoFFT to use float math (2x faster)
AR_lib_deps = kosme/arduinoFFT @ 2.0.1
board_build.partitions = ${esp32.default_partitions} ;; default partioning for 4MB Flash - can be overridden in build envs
# additional build flags for audioreactive - must be applied globally
AR_build_flags = -D sqrt_internal=sqrtf ;; -fsingle-precision-constant ;; forces ArduinoFFT to use float math (2x faster)
AR_lib_deps = kosme/arduinoFFT @ 2.0.1 ;; for pre-usermod-library platformio_override compatibility
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are updating to be a library, why do we still need the old AR_lib_deps info as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compatibility with old platformio_override files that reference it. If we remove it, git pull breaks platformIO completely until you clean all references out of your overrides.

Copy link
Collaborator

@netmindz netmindz Jan 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If folk have platform_override that is trying to use AR, is having AR_build_flags that that doesn't have the old define just going to cause confusion? They will think they have the flags, but now that's not enough to actually enable

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this would be a breaking change that will need to be staged appropriately. Unfortunately if your platformio file is outright invalid, PlatformIO in VSCode doesn't tell you what's wrong, it just blankly refuses to operate with no error message. I found it more useful to at least keep the tool operating while I was correcting my build definitions, but that's just my $0.02.



[esp32_idf_V4]
;; experimental build environment for ESP32 using ESP-IDF 4.4.x / arduino-esp32 v2.0.5
Expand Down Expand Up @@ -424,23 +420,23 @@ build_flags = ${common.build_flags} ${esp8266.build_flags} -D WLED_RELEASE_NAME=
board = esp32dev
platform = ${esp32.platform}
platform_packages = ${esp32.platform_packages}
custom_usermods = audioreactive
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} ${esp32.build_flags} -D WLED_RELEASE_NAME=\"ESP32\" #-D WLED_DISABLE_BROWNOUT_DET
${esp32.AR_build_flags}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way to move the build_flags used for the usermod into it's library.json?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In most cases, yes.

In the specific case of AR, the build flags aren't actually for the AR module, they're for the FFT library dependency. Unfortunately, the only way to affect some dependent library's build is to do it at the project level. PlaformIO doesn't let one library define flags for one of its dependencies. https://community.platformio.org/t/setting-flags-defines-for-building-a-librarys-dependency/36744

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, maybe there is a way, using platformio hook scripts in the library. Working on it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are certainly usermods that use more typical build_flags that affect the usermod itself, but perhaps these still need to stay in the main platformio.ini if they are actual optional flags the user chooses to set

Copy link
Collaborator Author

@willmmiles willmmiles Jan 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed! It turns out there is a way though platformio hook scripts. 8527d23

lib_deps = ${esp32.lib_deps}
${esp32.AR_lib_deps}
monitor_filters = esp32_exception_decoder
board_build.partitions = ${esp32.default_partitions}

[env:esp32dev_8M]
board = esp32dev
platform = ${esp32_idf_V4.platform}
platform_packages = ${esp32_idf_V4.platform_packages}
custom_usermods = audioreactive
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} ${esp32_idf_V4.build_flags} -D WLED_RELEASE_NAME=\"ESP32_8M\" #-D WLED_DISABLE_BROWNOUT_DET
${esp32.AR_build_flags}
lib_deps = ${esp32_idf_V4.lib_deps}
${esp32.AR_lib_deps}
monitor_filters = esp32_exception_decoder
board_build.partitions = ${esp32.large_partitions}
board_upload.flash_size = 8MB
Expand All @@ -452,11 +448,11 @@ board_upload.maximum_size = 8388608
board = esp32dev
platform = ${esp32_idf_V4.platform}
platform_packages = ${esp32_idf_V4.platform_packages}
custom_usermods = audioreactive
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} ${esp32_idf_V4.build_flags} -D WLED_RELEASE_NAME=\"ESP32_16M\" #-D WLED_DISABLE_BROWNOUT_DET
${esp32.AR_build_flags}
lib_deps = ${esp32_idf_V4.lib_deps}
${esp32.AR_lib_deps}
monitor_filters = esp32_exception_decoder
board_build.partitions = ${esp32.extreme_partitions}
board_upload.flash_size = 16MB
Expand All @@ -468,11 +464,11 @@ board_build.flash_mode = dio
;board = esp32dev
;platform = ${esp32.platform}
;platform_packages = ${esp32.platform_packages}
;custom_usermods = audioreactive
;build_unflags = ${common.build_unflags}
;build_flags = ${common.build_flags} ${esp32.build_flags} -D WLED_RELEASE_NAME=\"ESP32_audioreactive\" #-D WLED_DISABLE_BROWNOUT_DET
; ${esp32.AR_build_flags}
;lib_deps = ${esp32.lib_deps}
; ${esp32.AR_lib_deps}
;monitor_filters = esp32_exception_decoder
;board_build.partitions = ${esp32.default_partitions}
;; board_build.f_flash = 80000000L
Expand All @@ -483,12 +479,12 @@ board = esp32-poe
platform = ${esp32.platform}
platform_packages = ${esp32.platform_packages}
upload_speed = 921600
custom_usermods = audioreactive
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} ${esp32.build_flags} -D WLED_RELEASE_NAME=\"ESP32_Ethernet\" -D RLYPIN=-1 -D WLED_USE_ETHERNET -D BTNPIN=-1
; -D WLED_DISABLE_ESPNOW ;; ESP-NOW requires wifi, may crash with ethernet only
${esp32.AR_build_flags}
lib_deps = ${esp32.lib_deps}
${esp32.AR_lib_deps}
board_build.partitions = ${esp32.default_partitions}

[env:esp32_wrover]
Expand All @@ -499,14 +495,14 @@ board = ttgo-t7-v14-mini32
board_build.f_flash = 80000000L
board_build.flash_mode = qio
board_build.partitions = ${esp32.extended_partitions}
custom_usermods = audioreactive
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} ${esp32_idf_V4.build_flags} -D WLED_RELEASE_NAME=\"ESP32_WROVER\"
-DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue ;; Older ESP32 (rev.<3) need a PSRAM fix (increases static RAM used) https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/external-ram.html
-D DATA_PINS=25
${esp32.AR_build_flags}
lib_deps = ${esp32_idf_V4.lib_deps}
${esp32.AR_lib_deps}


[env:esp32c3dev]
extends = esp32c3
platform = ${esp32c3.platform}
Expand All @@ -530,6 +526,7 @@ board_build.arduino.memory_type = qio_opi ;; use with PSRAM: 8MB or 16MB
platform = ${esp32s3.platform}
platform_packages = ${esp32s3.platform_packages}
upload_speed = 921600
custom_usermods = audioreactive
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S3_16MB_opi\"
-D CONFIG_LITTLEFS_FOR_IDF_3_2 -D WLED_WATCHDOG_TIMEOUT=0
Expand All @@ -538,7 +535,6 @@ build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=
-DBOARD_HAS_PSRAM
${esp32.AR_build_flags}
lib_deps = ${esp32s3.lib_deps}
${esp32.AR_lib_deps}
board_build.partitions = ${esp32.extreme_partitions}
board_upload.flash_size = 16MB
board_upload.maximum_size = 16777216
Expand All @@ -553,6 +549,7 @@ board_build.arduino.memory_type = qio_opi ;; use with PSRAM: 8MB or 16MB
platform = ${esp32s3.platform}
platform_packages = ${esp32s3.platform_packages}
upload_speed = 921600
custom_usermods = audioreactive
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S3_8MB_opi\"
-D CONFIG_LITTLEFS_FOR_IDF_3_2 -D WLED_WATCHDOG_TIMEOUT=0
Expand All @@ -561,7 +558,6 @@ build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=
-DBOARD_HAS_PSRAM
${esp32.AR_build_flags}
lib_deps = ${esp32s3.lib_deps}
${esp32.AR_lib_deps}
board_build.partitions = ${esp32.large_partitions}
board_build.f_flash = 80000000L
board_build.flash_mode = qio
Expand All @@ -575,6 +571,7 @@ platform_packages = ${esp32s3.platform_packages}
board = esp32s3camlcd ;; this is the only standard board with "opi_opi"
board_build.arduino.memory_type = opi_opi
upload_speed = 921600
custom_usermods = audioreactive
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S3_WROOM-2\"
-D CONFIG_LITTLEFS_FOR_IDF_3_2 -D WLED_WATCHDOG_TIMEOUT=0
Expand All @@ -587,7 +584,6 @@ build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=
${esp32.AR_build_flags}
-D SR_DMTYPE=1 -D I2S_SDPIN=13 -D I2S_CKPIN=14 -D I2S_WSPIN=15 -D MCLK_PIN=4 ;; I2S mic
lib_deps = ${esp32s3.lib_deps}
${esp32.AR_lib_deps}

board_build.partitions = ${esp32.extreme_partitions}
board_upload.flash_size = 16MB
Expand All @@ -600,6 +596,7 @@ board = lolin_s3_mini ;; -S3 mini, 4MB flash 2MB PSRAM
platform = ${esp32s3.platform}
platform_packages = ${esp32s3.platform_packages}
upload_speed = 921600
custom_usermods = audioreactive
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S3_4M_qspi\"
-DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=1 ;; for boards with USB-OTG connector only (USBCDC or "TinyUSB")
Expand All @@ -608,7 +605,6 @@ build_flags = ${common.build_flags} ${esp32s3.build_flags} -D WLED_RELEASE_NAME=
-D WLED_WATCHDOG_TIMEOUT=0
${esp32.AR_build_flags}
lib_deps = ${esp32s3.lib_deps}
${esp32.AR_lib_deps}
board_build.partitions = ${esp32.default_partitions}
board_build.f_flash = 80000000L
board_build.flash_mode = qio
Expand All @@ -621,6 +617,7 @@ board = lolin_s2_mini
board_build.partitions = ${esp32.default_partitions}
board_build.flash_mode = qio
board_build.f_flash = 80000000L
custom_usermods = audioreactive
build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} ${esp32s2.build_flags} -D WLED_RELEASE_NAME=\"ESP32-S2\"
-DARDUINO_USB_CDC_ON_BOOT=1
Expand All @@ -639,4 +636,3 @@ build_flags = ${common.build_flags} ${esp32s2.build_flags} -D WLED_RELEASE_NAME=
; -D STATUSLED=15
${esp32.AR_build_flags}
lib_deps = ${esp32s2.lib_deps}
${esp32.AR_lib_deps}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#pragma once

#include "wled.h"

Expand Down Expand Up @@ -2064,3 +2063,6 @@ const char AudioReactive::_digitalmic[] PROGMEM = "digitalmic";
const char AudioReactive::_addPalettes[] PROGMEM = "add-palettes";
const char AudioReactive::UDP_SYNC_HEADER[] PROGMEM = "00002"; // new sync header version, as format no longer compatible with previous structure
const char AudioReactive::UDP_SYNC_HEADER_v1[] PROGMEM = "00001"; // old sync header version - need to add backwards-compatibility feature

static AudioReactive ar_module;
REGISTER_USERMOD(ar_module);
17 changes: 17 additions & 0 deletions usermods/audioreactive/library.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "audioreactive",
"build": {
"srcDir": ".",
"includeDir": "../../wled00",
"libLDFMode": "chain+",
"libArchive": false
},
netmindz marked this conversation as resolved.
Show resolved Hide resolved
"dependencies": [
{
"owner": "kosme",
"name": "arduinoFFT",
"version": "2.0.1",
"platforms": "espressif32"
}
]
}
12 changes: 12 additions & 0 deletions usermods/usermod_v2_animartrix/library.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "animartrix",
"build": {
"srcDir": ".",
"includeDir": "../../wled00",
"libLDFMode": "chain+",
"libArchive": false
},
"dependencies": {
"Animartrix": "https://github.com/netmindz/animartrix.git#b172586"
}
}
6 changes: 1 addition & 5 deletions usermods/usermod_v2_animartrix/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@ CC BY-NC 3.0 licensed effects by Stefan Petrick, include this usermod only if yo

## Installation

Please uncomment the two references to ANIMartRIX in your platform.ini

lib_dep to a version of https://github.com/netmindz/animartrix.git
and the build_flags -D USERMOD_ANIMARTRIX

Add 'animartrix' to 'custom_usermods' in your platformio_override.ini.

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#pragma once

#include "wled.h"
#include <ANIMartRIX.h>

Expand Down Expand Up @@ -452,5 +450,6 @@ class AnimartrixUsermod : public Usermod {

};


static AnimartrixUsermod animartrix_module("Animartrix", false);
REGISTER_USERMOD(animartrix_module);

8 changes: 8 additions & 0 deletions usermods/usermod_v2_auto_save/library.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "auto_save",
"build": {
"srcDir": ".",
"includeDir": "../../wled00",
"libLDFMode": "chain+"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,6 @@ const char AutoSaveUsermod::_autoSaveEnabled[] PROGMEM = "enabled";
const char AutoSaveUsermod::_autoSaveAfterSec[] PROGMEM = "autoSaveAfterSec";
const char AutoSaveUsermod::_autoSavePreset[] PROGMEM = "autoSavePreset";
const char AutoSaveUsermod::_autoSaveApplyOnBoot[] PROGMEM = "autoSaveApplyOnBoot";

static AutoSaveUsermod autosave;
REGISTER_USERMOD(autosave);
11 changes: 4 additions & 7 deletions wled00/fcn_declare.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class Usermod {
protected:
um_data_t *um_data; // um_data should be allocated using new in (derived) Usermod's setup() or constructor
public:
Usermod() { um_data = nullptr; }
Usermod() : um_data(nullptr) {};
virtual ~Usermod() { if (um_data) delete um_data; }
virtual void setup() = 0; // pure virtual, has to be overriden
virtual void loop() = 0; // pure virtual, has to be overriden
Expand Down Expand Up @@ -418,8 +418,6 @@ class Usermod {
};

namespace UsermodManager {
extern byte numMods;

void loop();
void handleOverlayDraw();
bool handleButton(uint8_t b);
Expand All @@ -441,13 +439,12 @@ namespace UsermodManager {
#endif
void onUpdateBegin(bool);
void onStateChange(uint8_t);
bool add(Usermod* um);
Usermod* lookup(uint16_t mod_id);
inline byte getModCount() {return numMods;};
size_t getModCount();
};

//usermods_list.cpp
void registerUsermods();
// Register usermods by building a static list via a linker section
#define REGISTER_USERMOD(x) Usermod* const um_##x __attribute__((__section__(".dtors.tbl.usermods.1"), used)) = &x

//usermod.cpp
void userSetup();
Expand Down
Loading
Loading