From 090657ac82faf534b4546bf1ca60079e5b5106cc Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sat, 21 Mar 2020 08:38:42 +0100 Subject: [PATCH 1/6] enhanced RGB LED control: use more than 1 LED --- include/led.h | 5 +++++ src/hal/eboxtube.h | 3 ++- src/hal/lopy4.h | 3 ++- src/hal/m5fire.h | 5 +++-- src/led.cpp | 11 +++++++---- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/include/led.h b/include/led.h index de4d2227..9fb7bc91 100644 --- a/include/led.h +++ b/include/led.h @@ -3,6 +3,11 @@ #ifdef HAS_RGB_LED #include + +#ifndef RGB_LED_COUNT +#define RGB_LED_COUNT 1 +#endif + #endif // value for HSL color diff --git a/src/hal/eboxtube.h b/src/hal/eboxtube.h index 86a69d7d..e95b6940 100644 --- a/src/hal/eboxtube.h +++ b/src/hal/eboxtube.h @@ -14,7 +14,8 @@ #define CFG_sx1276_radio 1 #define HAS_LED (22) // Green LED on board -#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, 1, GPIO_NUM_2) // WS2812B RGB LED on board +#define RGB_LED_COUNT 1 // we have 1 LED +#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, RGB_LED_COUNT, GPIO_NUM_2) // WS2812B RGB LED on board #define HAS_BUTTON (0) // button "FLASH" on board #define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature diff --git a/src/hal/lopy4.h b/src/hal/lopy4.h index e0736229..4e625dfa 100644 --- a/src/hal/lopy4.h +++ b/src/hal/lopy4.h @@ -21,7 +21,8 @@ #define CFG_sx1276_radio 1 #define HAS_LED NOT_A_PIN // LoPy4 has no on board mono LED, we use on board RGB LED -#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, 1, GPIO_NUM_0) // WS2812B RGB LED on GPIO0 (P2) +#define RGB_LED_COUNT 1 // we have 1 LEDs +#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, RGB_LED_COUNT, GPIO_NUM_0) // WS2812B RGB LED on GPIO0 (P2) #define BOARD_HAS_PSRAM // use extra 4MB extern RAM // Note: Pins for LORA chip SPI interface come from board file pins_arduino.h diff --git a/src/hal/m5fire.h b/src/hal/m5fire.h index e02ede3a..5cb1b146 100644 --- a/src/hal/m5fire.h +++ b/src/hal/m5fire.h @@ -38,8 +38,9 @@ //#define BAT_MEASURE_ADC ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7 //#define BAT_VOLTAGE_DIVIDER 2 // voltage divider 100k/100k on board -#define HAS_LED NOT_A_PIN // no on board LED (?) -#define HAS_RGB_LED SmartLed rgb_led(LED_SK6812, 10, GPIO_NUM_15) // LED_SK6812 RGB LED on GPIO15 +#define HAS_LED NOT_A_PIN // no on board LED +#define RGB_LED_COUNT 5 // we use 5 of 10 LEDs (1 side) +#define HAS_RGB_LED SmartLed rgb_led(LED_SK6812, RGB_LED_COUNT, GPIO_NUM_15) // LED_SK6812 RGB LED on GPIO15 #define HAS_BUTTON (39) // on board button A // GPS settings diff --git a/src/led.cpp b/src/led.cpp index d7925b4e..5c91428b 100644 --- a/src/led.cpp +++ b/src/led.cpp @@ -63,9 +63,11 @@ RGBColor rgb_hsl2rgb(float h, float s, float l) { } void rgb_set_color(uint16_t hue) { + int i = RGB_LED_COUNT; if (hue == COLOR_NONE) { // Off - rgb_led[0] = Rgb(0, 0, 0); + while (i--) + rgb_led[i] = Rgb(0, 0, 0); } else { // see http://www.workwithcolor.com/blue-color-hue-range-01.htm // H (is color from 0..360) should be between 0.0 and 1.0 @@ -74,7 +76,8 @@ void rgb_set_color(uint16_t hue) { // cfg.rgblum is between 0 and 100 (percent) RGBColor target = rgb_hsl2rgb(hue / 360.0f, 1.0f, 0.005f * cfg.rgblum); // uint32_t color = target.R<<16 | target.G<<8 | target.B; - rgb_led[0] = Rgb(target.R, target.G, target.B); + while (i--) + rgb_led[i] = Rgb(target.R, target.G, target.B); } // Show rgb_led.show(); @@ -211,7 +214,7 @@ void ledLoop(void *parameter) { } // give yield to CPU delay(2); - } // while(1) -}; // ledloop() + } // while(1) +}; // ledloop() #endif // #if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED) From 714ed1675cca6e5daa18c03cf501996189721657 Mon Sep 17 00:00:00 2001 From: Dierk Arp Date: Tue, 24 Mar 2020 07:50:49 +0100 Subject: [PATCH 2/6] Update ttgov1.h issue #577: Pin DIO2 of SX1276 is connected to pin 32 --- src/hal/ttgov1.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hal/ttgov1.h b/src/hal/ttgov1.h index ac906860..3f117600 100644 --- a/src/hal/ttgov1.h +++ b/src/hal/ttgov1.h @@ -37,6 +37,6 @@ // Pins for LORA chip SPI interface come from board file, we need some // additional definitions for LMIC #define LORA_IO1 (33) -#define LORA_IO2 LMIC_UNUSED_PIN +#define LORA_IO2 (32) // ref.: https://www.thethingsnetwork.org/forum/t/big-esp32-sx127x-topic-part-3/18436 #endif From 0ac5e2a925616625b9f030afc18403294c54c4c2 Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Wed, 1 Apr 2020 15:21:05 +0200 Subject: [PATCH 3/6] Update ttgov21new.h --- src/hal/ttgov21new.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hal/ttgov21new.h b/src/hal/ttgov21new.h index 1d95d8fe..309acd2d 100644 --- a/src/hal/ttgov21new.h +++ b/src/hal/ttgov21new.h @@ -29,9 +29,9 @@ #define BAT_VOLTAGE_DIVIDER 2 // voltage divider 100k/100k on board // Pins for I2C interface of OLED Display -#define MY_OLED_SDA (21) -#define MY_OLED_SCL (22) -#define MY_OLED_RST NOT_A_PIN +#define MY_DISPLAY_SDA (21) +#define MY_DISPLAY_SCL (22) +#define MY_DISPLAY_RST NOT_A_PIN // Pins for LORA chip SPI interface, reset line and interrupt lines #define LORA_SCK (5) From 99b50ea5fbf1e8b225555509fdc078317f5799dd Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Wed, 1 Apr 2020 15:21:54 +0200 Subject: [PATCH 4/6] Update platformio.ini --- platformio.ini | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/platformio.ini b/platformio.ini index 24b0b474..da148797 100644 --- a/platformio.ini +++ b/platformio.ini @@ -60,9 +60,8 @@ upload_speed = 115200 lib_deps_lora = MCCI LoRaWAN LMIC library@>=3.1.0 ; MCCI LMIC by Terrill Moore lib_deps_display = - ;ss_oled@4.1.1 ; simple and small OLED lib by Larry Bank - https://github.com/bitbank2/ss_oled.git - BitBang_I2C@2.0.1 + ss_oled@4.1.2 ; simple and small OLED lib by Larry Bank + BitBang_I2C@2.0.2 QRCode@>=0.0.1 bb_spi_lcd@1.1.0 ; LCD TFT driver lib by Larry Bank lib_deps_matrix_display = From 886587cacb8428910cc10927658c0fdecb46dd65 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Wed, 1 Apr 2020 21:04:17 +0200 Subject: [PATCH 5/6] display.cpp: bugfix (issue #583) --- src/display.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/display.cpp b/src/display.cpp index fd450a1b..dc22b456 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -55,8 +55,8 @@ void dp_setup(int contrast) { #if (HAS_DISPLAY) == 1 int rc = oledInit(&ssoled, MY_DISPLAY_TYPE, OLED_ADDR, MY_DISPLAY_FLIP, - MY_DISPLAY_INVERT, USE_HW_I2C, MY_DISPLAY_SDA, MY_DISPLAY_SCL, - MY_DISPLAY_RST, + MY_DISPLAY_INVERT, USE_HW_I2C, MY_DISPLAY_SDA, + MY_DISPLAY_SCL, MY_DISPLAY_RST, 400000L); // use standard I2C bus at 400Khz assert(rc != OLED_NOT_FOUND); @@ -65,10 +65,10 @@ void dp_setup(int contrast) { #elif (HAS_DISPLAY) == 2 - int rc = - spilcdInit(MY_DISPLAY_TYPE, 0, MY_DISPLAY_INVERT, MY_DISPLAY_FLIP, 32000000, - MY_DISPLAY_CS, MY_DISPLAY_DC, MY_DISPLAY_RST, MY_DISPLAY_BL, - MY_DISPLAY_MISO, MY_DISPLAY_MOSI, MY_DISPLAY_CLK); + int rc = spilcdInit(MY_DISPLAY_TYPE, 0, MY_DISPLAY_INVERT, MY_DISPLAY_FLIP, + 32000000, MY_DISPLAY_CS, MY_DISPLAY_DC, MY_DISPLAY_RST, + MY_DISPLAY_BL, MY_DISPLAY_MISO, MY_DISPLAY_MOSI, + MY_DISPLAY_CLK); assert(rc == 0); @@ -483,7 +483,7 @@ void dp_shutdown(void) { ESP_LOGV(TAG, "[%0.3f] i2c mutex lock failed", millis() / 1000.0); else { cfg.screenon = 0; - oledShutdown(&ssoled); + oledPower(&ssoled, false); delay(DISPLAYREFRESH_MS / 1000 * 1.1); I2C_MUTEX_UNLOCK(); // release i2c bus access } @@ -522,7 +522,8 @@ void dp_fillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, for (uint16_t xi = x; xi < x + width; xi++) oledDrawLine(&ssoled, xi, y, xi, y + height - 1, bRender); #elif (HAS_DISPLAY) == 2 - spilcdRectangle(x, y, width, height, MY_DISPLAY_BGCOLOR, MY_DISPLAY_FGCOLOR, 1, 1); + spilcdRectangle(x, y, width, height, MY_DISPLAY_BGCOLOR, MY_DISPLAY_FGCOLOR, + 1, 1); #endif } From 3b065bb13a32884c0490de278e86289751011a64 Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Fri, 3 Apr 2020 17:03:05 +0200 Subject: [PATCH 6/6] Update payload.cpp --- src/payload.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/payload.cpp b/src/payload.cpp index 10c04ddc..8ab9f91c 100644 --- a/src/payload.cpp +++ b/src/payload.cpp @@ -346,6 +346,7 @@ void PayloadConvert::addSDS(sdsStatus_t sds) { buffer[cursor++] = highByte((uint16_t)(sds.pm25 * 10)); buffer[cursor++] = lowByte((uint16_t)(sds.pm25 * 10)); #endif // HAS_SDS011 +} void PayloadConvert::addCount(uint16_t value, uint8_t snifftype) { switch (snifftype) {