secondary LED added

This commit is contained in:
Verkehrsrot 2019-03-24 01:05:13 +01:00
parent cad13b72a1
commit 6604d3f694
6 changed files with 50 additions and 12 deletions

View File

@ -38,5 +38,6 @@ void rgb_set_color(uint16_t hue);
void blink_LED(uint16_t set_color, uint16_t set_blinkduration); void blink_LED(uint16_t set_color, uint16_t set_blinkduration);
void ledLoop(void *parameter); void ledLoop(void *parameter);
void switch_LED(uint8_t state); void switch_LED(uint8_t state);
void switch_LED1(uint8_t state);
#endif #endif

View File

@ -89,7 +89,7 @@ void init_display(const char *Productname, const char *Version) {
#endif #endif
// Display chip information // Display chip information
#if(VERBOSE) #if (VERBOSE)
esp_chip_info_t chip_info; esp_chip_info_t chip_info;
esp_chip_info(&chip_info); esp_chip_info(&chip_info);
u8x8.printf("ESP32 %d cores\nWiFi%s%s\n", chip_info.cores, u8x8.printf("ESP32 %d cores\nWiFi%s%s\n", chip_info.cores,
@ -105,7 +105,7 @@ void init_display(const char *Productname, const char *Version) {
u8x8.print(" v"); u8x8.print(" v");
u8x8.println(PROGVERSION); u8x8.println(PROGVERSION);
#if(HAS_LORA) #if (HAS_LORA)
u8x8.println("DEVEUI:"); u8x8.println("DEVEUI:");
os_getDevEui((u1_t *)buf); os_getDevEui((u1_t *)buf);
DisplayKey(buf, 8, true); DisplayKey(buf, 8, true);
@ -114,7 +114,7 @@ void init_display(const char *Productname, const char *Version) {
u8x8.clear(); u8x8.clear();
u8x8.setPowerSave(!cfg.screenon); // set display off if disabled u8x8.setPowerSave(!cfg.screenon); // set display off if disabled
u8x8.draw2x2String(0, 0, "PAX:0"); u8x8.draw2x2String(0, 0, "PAX:0");
#if(BLECOUNTER) #if (BLECOUNTER)
u8x8.setCursor(0, 3); u8x8.setCursor(0, 3);
u8x8.printf("BLTH:0"); u8x8.printf("BLTH:0");
#endif #endif
@ -131,7 +131,8 @@ void refreshtheDisplay() {
uint8_t msgWaiting; uint8_t msgWaiting;
char timeState, buff[16]; char timeState, buff[16];
const time_t t = myTZ.toLocal(now()); // note: call now() here *before* locking mutex! const time_t t =
myTZ.toLocal(now()); // note: call now() here *before* locking mutex!
// block i2c bus access // block i2c bus access
if (I2C_MUTEX_LOCK()) { if (I2C_MUTEX_LOCK()) {
@ -163,7 +164,7 @@ void refreshtheDisplay() {
#endif #endif
// update GPS status (line 2) // update GPS status (line 2)
#if(HAS_GPS) #if (HAS_GPS)
// have we ever got valid gps data? // have we ever got valid gps data?
if (gps.passedChecksum() > 0) { if (gps.passedChecksum() > 0) {
u8x8.setCursor(9, 2); u8x8.setCursor(9, 2);
@ -178,7 +179,7 @@ void refreshtheDisplay() {
#endif #endif
// update bluetooth counter + LoRa SF (line 3) // update bluetooth counter + LoRa SF (line 3)
#if(BLECOUNTER) #if (BLECOUNTER)
u8x8.setCursor(0, 3); u8x8.setCursor(0, 3);
if (cfg.blescan) if (cfg.blescan)
u8x8.printf("BLTH:%-5d", macs_ble); u8x8.printf("BLTH:%-5d", macs_ble);
@ -186,7 +187,7 @@ void refreshtheDisplay() {
u8x8.printf("%s", "BLTH:off"); u8x8.printf("%s", "BLTH:off");
#endif #endif
#if(HAS_LORA) #if (HAS_LORA)
u8x8.setCursor(11, 3); u8x8.setCursor(11, 3);
u8x8.printf("SF:"); u8x8.printf("SF:");
if (cfg.adrmode) // if ADR=on then display SF value inverse if (cfg.adrmode) // if ADR=on then display SF value inverse
@ -209,7 +210,7 @@ void refreshtheDisplay() {
u8x8.setCursor(10, 5); u8x8.setCursor(10, 5);
u8x8.printf("%4dKB", getFreeRAM() / 1024); u8x8.printf("%4dKB", getFreeRAM() / 1024);
#if(HAS_LORA) #if (HAS_LORA)
u8x8.setCursor(0, 6); u8x8.setCursor(0, 6);
#if (!defined HAS_DCF77) && (!defined HAS_IF482) #if (!defined HAS_DCF77) && (!defined HAS_IF482)
// update LoRa status display (line 6) // update LoRa status display (line 6)

View File

@ -20,7 +20,8 @@
#define EXT_POWER_ON 0 #define EXT_POWER_ON 0
#define EXT_POWER_OFF 1 #define EXT_POWER_OFF 1
#define HAS_LED (12) // on board LED #define HAS_LED (2) // on board green LED
#define HAS_LED1 (12) // on board red LED
//#define HAS_BUTTON (0) // on board button -> don't use, is same as RTC_INT! //#define HAS_BUTTON (0) // on board button -> don't use, is same as RTC_INT!
// Pins for I2C interface of OLED Display // Pins for I2C interface of OLED Display

View File

@ -107,6 +107,26 @@ void switch_LED(uint8_t state) {
#endif #endif
} }
void switch_LED1(uint8_t state) {
#if (HAS_LED1 != NOT_A_PIN)
if (state == LED_ON) {
// switch LED on
#ifdef LED1_ACTIVE_LOW
digitalWrite(HAS_LED1, LOW);
#else
digitalWrite(HAS_LED1, HIGH);
#endif
} else if (state == LED_OFF) {
// switch LED off
#ifdef LED1_ACTIVE_LOW
digitalWrite(HAS_LED1, HIGH);
#else
digitalWrite(HAS_LED1, LOW);
#endif
}
#endif
}
void blink_LED(uint16_t set_color, uint16_t set_blinkduration) { void blink_LED(uint16_t set_color, uint16_t set_blinkduration) {
#if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED) #if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED)
LEDColor = set_color; // set color for RGB LED LEDColor = set_color; // set color for RGB LED

View File

@ -113,7 +113,7 @@ void setup() {
if (I2Caccess) if (I2Caccess)
xSemaphoreGive(I2Caccess); // Flag the i2c bus available for use xSemaphoreGive(I2Caccess); // Flag the i2c bus available for use
// disable brownout detection // disable brownout detection
#ifdef DISABLE_BROWNOUT #ifdef DISABLE_BROWNOUT
// register with brownout is at address DR_REG_RTCCNTL_BASE + 0xd4 // register with brownout is at address DR_REG_RTCCNTL_BASE + 0xd4
(*((uint32_t volatile *)ETS_UNCACHED_ADDR((DR_REG_RTCCNTL_BASE + 0xd4)))) = 0; (*((uint32_t volatile *)ETS_UNCACHED_ADDR((DR_REG_RTCCNTL_BASE + 0xd4)))) = 0;
@ -188,14 +188,18 @@ void setup() {
#endif #endif
#ifdef BAT_MEASURE_EN #ifdef BAT_MEASURE_EN
pinMode(BAT_MEASURE_EN, OUTPUT); pinMode(BAT_MEASURE_EN, OUTPUT);
#endif #endif
// initialize leds // initialize leds
#if (HAS_LED != NOT_A_PIN) #if (HAS_LED != NOT_A_PIN)
pinMode(HAS_LED, OUTPUT); pinMode(HAS_LED, OUTPUT);
strcat_P(features, " LED"); strcat_P(features, " LED");
// switch on power LED if we have 2 LEDs, else use it for status #if (HAS_LED1 != NOT_A_PIN)
pinMode(HAS_LED1, OUTPUT);
strcat_P(features, " LED1");
#endif
// use LED for power display if we have additional RGB LED, else for status
#ifdef HAS_RGB_LED #ifdef HAS_RGB_LED
switch_LED(LED_ON); switch_LED(LED_ON);
strcat_P(features, " RGB"); strcat_P(features, " RGB");

View File

@ -130,8 +130,10 @@ void IRAM_ATTR CLOCKIRQ(void) {
xTaskNotifyFromISR(ClockTask, uint32_t(now()), eSetBits, xTaskNotifyFromISR(ClockTask, uint32_t(now()), eSetBits,
&xHigherPriorityTaskWoken); &xHigherPriorityTaskWoken);
#ifdef HAS_DISPLAY
#if (defined GPS_INT || defined RTC_INT) #if (defined GPS_INT || defined RTC_INT)
TimePulseTick = !TimePulseTick; // flip pulse ticker TimePulseTick = !TimePulseTick; // flip pulse ticker
#endif
#endif #endif
portEXIT_CRITICAL_ISR(&mux); portEXIT_CRITICAL_ISR(&mux);
@ -213,6 +215,7 @@ void clock_loop(void *taskparameter) { // ClockTask
#define nextmin(t) (t + DCF77_FRAME_SIZE + 1) // next minute #define nextmin(t) (t + DCF77_FRAME_SIZE + 1) // next minute
static bool led1_state = false;
uint32_t printtime; uint32_t printtime;
time_t t = *((time_t *)taskparameter), last_printtime = 0; // UTC time seconds time_t t = *((time_t *)taskparameter), last_printtime = 0; // UTC time seconds
TickType_t startTime; TickType_t startTime;
@ -243,6 +246,14 @@ void clock_loop(void *taskparameter) { // ClockTask
last_printtime = t; last_printtime = t;
#ifdef HAS_LED1
if (led1_state)
switch_LED1(LED_OFF);
else
switch_LED1(LED_ON);
led1_state = !led1_state;
#endif
#if defined HAS_IF482 #if defined HAS_IF482
vTaskDelayUntil(&startTime, txDelay); // wait until moment to fire vTaskDelayUntil(&startTime, txDelay); // wait until moment to fire