diff --git a/src/battery_utils.cpp b/src/battery_utils.cpp index 8fb35b5..93e4ee4 100644 --- a/src/battery_utils.cpp +++ b/src/battery_utils.cpp @@ -1,17 +1,17 @@ /* Copyright (C) 2025 Ricardo Guzman - CA2RXU - * + * * This file is part of LoRa APRS iGate. - * + * * LoRa APRS iGate is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * LoRa APRS iGate is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with LoRa APRS iGate. If not, see . */ @@ -105,9 +105,9 @@ namespace BATTERY_Utils { void getI2CVoltageSensorAddress() { uint8_t err, addr; for(addr = 1; addr < 0x7F; addr++) { - #if defined(HELTEC_V3) || defined(HELTEC_V3_2) || defined(HELTEC_WSL_V3) || defined(HELTEC_WSL_V3_DISPLAY) - Wire1.beginTransmission(addr); - err = Wire1.endTransmission(); + #ifdef SENSOR_I2C_BUS + SENSOR_I2C_BUS.beginTransmission(addr); + err = SENSOR_I2C_BUS.endTransmission(); #else Wire.beginTransmission(addr); err = Wire.endTransmission(); @@ -145,7 +145,7 @@ namespace BATTERY_Utils { } } - float checkInternalVoltage() { + float checkInternalVoltage() { #if defined(HAS_AXP192) || defined(HAS_AXP2101) if(POWER_Utils::isBatteryConnected()) { return POWER_Utils::getBatteryVoltage(); @@ -153,7 +153,7 @@ namespace BATTERY_Utils { return 0.0; } #else - + #ifdef ADC_CTRL POWER_Utils::adc_ctrl_ON(); #endif @@ -177,7 +177,7 @@ namespace BATTERY_Utils { #endif #endif #endif - delay(3); + delay(3); } #ifdef ADC_CTRL @@ -241,7 +241,7 @@ namespace BATTERY_Utils { #else extVoltage = ((((sampleSum/100.0)* adcReadingTransformation) + readingCorrection) * voltageDividerTransformation) - multiplyCorrection; #endif - + return extVoltage; // raw voltage without mapping // return mapVoltage(voltage, 5.05, 6.32, 4.5, 5.5); // mapped voltage diff --git a/src/power_utils.cpp b/src/power_utils.cpp index e7ddb6f..7818e39 100644 --- a/src/power_utils.cpp +++ b/src/power_utils.cpp @@ -296,12 +296,8 @@ namespace POWER_Utils { Wire.begin(OLED_SDA, OLED_SCL); #endif - #ifdef USE_WIRE_WITH_BOARD_I2C_PINS - Wire.begin(BOARD_I2C_SDA, BOARD_I2C_SCL); - #endif - - #ifdef USE_WIRE1_WITH_BOARD_I2C_PINS - Wire1.begin(BOARD_I2C_SDA, BOARD_I2C_SCL); + #ifdef SENSOR_I2C_BUS + SENSOR_I2C_BUS.begin(BOARD_I2C_SDA, BOARD_I2C_SCL); #endif delay(1000); diff --git a/src/wx_utils.cpp b/src/wx_utils.cpp index d4de9d5..f0f19fc 100644 --- a/src/wx_utils.cpp +++ b/src/wx_utils.cpp @@ -61,9 +61,9 @@ namespace WX_Utils { void getWxModuleAddres() { uint8_t err, addr; for(addr = 1; addr < 0x7F; addr++) { - #if defined(HELTEC_V3) || defined(HELTEC_V3_2) || defined(HELTEC_WSL_V3) || defined(HELTEC_WSL_V3_DISPLAY) - Wire1.beginTransmission(addr); - err = Wire1.endTransmission(); + #ifdef SENSOR_I2C_BUS + SENSOR_I2C_BUS.beginTransmission(addr); + err = SENSOR_I2C_BUS.endTransmission(); #else Wire.beginTransmission(addr); #ifdef LIGHTGATEWAY_PLUS_1_0 diff --git a/variants/WEMOS_S2_MINI_DIY_LoRa/board_pinout.h b/variants/WEMOS_S2_MINI_DIY_LoRa/board_pinout.h index 7ab85c0..034ee6f 100644 --- a/variants/WEMOS_S2_MINI_DIY_LoRa/board_pinout.h +++ b/variants/WEMOS_S2_MINI_DIY_LoRa/board_pinout.h @@ -31,7 +31,7 @@ #define GPIO_WAKEUP_PIN GPIO_SEL_38 // I2C - #define USE_WIRE_WITH_BOARD_I2C_PINS + #define SENSOR_I2C_BUS Wire #define BOARD_I2C_SDA 11 #define BOARD_I2C_SCL 12 diff --git a/variants/XIAO_ESP32S3_WIO_SX1262/board_pinout.h b/variants/XIAO_ESP32S3_WIO_SX1262/board_pinout.h index 6a9b8cb..4aea3f7 100644 --- a/variants/XIAO_ESP32S3_WIO_SX1262/board_pinout.h +++ b/variants/XIAO_ESP32S3_WIO_SX1262/board_pinout.h @@ -39,8 +39,8 @@ #define INTERNAL_LED_PIN 48 // I2C - #define USE_WIRE_WITH_OLED_PINS - #define OLED_SDA 5 - #define OLED_SCL 6 + #define SENSOR_I2C_BUS Wire + #define BOARD_I2C_SDA 5 + #define BOARD_I2C_SCL 6 #endif \ No newline at end of file diff --git a/variants/heltec_vision_master_e290/board_pinout.h b/variants/heltec_vision_master_e290/board_pinout.h index 2dc06aa..43cb893 100644 --- a/variants/heltec_vision_master_e290/board_pinout.h +++ b/variants/heltec_vision_master_e290/board_pinout.h @@ -33,7 +33,7 @@ #define GPIO_WAKEUP_PIN GPIO_SEL_14 // I2C - #define USE_WIRE1_WITH_BOARD_I2C_PINS + #define SENSOR_I2C_BUS Wire1 #define BOARD_I2C_SDA 39 #define BOARD_I2C_SCL 38 diff --git a/variants/heltec_wifi_lora_32_V3/board_pinout.h b/variants/heltec_wifi_lora_32_V3/board_pinout.h index e57dee5..108df61 100644 --- a/variants/heltec_wifi_lora_32_V3/board_pinout.h +++ b/variants/heltec_wifi_lora_32_V3/board_pinout.h @@ -34,7 +34,7 @@ // I2C #define USE_WIRE_WITH_OLED_PINS - #define USE_WIRE1_WITH_BOARD_I2C_PINS + #define SENSOR_I2C_BUS Wire1 #define BOARD_I2C_SDA 41 #define BOARD_I2C_SCL 42 diff --git a/variants/heltec_wifi_lora_32_V3_2/board_pinout.h b/variants/heltec_wifi_lora_32_V3_2/board_pinout.h index 6217479..c075e75 100644 --- a/variants/heltec_wifi_lora_32_V3_2/board_pinout.h +++ b/variants/heltec_wifi_lora_32_V3_2/board_pinout.h @@ -34,7 +34,7 @@ // I2C #define USE_WIRE_WITH_OLED_PINS - #define USE_WIRE1_WITH_BOARD_I2C_PINS + #define SENSOR_I2C_BUS Wire1 #define BOARD_I2C_SDA 41 #define BOARD_I2C_SCL 42 diff --git a/variants/heltec_wifi_lora_32_V4/board_pinout.h b/variants/heltec_wifi_lora_32_V4/board_pinout.h index 3af5222..4100da5 100644 --- a/variants/heltec_wifi_lora_32_V4/board_pinout.h +++ b/variants/heltec_wifi_lora_32_V4/board_pinout.h @@ -34,7 +34,7 @@ // I2C #define USE_WIRE_WITH_OLED_PINS - #define USE_WIRE1_WITH_BOARD_I2C_PINS + #define SENSOR_I2C_BUS Wire1 #define BOARD_I2C_SDA 41 #define BOARD_I2C_SCL 42 diff --git a/variants/heltec_wireless_paper_v1/board_pinout.h b/variants/heltec_wireless_paper_v1/board_pinout.h index 8162903..677d6d0 100644 --- a/variants/heltec_wireless_paper_v1/board_pinout.h +++ b/variants/heltec_wireless_paper_v1/board_pinout.h @@ -33,7 +33,7 @@ #define GPIO_WAKEUP_PIN GPIO_SEL_14 // I2C - #define USE_WIRE1_WITH_BOARD_I2C_PINS + #define SENSOR_I2C_BUS Wire1 #define BOARD_I2C_SDA 37 #define BOARD_I2C_SCL 36 diff --git a/variants/heltec_wireless_paper_v1_2/board_pinout.h b/variants/heltec_wireless_paper_v1_2/board_pinout.h index 8162903..677d6d0 100644 --- a/variants/heltec_wireless_paper_v1_2/board_pinout.h +++ b/variants/heltec_wireless_paper_v1_2/board_pinout.h @@ -33,7 +33,7 @@ #define GPIO_WAKEUP_PIN GPIO_SEL_14 // I2C - #define USE_WIRE1_WITH_BOARD_I2C_PINS + #define SENSOR_I2C_BUS Wire1 #define BOARD_I2C_SDA 37 #define BOARD_I2C_SCL 36 diff --git a/variants/heltec_wireless_stick_lite_v3/board_pinout.h b/variants/heltec_wireless_stick_lite_v3/board_pinout.h index 9ba653b..fd2b3f2 100644 --- a/variants/heltec_wireless_stick_lite_v3/board_pinout.h +++ b/variants/heltec_wireless_stick_lite_v3/board_pinout.h @@ -33,7 +33,7 @@ #define GPIO_WAKEUP_PIN GPIO_SEL_14 // I2C - #define USE_WIRE1_WITH_BOARD_I2C_PINS + #define SENSOR_I2C_BUS Wire1 #define BOARD_I2C_SDA 41 #define BOARD_I2C_SCL 42 diff --git a/variants/heltec_wireless_stick_lite_v3_display/board_pinout.h b/variants/heltec_wireless_stick_lite_v3_display/board_pinout.h index 2aee179..20018ab 100644 --- a/variants/heltec_wireless_stick_lite_v3_display/board_pinout.h +++ b/variants/heltec_wireless_stick_lite_v3_display/board_pinout.h @@ -33,7 +33,7 @@ #define GPIO_WAKEUP_PIN GPIO_SEL_14 // I2C - #define USE_WIRE1_WITH_BOARD_I2C_PINS + #define SENSOR_I2C_BUS Wire1 #define BOARD_I2C_SDA 41 #define BOARD_I2C_SCL 42 diff --git a/variants/heltec_wireless_tracker/board_pinout.h b/variants/heltec_wireless_tracker/board_pinout.h index ffd4436..8a4da11 100644 --- a/variants/heltec_wireless_tracker/board_pinout.h +++ b/variants/heltec_wireless_tracker/board_pinout.h @@ -33,7 +33,7 @@ #define GPIO_WAKEUP_PIN GPIO_SEL_14 // I2C - #define USE_WIRE_WITH_BOARD_I2C_PINS + #define SENSOR_I2C_BUS Wire #define BOARD_I2C_SDA 7 #define BOARD_I2C_SCL 6 diff --git a/variants/ttgo_t_deck_GPS/board_pinout.h b/variants/ttgo_t_deck_GPS/board_pinout.h index f8cb0e2..d9d325f 100644 --- a/variants/ttgo_t_deck_GPS/board_pinout.h +++ b/variants/ttgo_t_deck_GPS/board_pinout.h @@ -33,7 +33,7 @@ #define GPIO_WAKEUP_PIN GPIO_SEL_45 // I2C - #define USE_WIRE_WITH_BOARD_I2C_PINS + #define SENSOR_I2C_BUS Wire #define BOARD_I2C_SDA 18 #define BOARD_I2C_SCL 8 diff --git a/variants/ttgo_t_deck_plus/board_pinout.h b/variants/ttgo_t_deck_plus/board_pinout.h index 82754ac..e2e54fe 100644 --- a/variants/ttgo_t_deck_plus/board_pinout.h +++ b/variants/ttgo_t_deck_plus/board_pinout.h @@ -33,7 +33,7 @@ #define GPIO_WAKEUP_PIN GPIO_SEL_45 // I2C - #define USE_WIRE_WITH_BOARD_I2C_PINS + #define SENSOR_I2C_BUS Wire #define BOARD_I2C_SDA 18 #define BOARD_I2C_SCL 8