secondary LED added
This commit is contained in:
parent
cad13b72a1
commit
6604d3f694
@ -38,5 +38,6 @@ void rgb_set_color(uint16_t hue);
|
||||
void blink_LED(uint16_t set_color, uint16_t set_blinkduration);
|
||||
void ledLoop(void *parameter);
|
||||
void switch_LED(uint8_t state);
|
||||
void switch_LED1(uint8_t state);
|
||||
|
||||
#endif
|
@ -89,7 +89,7 @@ void init_display(const char *Productname, const char *Version) {
|
||||
#endif
|
||||
|
||||
// Display chip information
|
||||
#if(VERBOSE)
|
||||
#if (VERBOSE)
|
||||
esp_chip_info_t chip_info;
|
||||
esp_chip_info(&chip_info);
|
||||
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.println(PROGVERSION);
|
||||
|
||||
#if(HAS_LORA)
|
||||
#if (HAS_LORA)
|
||||
u8x8.println("DEVEUI:");
|
||||
os_getDevEui((u1_t *)buf);
|
||||
DisplayKey(buf, 8, true);
|
||||
@ -114,7 +114,7 @@ void init_display(const char *Productname, const char *Version) {
|
||||
u8x8.clear();
|
||||
u8x8.setPowerSave(!cfg.screenon); // set display off if disabled
|
||||
u8x8.draw2x2String(0, 0, "PAX:0");
|
||||
#if(BLECOUNTER)
|
||||
#if (BLECOUNTER)
|
||||
u8x8.setCursor(0, 3);
|
||||
u8x8.printf("BLTH:0");
|
||||
#endif
|
||||
@ -131,7 +131,8 @@ void refreshtheDisplay() {
|
||||
|
||||
uint8_t msgWaiting;
|
||||
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
|
||||
if (I2C_MUTEX_LOCK()) {
|
||||
@ -163,7 +164,7 @@ void refreshtheDisplay() {
|
||||
#endif
|
||||
|
||||
// update GPS status (line 2)
|
||||
#if(HAS_GPS)
|
||||
#if (HAS_GPS)
|
||||
// have we ever got valid gps data?
|
||||
if (gps.passedChecksum() > 0) {
|
||||
u8x8.setCursor(9, 2);
|
||||
@ -178,7 +179,7 @@ void refreshtheDisplay() {
|
||||
#endif
|
||||
|
||||
// update bluetooth counter + LoRa SF (line 3)
|
||||
#if(BLECOUNTER)
|
||||
#if (BLECOUNTER)
|
||||
u8x8.setCursor(0, 3);
|
||||
if (cfg.blescan)
|
||||
u8x8.printf("BLTH:%-5d", macs_ble);
|
||||
@ -186,7 +187,7 @@ void refreshtheDisplay() {
|
||||
u8x8.printf("%s", "BLTH:off");
|
||||
#endif
|
||||
|
||||
#if(HAS_LORA)
|
||||
#if (HAS_LORA)
|
||||
u8x8.setCursor(11, 3);
|
||||
u8x8.printf("SF:");
|
||||
if (cfg.adrmode) // if ADR=on then display SF value inverse
|
||||
@ -209,7 +210,7 @@ void refreshtheDisplay() {
|
||||
u8x8.setCursor(10, 5);
|
||||
u8x8.printf("%4dKB", getFreeRAM() / 1024);
|
||||
|
||||
#if(HAS_LORA)
|
||||
#if (HAS_LORA)
|
||||
u8x8.setCursor(0, 6);
|
||||
#if (!defined HAS_DCF77) && (!defined HAS_IF482)
|
||||
// update LoRa status display (line 6)
|
||||
|
@ -20,7 +20,8 @@
|
||||
#define EXT_POWER_ON 0
|
||||
#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!
|
||||
|
||||
// Pins for I2C interface of OLED Display
|
||||
|
20
src/led.cpp
20
src/led.cpp
@ -107,6 +107,26 @@ void switch_LED(uint8_t state) {
|
||||
#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) {
|
||||
#if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED)
|
||||
LEDColor = set_color; // set color for RGB LED
|
||||
|
@ -195,7 +195,11 @@ void setup() {
|
||||
#if (HAS_LED != NOT_A_PIN)
|
||||
pinMode(HAS_LED, OUTPUT);
|
||||
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
|
||||
switch_LED(LED_ON);
|
||||
strcat_P(features, " RGB");
|
||||
|
@ -130,8 +130,10 @@ void IRAM_ATTR CLOCKIRQ(void) {
|
||||
xTaskNotifyFromISR(ClockTask, uint32_t(now()), eSetBits,
|
||||
&xHigherPriorityTaskWoken);
|
||||
|
||||
#ifdef HAS_DISPLAY
|
||||
#if (defined GPS_INT || defined RTC_INT)
|
||||
TimePulseTick = !TimePulseTick; // flip pulse ticker
|
||||
#endif
|
||||
#endif
|
||||
|
||||
portEXIT_CRITICAL_ISR(&mux);
|
||||
@ -213,6 +215,7 @@ void clock_loop(void *taskparameter) { // ClockTask
|
||||
|
||||
#define nextmin(t) (t + DCF77_FRAME_SIZE + 1) // next minute
|
||||
|
||||
static bool led1_state = false;
|
||||
uint32_t printtime;
|
||||
time_t t = *((time_t *)taskparameter), last_printtime = 0; // UTC time seconds
|
||||
TickType_t startTime;
|
||||
@ -243,6 +246,14 @@ void clock_loop(void *taskparameter) { // ClockTask
|
||||
|
||||
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
|
||||
|
||||
vTaskDelayUntil(&startTime, txDelay); // wait until moment to fire
|
||||
|
Loading…
Reference in New Issue
Block a user