Call presets internally from usermod.cpp

Hi,

How one can call presets from the the usermod.cpp?

My plan is to install WLED in a car and control it via few switches. I’ll create a binary from few switches so I can select them to create numbers 0-15 basically. Zero being turned off. Then the combination of switches will put the WLED in specified preset. I can use the access point with phone to modify the presets but the switches on car I’ll use to control WLED.

I’m not a super good programmer. I coudn’t figure this out by reading the code.
I only managed to do this with a scripts e.g. “http://192.168.2.162/win&PL=2”. But needs to work in the car without internet (and second device to make GET requests).

Someone has already made a version that supports three switches. That should be able to be expanded.

Switch part is easy for me but calling the presets I don’t understand. Or if it is possible from usermod.

I bet someone has made most of the variations average user is going to use. Hard part is to find those to take example.

1 Like

There is a function for this in WLED:
bool applyPreset(byte index, bool loadBri)
The first parameter ist the preset number, the second is optional and defines if the brightness from the preset is loaded or not. The function returns true on successful preset load and false otherwise.

Awesome! Thanks!