@@ -85,6 +85,37 @@ int digitalRead(ExpanderPin pin) {
8585 return readBitRegister (pin.address , 0xF , pin.pin );
8686}
8787
88+ void NessoBattery::enableCharge () {
89+ // AW32001E - address 0x49
90+ // set CEB bit low (charge enable)
91+ if (!wireInitialized) {
92+ WireInternal.begin (SDA, SCL);
93+ wireInitialized = true ;
94+ }
95+ writeBitRegister (0x49 , 0x1 , 3 , false );
96+ }
97+
98+ float NessoBattery::getVoltage () {
99+ // BQ27220 - address 0x55
100+ if (!wireInitialized) {
101+ WireInternal.begin (SDA, SCL);
102+ wireInitialized = true ;
103+ }
104+ uint16_t voltage = (readRegister (0x55 , 0x9 ) << 8 ) | readRegister (0x55 , 0x8 );
105+ return (float )voltage / 1000 .0f ;
106+ }
107+
108+ uint16_t NessoBattery::getChargeLevel () {
109+ // BQ27220 - address 0x55
110+ if (!wireInitialized) {
111+ WireInternal.begin (SDA, SCL);
112+ wireInitialized = true ;
113+ }
114+ uint16_t current_capacity = readRegister (0x55 , 0x11 ) << 8 | readRegister (0x55 , 0x10 );
115+ uint16_t total_capacity = readRegister (0x55 , 0x13 ) << 8 | readRegister (0x55 , 0x12 );
116+ return (current_capacity * 100 ) / total_capacity;
117+ }
118+
88119ExpanderPin LORA_LNA_ENABLE (5 );
89120ExpanderPin LORA_ANTENNA_SWITCH (6 );
90121ExpanderPin LORA_ENABLE (7 );
0 commit comments