WLED/usermods/usermod_rotary_brightness_color/README.md
Louis Beaudoin 8c44147a45
Usermod Settings polishing/documentation (#2061)
* Testing new wrapper functions to read Usermod config

* Usermod Settings polishing
- remove getBoolFromJsonKey() (no longer needed), fix getValueFromJsonKey(element, destination, defaultvalue)
- Update Usermod Settings html "number" field to use step="any", and make wider to make maximum values fully visible
  - step="any" allows viewing/submitting full 7/8-digit float values, and the arrow buttons step by 1 now, instead of .00001 (which wasn't good for integers or floats)
  - html wasn't generated/compressed yet

* Update usermod_v2_example.h with more complete example and documentation for Usermod Settings
- readFromConfig() has three options for how to load values from the config JSON, we need to pick one

* Update/rename usermode_rotary_brightness_color, to be used as an example of more robust parsing Usermod Settings values

* Update Usermod example, rename getValueFromJsonKey() to getJsonValue()
- chose single readFromConfig() pattern
- demonstrating 3-argument getJsonValue()
- remove leftover printf in getJsonValue()

Co-authored-by: Louis Beaudoin <louis@embedded-creations.com>
2021-07-05 23:14:57 +02:00

1.7 KiB

Rotary Encoder (Brightness and Color)

V2 usermod that allows changing brightness and color using a rotary encoder, change between modes by pressing a button (many encoders have one included)

but it will wait for AUTOSAVE_SETTLE_MS milliseconds, a "settle" period in case there are other changes (any change will extend the "settle" window).

It will additionally load preset AUTOSAVE_PRESET_NUM at startup. during the first loop(). Reasoning below.

AutoSaveUsermod is standalone, but if FourLineDisplayUsermod is installed, it will notify the user of the saved changes.

Note: I don't love that WLED doesn't respect the brightness of the preset being auto loaded, so the AutoSaveUsermod will set the AUTOSAVE_PRESET_NUM preset in the first loop, so brightness IS honored. This means WLED will effectively ignore Default brightness and Apply N preset at boot when the AutoSaveUsermod is installed.

Installation

define USERMOD_ROTARY_ENCODER_BRIGHTNESS_COLOR e.g.

#define USERMOD_ROTARY_ENCODER_BRIGHTNESS_COLOR in my_config.h

or add -D USERMOD_ROTARY_ENCODER_BRIGHTNESS_COLOR to build_flags in platformio_override.ini

Define Your Options

Open Usermod Settings in WLED to change settings:

fadeAmount - how many points to fade the Neopixel with each step of the rotary encoder (default 5) pin[3] - pins to connect to the rotary encoder:

  • pin[0] is pin A on your rotary encoder
  • pin[1] is pin B on your rotary encoder
  • pin[2] is the button on your rotary encoder (optional, set to -1 to disable the button and the rotary encoder will control brightness only)

PlatformIO requirements

No special requirements.

Change Log

2021-07

  • Upgraded to work with the latest WLED code, and make settings configurable in Usermod Settings