Compare commits

...

3 commits

Author SHA1 Message Date
Carsten Schmiemann 9e30931ca4 Update graphics 2024-04-22 00:39:56 +02:00
Carsten Schmiemann 035b0902a7 Fix led behavior 2024-04-22 00:29:34 +02:00
Carsten Schmiemann bf4860b509 Code modify for T-CAN485 board 2024-04-20 22:32:32 +02:00
5 changed files with 64 additions and 8 deletions

BIN
.DS_Store vendored

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 221 KiB

After

Width:  |  Height:  |  Size: 228 KiB

View file

@ -121,7 +121,7 @@ int ESP32SJA1000Class::begin(long baudRate)
}
modifyRegister(REG_BTR1, 0x80, 0x80); // SAM = 1
writeRegister(REG_IER, 0xff); // enable all interrupts
writeRegister(REG_IER, 0xef); // enable all interrupts
// set filter to allow anything
writeRegister(REG_ACRn(0), 0x00);

View file

@ -10,17 +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
build_flags = -DCORE_DEBUG_LEVEL=3
;upload_speed = 115200
build_flags = -DCORE_DEBUG_LEVEL=3
lib_deps = fastled/FastLED@^3.6.0

View file

@ -4,6 +4,9 @@
#include <CAN.h>
#include "esp_log.h"
#include <FastLED.h>
CRGB led[1];
static SemaphoreHandle_t mutex;
// Task handles
@ -64,6 +67,11 @@ unsigned long standbyStartTime = 0; // Tracks the start time of standby mode
bool serial_init = false;
bool can_enabled = 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()
@ -404,6 +412,40 @@ void vSerialConsoleTask(void *pvParameters)
serial_ping += 10000;
ESP_LOGI("Serial Console", "Ping, Time %d s", millis() / 1000);
}
if (standbyState)
{
led[0] = CRGB::Yellow;
led_interval = 500;
}
else if (ignitionState)
{
led[0] = CRGB::Green;
led_interval = 250;
}
else if (!ignitionState)
{
led[0] = CRGB::Red;
led_interval = 1000;
}
unsigned long currentMillis = millis();
if (currentMillis - led_previousMillis >= led_interval)
{
led_previousMillis = currentMillis;
if (led_status)
{
FastLED.setBrightness(0);
led_status = false;
}
else
{
FastLED.setBrightness(25);
led_status = true;
}
FastLED.show();
}
}
}
@ -413,16 +455,28 @@ void setup()
Serial.setTimeout(5000);
ESP_LOGI("SYS", "Easylink CAN Waker application starting up...");
// TCAN Enable CAN Interface
pinMode(16, OUTPUT);
digitalWrite(16, HIGH);
pinMode(23, OUTPUT);
digitalWrite(23, LOW);
CAN.setPins(26, 27);
mutex = xSemaphoreCreateMutex();
// Print state of variables during bootup
ESP_LOGD("SYS", "Print actual variable states");
printVariableSummary();
FastLED.addLeds<WS2812, 4, GRB>(led, 1);
ESP_LOGD("SYS", "Init WS2812 LED");
xTaskCreatePinnedToCore(vCANSendTask, "CANSendTask", 8096, NULL, 10, &xCANSendTaskHandle, 0);
ESP_LOGD("SYS", "Start CANSendTask");
ESP_LOGD("SYS", "Started CANSendTask");
xTaskCreatePinnedToCore(vSerialConsoleTask, "SerialConsoleTask", 8096, NULL, 10, &xSerialConsoleTaskHandle, 1);
ESP_LOGD("SYS", "Start SerialConsoleTask");
ESP_LOGD("SYS", "Started SerialConsoleTask");
}
void loop()