Fix led behavior
This commit is contained in:
parent
bf4860b509
commit
035b0902a7
2 changed files with 17 additions and 15 deletions
|
@ -10,19 +10,19 @@
|
|||
|
||||
[env:nodemcu-32s-dev]
|
||||
platform = espressif32
|
||||
board = nodemcu-32s
|
||||
board = esp32dev
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
monitor_filters = esp32_exception_decoder
|
||||
upload_speed = 115200
|
||||
;upload_speed = 115200
|
||||
build_flags = -DCORE_DEBUG_LEVEL=5
|
||||
lib_deps = fastled/FastLED@^3.6.0
|
||||
|
||||
[env:nodemcu-32s-prod]
|
||||
platform = espressif32
|
||||
board = nodemcu-32s
|
||||
board = esp32dev
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
upload_speed = 115200
|
||||
;upload_speed = 115200
|
||||
build_flags = -DCORE_DEBUG_LEVEL=3
|
||||
lib_deps = fastled/FastLED@^3.6.0
|
||||
|
|
24
src/main.cpp
24
src/main.cpp
|
@ -66,8 +66,12 @@ unsigned long standbyStartTime = 0; // Tracks the start time of standby mode
|
|||
// Internal variables
|
||||
bool serial_init = false;
|
||||
bool can_enabled = false;
|
||||
bool led_status = false;
|
||||
int serial_ping = 0;
|
||||
// LED variables
|
||||
bool led_status = false;
|
||||
bool led_standby_blink = false;
|
||||
long led_interval = 1000;
|
||||
unsigned long led_previousMillis = 0;
|
||||
|
||||
// Function to initialize CAN bus
|
||||
void initCAN()
|
||||
|
@ -409,31 +413,29 @@ void vSerialConsoleTask(void *pvParameters)
|
|||
ESP_LOGI("Serial Console", "Ping, Time %d s", millis() / 1000);
|
||||
}
|
||||
|
||||
unsigned long previousMillis = 0;
|
||||
long interval = 1000;
|
||||
|
||||
if (standbyState)
|
||||
{
|
||||
led[0] = CRGB::Yellow;
|
||||
interval = 500;
|
||||
led_interval = 500;
|
||||
}
|
||||
else if (ignitionState)
|
||||
{
|
||||
led[0] = CRGB::Green;
|
||||
interval = 250;
|
||||
led_interval = 250;
|
||||
}
|
||||
else if (!ignitionState)
|
||||
{
|
||||
led[0] = CRGB::Red;
|
||||
interval = 1000;
|
||||
led_interval = 1000;
|
||||
}
|
||||
unsigned long currentMillis = millis();
|
||||
if (currentMillis - previousMillis >= interval)
|
||||
|
||||
if (currentMillis - led_previousMillis >= led_interval)
|
||||
{
|
||||
previousMillis = currentMillis;
|
||||
led_previousMillis = currentMillis;
|
||||
if (led_status)
|
||||
{
|
||||
FastLED.setBrightness(25);
|
||||
FastLED.setBrightness(0);
|
||||
led_status = false;
|
||||
}
|
||||
else
|
||||
|
@ -453,7 +455,7 @@ void setup()
|
|||
Serial.setTimeout(5000);
|
||||
ESP_LOGI("SYS", "Easylink CAN Waker application starting up...");
|
||||
|
||||
//TCAN Enable CAN Interface
|
||||
// TCAN Enable CAN Interface
|
||||
pinMode(16, OUTPUT);
|
||||
digitalWrite(16, HIGH);
|
||||
|
||||
|
|
Loading…
Reference in a new issue