-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathactuator_ledbuiltin.cpp
43 lines (34 loc) · 1.6 KB
/
actuator_ledbuiltin.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
Turn the built in LED on or off
Required from .h: ACTUATOR_LEDBUILTIN_PIN
Optional: ACTUATOR_LEDBUILTIN_DEBUG ACTUATOR_LEDBUILTIN_BRIGHTNESS
Optional: BUILTIN_LED LED_BUILTIN RGB_BUILTIN - set on various boards
For reference the LED is on the following pins for boards we have been working with ....
Sonoff: 13
*/
#include "_settings.h" // Settings for what to include etc
#ifdef ACTUATOR_LEDBUILTIN_WANT
#include <Arduino.h>
#include "actuator_ledbuiltin.h"
#include "actuator_digital.h"
#include "system_mqtt.h"
#include "system_discovery.h"
#ifdef LOLIN_C3_PICO
#ifndef ACTUATOR_LEDBUILTIN_BRIGHTNESS
#define ACTUATOR_LEDBUILTIN_BRIGHTNESS 64
#endif
#endif // LOLIN_C3_PICO
Actuator_Ledbuiltin::Actuator_Ledbuiltin(const uint8_t p, const char* topic) : Actuator_Digital(p, topic) { }
void Actuator_Ledbuiltin::act() {
#ifdef RGB_BUILTIN // Lolon C3 doesnt have RGB_BUILTIN defined so digitalWrite doesnt work correctly
#error Unclear to me if boards with RGB_BUILTIN shoul used the neopixelwrie or digitalWrite (with latter doing a neopixelwrite)
#endif
// TO_ADD_BOARD if the board's built in LED is RGB then add to the definition in the next line
#if defined(LOLIN_C3_PICO)
const uint8_t brightness = value ? ACTUATOR_LEDBUILTIN_BRIGHTNESS : 0;
rgbLedWrite(ACTUATOR_LEDBUILTIN_PIN,brightness,brightness,brightness); // Note this is r,g,b (Neopixel is g r b on Lolin)
#else // LOLIN_C3_PICO
digitalWrite(ACTUATOR_LEDBUILTIN_PIN, value ? LOW : HIGH); // LED pin is inverted, at least on Lolin D1 Mini
#endif // LOLIN_C3_PICO
}
#endif // ACTUATOR_LEDBUILTIN_WANT