Use global I2C instance, instead of custom
This commit is contained in:
parent
b477304a15
commit
c39cacf311
@ -788,7 +788,7 @@ board_build.partitions = ${esp32.default_partitions}
|
|||||||
[env:esp32_ulc]
|
[env:esp32_ulc]
|
||||||
board = esp32-poe
|
board = esp32-poe
|
||||||
build_unflags = ${common.build_unflags}
|
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}
|
lib_deps = ${esp32.lib_deps}
|
||||||
platform = espressif32@3.2
|
platform = espressif32@3.2
|
||||||
board_build.partitions = ${esp32.default_partitions}
|
board_build.partitions = ${esp32.default_partitions}
|
@ -194,12 +194,9 @@ union {
|
|||||||
|
|
||||||
class IP5306{
|
class IP5306{
|
||||||
public:
|
public:
|
||||||
/*@brief initialize i2c
|
/*@brief initialize i2c
|
||||||
@param sda and scl pin number
|
|
||||||
*/
|
*/
|
||||||
IP5306(uint8_t sda_pin=21, uint8_t scl_pin=22) {
|
IP5306(void) {
|
||||||
Wire.begin(sda_pin,scl_pin);
|
|
||||||
|
|
||||||
/*initialize register data*/
|
/*initialize register data*/
|
||||||
reg_SYS_CTL0_t.reg_byte = i2c_read(IP5306_ADDRESS,SYS_CTL0);
|
reg_SYS_CTL0_t.reg_byte = i2c_read(IP5306_ADDRESS,SYS_CTL0);
|
||||||
reg_SYS_CTL1_t.reg_byte = i2c_read(IP5306_ADDRESS,SYS_CTL1);
|
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_CTL1_t.reg_byte = i2c_read(IP5306_ADDRESS,Charger_CTL1);
|
||||||
reg_Charger_CTL2_t.reg_byte = i2c_read(IP5306_ADDRESS,Charger_CTL2);
|
reg_Charger_CTL2_t.reg_byte = i2c_read(IP5306_ADDRESS,Charger_CTL2);
|
||||||
reg_Charger_CTL3_t.reg_byte = i2c_read(IP5306_ADDRESS,Charger_CTL3);
|
reg_Charger_CTL3_t.reg_byte = i2c_read(IP5306_ADDRESS,Charger_CTL3);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@brief write data to register
|
/*@brief write data to register
|
||||||
|
@ -9,14 +9,6 @@
|
|||||||
#define USERMOD_BATTERY_MEASUREMENT_INTERVAL 5000
|
#define USERMOD_BATTERY_MEASUREMENT_INTERVAL 5000
|
||||||
#endif
|
#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
|
#ifndef USERMOD_ABL_BATTERY
|
||||||
#define USERMOD_ABL_BATTERY 1250
|
#define USERMOD_ABL_BATTERY 1250
|
||||||
#endif
|
#endif
|
||||||
@ -61,6 +53,8 @@ class UsermodULCBatteryManagement : public Usermod {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
if (i2c_sda < 0 || i2c_scl < 0) return;
|
||||||
|
|
||||||
ip5306 = new IP5306();
|
ip5306 = new IP5306();
|
||||||
|
|
||||||
nextReadTime = millis() + 5000;
|
nextReadTime = millis() + 5000;
|
||||||
|
Loading…
Reference in New Issue
Block a user