From c81af717bdc555b9355b43c535125ab8976ba962 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sat, 13 Feb 2021 14:04:03 +0100 Subject: [PATCH] sanitize ext_power_off --- include/power.h | 9 +++++++++ src/hal/ecopower.h | 1 - src/hal/heltec.h | 1 + src/hal/heltecv2.h | 9 +++++---- src/hal/ttgofox.h | 1 - 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/power.h b/include/power.h index d11235c0..24ec9e28 100644 --- a/include/power.h +++ b/include/power.h @@ -34,6 +34,15 @@ #endif #endif +#ifdef EXT_POWER_SW +#ifndef EXT_POWER_ON +#define EXT_POWER_ON 1 +#endif +#ifndef EXT_POWER_OFF +#define EXT_POWER_OFF (!EXT_POWER_ON) +#endif +#endif + typedef uint8_t (*mapFn_t)(uint16_t, uint16_t, uint16_t); uint16_t read_voltage(void); diff --git a/src/hal/ecopower.h b/src/hal/ecopower.h index 4b7f7a6f..276b3c54 100644 --- a/src/hal/ecopower.h +++ b/src/hal/ecopower.h @@ -20,7 +20,6 @@ #define EXT_POWER_SW 15 // Switch VDD on pin JP10, needed for RTC DS3231 #define EXT_POWER_ON 0 -#define EXT_POWER_OFF 1 #define HAS_LED (2) // on board green LED #define HAS_TWO_LED (12) // on board red LED diff --git a/src/hal/heltec.h b/src/hal/heltec.h index 6cea89f7..47877577 100644 --- a/src/hal/heltec.h +++ b/src/hal/heltec.h @@ -8,6 +8,7 @@ #include // Hardware related definitions for Heltec V1 LoRa-32 Board +// see https://heltec-automation-docs.readthedocs.io/en/latest/esp32/wifi_lora_32/hardware_update_log.html#v1 //#define HAS_BME 1 // Enable BME sensors in general //#define HAS_BME680 GPIO_NUM_21, GPIO_NUM_22 // SDA, SCL diff --git a/src/hal/heltecv2.h b/src/hal/heltecv2.h index c57607e2..dce2c717 100644 --- a/src/hal/heltecv2.h +++ b/src/hal/heltecv2.h @@ -8,6 +8,7 @@ #include // Hardware related definitions for Heltec V2 LoRa-32 Board +// see https://heltec-automation-docs.readthedocs.io/en/latest/esp32/wifi_lora_32/hardware_update_log.html#v2 //#define HAS_BME 1 // Enable BME sensors in general //#define HAS_BME680 GPIO_NUM_4, GPIO_NUM_15 // SDA, SCL @@ -29,9 +30,9 @@ //#define BAT_MEASURE_ADC_UNIT 2 // ADC 2 //#define BAT_VOLTAGE_DIVIDER 2 // voltage divider 220k/100k on board -#define EXT_POWER_SW Vext // switches battery power, Vext control 0 = on / 1 = off -#define EXT_POWER_ON 0 -//#define EXT_POWER_OFF 1 +// switches battery power and Vext, switch logic 0 = on / 1 = off +#define EXT_POWER_SW Vext +#define EXT_POWER_ON 0 // Pins for I2C interface of OLED Display #define MY_DISPLAY_SDA SDA_OLED @@ -43,7 +44,7 @@ #define LORA_IRQ DIO0 #define LORA_IO1 DIO1 #define LORA_IO2 DIO2 -#define LORA_SCK GPIO_NUM_5 +#define LORA_SCK SCK #define LORA_MISO MISO #define LORA_MOSI MOSI #define LORA_RST RST_LoRa diff --git a/src/hal/ttgofox.h b/src/hal/ttgofox.h index d61460a8..dc0a9974 100644 --- a/src/hal/ttgofox.h +++ b/src/hal/ttgofox.h @@ -15,7 +15,6 @@ #define EXT_POWER_SW GPIO_NUM_25 // switches power for LoRa chip #define EXT_POWER_ON 0 -#define EXT_POWER_OFF 1 #define BAT_MEASURE_ADC ADC1_GPIO35_CHANNEL #define BAT_VOLTAGE_DIVIDER 2 // voltage divider 100k/100k on board #define HAS_BUTTON GPIO_NUM_36 // on board button (next to reset)