Lolin C3 mini v1.0 has standard led.

This commit is contained in:
MichaelDvP
2022-10-13 14:07:52 +02:00
parent 2c7eeeca7b
commit 9be13eb0b9
2 changed files with 29 additions and 15 deletions

View File

@@ -75,7 +75,7 @@ void NetworkSettingsService::manageSTA() {
esp_wifi_set_max_tx_power(networkSettings.tx_power * 4); // set power after wifi is startet for C3 esp_wifi_set_max_tx_power(networkSettings.tx_power * 4); // set power after wifi is startet for C3
}); });
#ifdef BOARD_C3_MINI_V1 #ifdef BOARD_C3_MINI_V1
// not sure if we need this special value for c3_min_v1.0 // v1 needs this value, see https://github.com/emsesp/EMS-ESP32/pull/620#discussion_r993173979
WiFi.setTxPower(WIFI_POWER_8_5dBm); // https://www.wemos.cc/en/latest/c3/c3_mini_1_0_0.html#about-wifi WiFi.setTxPower(WIFI_POWER_8_5dBm); // https://www.wemos.cc/en/latest/c3/c3_mini_1_0_0.html#about-wifi
#endif #endif
} }

View File

@@ -38,7 +38,7 @@
#include "../rom/rtc.h" #include "../rom/rtc.h"
#endif #endif
#endif #endif
#ifdef ARDUINO_LOLIN_C3_MINI #if defined(ARDUINO_LOLIN_C3_MINI) && !defined(BOARD_C3_MINI_V1)
#include <Adafruit_NeoPixel.h> #include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel pixels(1, 7, NEO_GRB + NEO_KHZ800); Adafruit_NeoPixel pixels(1, 7, NEO_GRB + NEO_KHZ800);
#endif #endif
@@ -459,14 +459,14 @@ void System::led_init(bool refresh) {
} }
if ((led_gpio_ != 0) && is_valid_gpio(led_gpio_)) { if ((led_gpio_ != 0) && is_valid_gpio(led_gpio_)) {
#ifdef ARDUINO_LOLIN_C3_MINI #if defined(ARDUINO_LOLIN_C3_MINI) && !defined(BOARD_C3_MINI_V1)
// rgb LED WS2812B, use Adafruit Neopixel // rgb LED WS2812B, use Adafruit Neopixel
// Adafruit_NeoPixel pixels(1, 7, NEO_GRB + NEO_KHZ800); // Adafruit_NeoPixel pixels(1, 7, NEO_GRB + NEO_KHZ800);
pixels.begin(); pixels.begin();
pixels.setPin(led_gpio_); pixels.setPin(led_gpio_);
// pixels.setBrightness(0); // pixels.setBrightness(0);
pixels.Color(0, 0, 0, 0); // pixels.Color(0, 0, 0, 0);
pixels.show(); // pixels.show();
#else #else
pinMode(led_gpio_, OUTPUT); // 0 means disabled pinMode(led_gpio_, OUTPUT); // 0 means disabled
digitalWrite(led_gpio_, !LED_ON); // start with LED off digitalWrite(led_gpio_, !LED_ON); // start with LED off
@@ -661,7 +661,7 @@ void System::system_check() {
if (healthcheck_ == 0) { if (healthcheck_ == 0) {
// everything is healthy, show LED permanently on or off depending on setting // everything is healthy, show LED permanently on or off depending on setting
if (led_gpio_) { if (led_gpio_) {
#ifdef ARDUINO_LOLIN_C3_MINI #if defined(ARDUINO_LOLIN_C3_MINI) && !defined(BOARD_C3_MINI_V1)
pixels.setPixelColor(0, 0, hide_led_ ? 0 : 128, 0); pixels.setPixelColor(0, 0, hide_led_ ? 0 : 128, 0);
pixels.show(); pixels.show();
#else #else
@@ -672,7 +672,7 @@ void System::system_check() {
} else { } else {
// turn off LED so we're ready to the flashes // turn off LED so we're ready to the flashes
if (led_gpio_) { if (led_gpio_) {
#ifdef ARDUINO_LOLIN_C3_MINI #if defined(ARDUINO_LOLIN_C3_MINI) && !defined(BOARD_C3_MINI_V1)
pixels.setPixelColor(0, 0, 0, 0); pixels.setPixelColor(0, 0, 0, 0);
pixels.show(); pixels.show();
#else #else
@@ -738,7 +738,7 @@ void System::led_monitor() {
// Serial.println("resetting flash check"); // Serial.println("resetting flash check");
led_long_timer_ = uuid::get_uptime(); led_long_timer_ = uuid::get_uptime();
led_flash_step_ = 0; led_flash_step_ = 0;
#ifdef ARDUINO_LOLIN_C3_MINI #if defined(ARDUINO_LOLIN_C3_MINI) && !defined(BOARD_C3_MINI_V1)
pixels.setPixelColor(0, 0, 0, 0); pixels.setPixelColor(0, 0, 0, 0);
pixels.show(); pixels.show();
#else #else
@@ -750,6 +750,24 @@ void System::led_monitor() {
// 2 flashes if the network (wifi or ethernet) is not connected // 2 flashes if the network (wifi or ethernet) is not connected
// 3 flashes is both the bus and the network are not connected. Then you know you're truly f*cked. // 3 flashes is both the bus and the network are not connected. Then you know you're truly f*cked.
#if defined(ARDUINO_LOLIN_C3_MINI) && !defined(BOARD_C3_MINI_V1)
if (led_flash_step_ == 3) {
if ((healthcheck_ & HEALTHCHECK_NO_NETWORK) == HEALTHCHECK_NO_NETWORK) {
pixels.setPixelColor(0, 128, 0, 0); // red
} else if ((healthcheck_ & HEALTHCHECK_NO_BUS) == HEALTHCHECK_NO_BUS) {
pixels.setPixelColor(0, 0, 0, 128); // blue
}
}
if (led_flash_step_ == 5 && (healthcheck_ & HEALTHCHECK_NO_NETWORK) == HEALTHCHECK_NO_NETWORK) {
pixels.setPixelColor(0, 128, 0, 0); // red
}
if ((led_flash_step_ == 7) && ((healthcheck_ & HEALTHCHECK_NO_NETWORK) == HEALTHCHECK_NO_NETWORK)
&& ((healthcheck_ & HEALTHCHECK_NO_BUS) == HEALTHCHECK_NO_BUS)) {
pixels.setPixelColor(0, 0, 0, 128); // blue
}
pixels.show();
#else
if ((led_flash_step_ == 3) if ((led_flash_step_ == 3)
&& (((healthcheck_ & HEALTHCHECK_NO_NETWORK) == HEALTHCHECK_NO_NETWORK) || ((healthcheck_ & HEALTHCHECK_NO_BUS) == HEALTHCHECK_NO_BUS))) { && (((healthcheck_ & HEALTHCHECK_NO_NETWORK) == HEALTHCHECK_NO_NETWORK) || ((healthcheck_ & HEALTHCHECK_NO_BUS) == HEALTHCHECK_NO_BUS))) {
led_on_ = true; led_on_ = true;
@@ -765,17 +783,13 @@ void System::led_monitor() {
} }
if (led_on_) { if (led_on_) {
#ifdef ARDUINO_LOLIN_C3_MINI
pixels.setPixelColor(0, 128, 0, 0);
pixels.show();
#else
digitalWrite(led_gpio_, LED_ON); // LED off digitalWrite(led_gpio_, LED_ON); // LED off
#endif
} }
#endif
} else { } else {
// turn the led off after the flash, on even number count // turn the led off after the flash, on even number count
if (led_on_) { if (led_on_) {
#ifdef ARDUINO_LOLIN_C3_MINI #if defined(ARDUINO_LOLIN_C3_MINI) && !defined(BOARD_C3_MINI_V1)
pixels.setPixelColor(0, 0, 0, 0); pixels.setPixelColor(0, 0, 0, 0);
pixels.show(); pixels.show();
#else #else