Skip to content
Snippets Groups Projects
Commit 984c66b5 authored by Jens Nolte's avatar Jens Nolte
Browse files

Make status LED configurable (disabled by default)

parent 0848b552
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,10 @@
#define IO_TAG "IO"
#define ESP_INTR_FLAG_DEFAULT 0
#define STATUS_LED_PIN GPIO_NUM_2
bool status_led_enabled = false;
bool status_led_negated = false;
gpio_num_t status_led_gpio;
#define DEBOUNCE_MILLIS 10
const TickType_t debounce_delay_ticks = std::max(DEBOUNCE_MILLIS / portTICK_PERIOD_MS, (TickType_t) 1);
......@@ -140,8 +143,17 @@ void add_button(gpio_num_t gpio, std::string topic, std::string message) {
add_button(gpio, [topic, message](){ publish_message(topic, message); });
}
void enable_status_led(gpio_num_t gpio, bool negated) {
gpio_init_output(gpio, true);
status_led_gpio = gpio;
status_led_enabled = true;
status_led_negated = negated;
}
void set_status_led(uint32_t level) {
ESP_ERROR_CHECK(gpio_set_level(STATUS_LED_PIN, level));
if (status_led_enabled) {
ESP_ERROR_CHECK(gpio_set_level(status_led_gpio, level ^ status_led_negated));
}
}
void gpio_init_output(gpio_num_t gpio_num, uint32_t level) {
......
......@@ -35,6 +35,9 @@ typedef struct {
typedef std::function<void(ota_event_t)> ota_event_callback_t;
// core
void enable_status_led(gpio_num_t gpio = GPIO_NUM_2, bool negated = false);
// network
void enable_wlan();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment