LED - xoseperez/espurna GitHub Wiki
ESPurna build-time configuration supports up to 8 connected LEDs to various GPIO pins. These LEDs are defined using C preprocessor flag LEDx_PIN
(x being a number from 1 to 8). Some LEDs might be onboard, and you might have the option of connecting some additional, depending on the board you are using.
Key | Description | Possible values | Default value |
---|---|---|---|
ledGPIO# | GPIO pin to use for the n-th LED | 0-5, 12-15, (also, 9 and 10 when the board is ESP8266) | GPIO_NONE (153) |
ledInv# | 1 to keep GPIO LOW when LED is ON and HIGH when LED is OFF, 0 for the opposite | 0 | |
ledMode# | Behavior for the n-th LED | One of the LED modes defined in types.h (see below) | LED_MODE_WIFI for the first LED, LED_MODE_MANUAL for the rest |
ledRelay# | Relay to use, when mode is set to either LED_MODE_FINDME_WIFI, LED_MODE_RELAY_WIFI, LED_MODE_FOLLOW, LED_MODE_FOLLOW_INVERSE or LED_MODE_RELAY | LED_MODE_MANUAL | |
ledPattern# | Pattern to use when LED is ON | See below | Not set |
Command | Description |
---|---|
led |
shows all configured led(s) |
led <ID> |
shows n-th led configuration options |
led <ID> <PATTERN> |
force n-th led into a manual mode and execute the specified pattern |
Each LED can be bound to a relay state (see below), or operate in one of the following modes, defined by LED#_MODE
As defined in the code/espurna/config/types.h:
-
LED_MODE_MANUAL
(0) LED will be managed manually and will be set to OFF by default -
LED_MODE_WIFI
(1) LED will blink according to the WIFI status -
LED_MODE_FOLLOW
(2) LED will follow state of linked LED#_RELAY relay ID -
LED_MODE_FOLLOW_INVERSE
(3) LED will follow the opposite state of linked LED#_RELAY relay ID -
LED_MODE_FINDME
(4) LED will be ON if all relays are OFF -
LED_MODE_FINDME_WIFI
(5) A mixture between WIFI and FINDME, using inverse patterns when relays is ON -
LED_MODE_ON
(6) LED always ON -
LED_MODE_OFF
(7) LED always OFF -
LED_MODE_RELAY
(8) If any relay is ON, LED will be ON, otherwise OFF -
LED_MODE_RELAY_WIFI
(9) A mixture between WIFI and RELAY, reverse of FINDME
When LED should be turned ON (by a specific mode or manually), we can override this behaviour by making it blink in a certain pattern. For example, with the following configuration:
"ledGPIO0" => "5"
"ledMode0" => "0"
"ledPattern0" => "500,500,10 100,100,0"
After sending "1" to the '{root topic}/led/0/set', GPIO5 will switch from ON to OFF every 500 ms exactly 10 times and will continue to be switched ON and OFF every 100 ms after that. After sending "0", LED will be turned OFF and stop the pattern.
Pattern format is {ON delay},{OFF delay},{repeats}
, the ledPattern#
value can contain multiple patterns separated by space:
-
{ON delay}
and{OFF delay}
are set in milliseconds and the longest possible delay is 25 seconds -
{repeats}
is the number of times LED will be switched from ON to OFF (using{delayOn}
and{delayOff}
times)
Patterns are read left-to-right, until the end of the string. If {repeats}
value is 0
, current pattern will be repeated indefenetly, until the LED is turned OFF manually. If {repeats}
value is greater than 0
, LED will switch to subsequent pattern or keep the GPIO in the default state.
For example, this setting will cause the LED to switch from ON to OFF every 200 milliseconds. 2nd pattern will not be used, because the first one {repeats}
value is set to 0
:
"ledPattern0" => "200,200,0 100,100,10"