diff --git a/platformio.ini b/platformio.ini index 81d113bb..6b79b58c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -788,7 +788,7 @@ board_build.partitions = ${esp32.default_partitions} [env:esp32_ulc] board = esp32-poe build_unflags = ${common.build_unflags} -build_flags = ${common.build_flags_esp32} -D WLED_RELEASE_NAME=ESP32_ULC -D RLYPIN=-1 -D WLED_USE_ETHERNET -D WLED_ETH_DEFAULT=6 -D LEDPIN=14 -D DEFAULT_LED_COUNT=37 -D APL_MILLIAMPS_DEFAULT=2500 -D BTNPIN=-1 -D WLED_DISABLE_BLYNK -D IRPIN=-1 -D USERMOD_ULC_BATTERYMANAGEMENT +build_flags = ${common.build_flags_esp32} -D WLED_RELEASE_NAME=ESP32_ULC -D RLYPIN=-1 -D WLED_USE_ETHERNET -D WLED_ETH_DEFAULT=6 -D LEDPIN=14 -D DEFAULT_LED_COUNT=37 -D APL_MILLIAMPS_DEFAULT=2500 -D BTNPIN=-1 -D WLED_DISABLE_BLYNK -D IRPIN=-1 -D USERMOD_ULC_BATTERYMANAGEMENT -D I2CSDAPIN=32 -D I2CSCLPIN=33 lib_deps = ${esp32.lib_deps} platform = espressif32@3.2 board_build.partitions = ${esp32.default_partitions} \ No newline at end of file diff --git a/usermods/ULC_Battery_Management/IP5306_I2C.h b/usermods/ULC_Battery_Management/IP5306_I2C.h index 2a9038ce..988c803b 100644 --- a/usermods/ULC_Battery_Management/IP5306_I2C.h +++ b/usermods/ULC_Battery_Management/IP5306_I2C.h @@ -194,12 +194,9 @@ union { class IP5306{ public: - /*@brief initialize i2c - @param sda and scl pin number + /*@brief initialize i2c */ - IP5306(uint8_t sda_pin=21, uint8_t scl_pin=22) { - Wire.begin(sda_pin,scl_pin); - + IP5306(void) { /*initialize register data*/ reg_SYS_CTL0_t.reg_byte = i2c_read(IP5306_ADDRESS,SYS_CTL0); reg_SYS_CTL1_t.reg_byte = i2c_read(IP5306_ADDRESS,SYS_CTL1); @@ -209,7 +206,6 @@ class IP5306{ reg_Charger_CTL1_t.reg_byte = i2c_read(IP5306_ADDRESS,Charger_CTL1); reg_Charger_CTL2_t.reg_byte = i2c_read(IP5306_ADDRESS,Charger_CTL2); reg_Charger_CTL3_t.reg_byte = i2c_read(IP5306_ADDRESS,Charger_CTL3); - } /*@brief write data to register diff --git a/usermods/ULC_Battery_Management/usermod_ulc_batterymanagement.h b/usermods/ULC_Battery_Management/usermod_ulc_batterymanagement.h index e3e9fd98..d96eeeef 100644 --- a/usermods/ULC_Battery_Management/usermod_ulc_batterymanagement.h +++ b/usermods/ULC_Battery_Management/usermod_ulc_batterymanagement.h @@ -9,14 +9,6 @@ #define USERMOD_BATTERY_MEASUREMENT_INTERVAL 5000 #endif -#ifndef USERMOD_IP5306_SDA - #define USERMOD_IP5306_SDA 32 -#endif - -#ifndef USERMOD_IP5306_SCL - #define USERMOD_IP5306_SCL 33 -#endif - #ifndef USERMOD_ABL_BATTERY #define USERMOD_ABL_BATTERY 1250 #endif @@ -61,6 +53,8 @@ class UsermodULCBatteryManagement : public Usermod { public: void setup() { + if (i2c_sda < 0 || i2c_scl < 0) return; + ip5306 = new IP5306(); nextReadTime = millis() + 5000;