From c566b302d576828978521aa3090a0d43067ab92a Mon Sep 17 00:00:00 2001 From: Verkehrsrot Date: Wed, 14 Aug 2019 21:52:12 +0200 Subject: [PATCH] add tinyPICO board --- platformio.ini | 3 ++- src/hal/eboxtube.h | 2 +- src/hal/fipy.h | 2 +- src/hal/generic.h | 2 +- src/hal/lolin32litelora.h | 2 +- src/hal/lolin32lora.h | 2 +- src/hal/lopy.h | 2 +- src/hal/lopy4.h | 4 ++-- src/hal/octopus32.h | 2 +- src/hal/tinypico.h | 24 ++++++++++++++++++++++++ src/led.cpp | 2 +- src/main.cpp | 10 +++++++++- src/paxcounter.conf | 2 +- 13 files changed, 46 insertions(+), 13 deletions(-) create mode 100644 src/hal/tinypico.h diff --git a/platformio.ini b/platformio.ini index 4df4cb24..b35fa91e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -28,6 +28,7 @@ halfile = generic.h ;halfile = wemos32oled.h ;halfile = wemos32matrix.h ;halfile = octopus32.h +;halfile = tinypico.h [platformio] ; upload firmware to board with usb cable @@ -40,7 +41,7 @@ description = Paxcounter is a device for metering passenger flows in realtime. I [common] ; for release_version use max. 10 chars total, use any decimal format like "a.b.c" -release_version = 1.7.91 +release_version = 1.7.92 ; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running! ; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose debug_level = 3 diff --git a/src/hal/eboxtube.h b/src/hal/eboxtube.h index 9278f0a6..34abe865 100644 --- a/src/hal/eboxtube.h +++ b/src/hal/eboxtube.h @@ -14,7 +14,7 @@ #define CFG_sx1276_radio 1 #define HAS_LED (22) // Green LED on board -#define HAS_RGB_LED (2) // WS2812B RGB LED on board +#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, 1, 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/fipy.h b/src/hal/fipy.h index c59dff59..f904d716 100644 --- a/src/hal/fipy.h +++ b/src/hal/fipy.h @@ -13,7 +13,7 @@ #define CFG_sx1272_radio 1 #define HAS_LED NOT_A_PIN // FiPy has no on board LED, so we use RGB LED -#define HAS_RGB_LED GPIO_NUM_0 // WS2812B RGB LED on GPIO0 +#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, 1, GPIO_NUM_0) // WS2812B RGB LED on GPIO0 #define BOARD_HAS_PSRAM // use extra 4MB extern RAM // Pins for LORA chip SPI interface, reset line and interrupt lines diff --git a/src/hal/generic.h b/src/hal/generic.h index 1579221f..c606e5ba 100644 --- a/src/hal/generic.h +++ b/src/hal/generic.h @@ -51,7 +51,7 @@ #define HAS_LED (21) // on board LED #define HAS_BUTTON (39) // on board button -#define HAS_RGB_LED (0) // WS2812B RGB LED on GPIO0 +#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, 1, GPIO_NUM_0) // WS2812B RGB LED on GPIO0 // GPS settings #define HAS_GPS 1 // use on board GPS diff --git a/src/hal/lolin32litelora.h b/src/hal/lolin32litelora.h index 79f9bb6b..11f3f156 100644 --- a/src/hal/lolin32litelora.h +++ b/src/hal/lolin32litelora.h @@ -17,7 +17,7 @@ //#define DISPLAY_FLIP 1 // uncomment this for rotated display #define HAS_LED 22 // ESP32 GPIO12 (pin22) On Board LED #define LED_ACTIVE_LOW 1 // Onboard LED is active when pin is LOW -#define HAS_RGB_LED 13 // ESP32 GPIO13 (pin13) On Board Shield WS2812B RGB LED +#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, 1, GPIO_NUM_13) // ESP32 GPIO13 (pin13) On Board Shield WS2812B RGB LED #define HAS_BUTTON 15 // ESP32 GPIO15 (pin15) Button is on the LoraNode32 shield #define BUTTON_PULLUP 1 // Button need pullup instead of default pulldown diff --git a/src/hal/lolin32lora.h b/src/hal/lolin32lora.h index a6fa2f37..a79b0d84 100644 --- a/src/hal/lolin32lora.h +++ b/src/hal/lolin32lora.h @@ -18,7 +18,7 @@ #define HAS_LED NOT_A_PIN // Led os on same pin as Lora SS pin, to avoid problems, we don't use it #define LED_ACTIVE_LOW 1 // Onboard LED is active when pin is LOW // Anyway shield is on over the LoLin32 board, so we won't be able to see this LED -#define HAS_RGB_LED 13 // ESP32 GPIO13 (pin13) On Board Shield WS2812B RGB LED +#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, 1, GPIO_NUM_13) // ESP32 GPIO13 (pin13) On Board Shield WS2812B RGB LED #define HAS_BUTTON 15 // ESP32 GPIO15 (pin15) Button is on the LoraNode32 shield #define BUTTON_PULLUP 1 // Button need pullup instead of default pulldown diff --git a/src/hal/lopy.h b/src/hal/lopy.h index 4bf50781..733eb603 100644 --- a/src/hal/lopy.h +++ b/src/hal/lopy.h @@ -12,7 +12,7 @@ #define HAS_LORA 1 // comment out if device shall not send data via LoRa #define CFG_sx1272_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 (0) // WS2812B RGB LED on GPIO0 +#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, 1, GPIO_NUM_0) // WS2812B RGB LED on GPIO0 (P2) // Note: Pins for LORA chip SPI interface come from board file pins_arduino.h diff --git a/src/hal/lopy4.h b/src/hal/lopy4.h index 321244e4..e0736229 100644 --- a/src/hal/lopy4.h +++ b/src/hal/lopy4.h @@ -20,8 +20,8 @@ //#define SPI_CS GPIO_NUM_36 #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 (0) // WS2812B RGB LED on GPIO0 (P2) +#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 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/octopus32.h b/src/hal/octopus32.h index c2bf3735..d245a8c2 100644 --- a/src/hal/octopus32.h +++ b/src/hal/octopus32.h @@ -23,7 +23,7 @@ #define HAS_LED 13 // ESP32 GPIO12 (pin22) On Board LED //#define LED_ACTIVE_LOW 1 // Onboard LED is active when pin is LOW -//#define HAS_RGB_LED 13 // ESP32 GPIO13 (pin13) On Board Shield WS2812B RGB LED +//#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, 1, GPIO_NUM_13) // ESP32 GPIO13 (pin13) On Board Shield WS2812B RGB LED //#define HAS_BUTTON 15 // ESP32 GPIO15 (pin15) Button is on the LoraNode32 shield //#define BUTTON_PULLUP 1 // Button need pullup instead of default pulldown diff --git a/src/hal/tinypico.h b/src/hal/tinypico.h new file mode 100644 index 00000000..415f793d --- /dev/null +++ b/src/hal/tinypico.h @@ -0,0 +1,24 @@ +// clang-format off +// upload_speed 921600 +// board esp32dev + + +#ifndef _TINYPICO_H +#define _TINYPICO_H + +#include + +// Hardware related definitions for crowdsupply tinypico board + +#define HAS_LED NOT_A_PIN // Green LED on board +#define HAS_RGB_LED Apa102 rgb_led(1, GPIO_NUM_12, GPIO_NUM_2) // APA102 RGB LED on board + +//#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature +#define BAT_MEASURE_ADC ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7 +#define BAT_VOLTAGE_DIVIDER 2.7625f // voltage divider 160k/442k on board +#define BOARD_HAS_PSRAM // use extra 4MB external RAM +#define LED_POWER_SW (13) // switches LED power +#define LED_POWER_ON 0 // switch on transistor for LED power +#define LED_POWER_OFF 1 + +#endif \ No newline at end of file diff --git a/src/led.cpp b/src/led.cpp index 624fb7d9..d7925b4e 100644 --- a/src/led.cpp +++ b/src/led.cpp @@ -14,7 +14,7 @@ unsigned long LEDBlinkStarted = 0; // When (in millis() led blink started) #ifdef HAS_RGB_LED // RGB Led instance -SmartLed rgb_led(LED_WS2812, 1, HAS_RGB_LED); +HAS_RGB_LED; float rgb_CalcColor(float p, float q, float t) { if (t < 0.0f) diff --git a/src/main.cpp b/src/main.cpp index c6dae99e..976ad625 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -195,17 +195,25 @@ void setup() { #if (HAS_LED != NOT_A_PIN) pinMode(HAS_LED, OUTPUT); strcat_P(features, " LED"); + +#ifdef LED_POWER_SW + pinMode(LED_POWER_SW, OUTPUT); + digitalWrite(LED_POWER_SW, LED_POWER_ON); +#endif + #ifdef HAS_TWO_LED pinMode(HAS_TWO_LED, 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"); rgb_set_color(COLOR_PINK); #endif -#endif + +#endif // HAS_LED #if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED) // start led loop diff --git a/src/paxcounter.conf b/src/paxcounter.conf index 30dcedc0..7382d8d8 100644 --- a/src/paxcounter.conf +++ b/src/paxcounter.conf @@ -72,7 +72,7 @@ #define TIME_SYNC_INTERVAL_RETRY 10 // retry time sync after lost sync each .. minutes [default = 10], 0 means off #define TIME_SYNC_COMPILEDATE 0 // set to 1 to use compile date to initialize RTC after power outage [default = 0] #define TIME_SYNC_LORAWAN 0 // set to 1 to use LORA network as time source, 0 means off [default = 0] -#define TIME_SYNC_LORASERVER 1 // set to 1 to use LORA timeserver as time source, 0 means off [default = 0] +#define TIME_SYNC_LORASERVER 0 // set to 1 to use LORA timeserver as time source, 0 means off [default = 0] // settings for syncing time with timeserver applications #define TIME_SYNC_SAMPLES 1 // number of time requests for averaging