minor AXP192/AXP2101 battery measurement enhancements

This commit is contained in:
Hansi, dl9rdz 2024-08-31 17:12:35 +00:00
parent 4387237deb
commit cbd0c32545
2 changed files with 18 additions and 4 deletions

View File

@ -1731,7 +1731,13 @@ void Display::drawBatt(DispEntry *de) {
} else {
val = pmu->getVbusVoltage();
}
if(val<0) { *buf=0; break; }
if(val<0) { // make sure to clear old text...
int len = strlen(de->extra)-1 + 4;
strcpy(buf, " ");
if(len>29) len=29;
buf[len] = 0;
break;
}
snprintf(buf, 30, "%.2f%s", val/1000, de->extra+1);
Serial.printf("Vbus: %s\n", buf);
break;
@ -1844,19 +1850,23 @@ void Display::updateDisplay() {
// Called when key is pressed or new RX starts
void Display::dispsavectlON() {
// nothing to do to turn display on, may add power on code here later
Serial.println("DISP SAVE: ON");
dispstate = 1;
}
// Should be called 1x / sec to update display
// parameter: rxactive (1=currently receiving something, 0=no rx)
void Display::dispsavectlOFF(int rxactive) {
Serial.printf("DISP SAVE: OFF %d (state is %d)\n", rxactive, dispstate);
if( sonde.config.dispsaver == 0 ) return; // screensaver disabled
if( dispstate == 0 ) return; // already OFF
if( rxactive && ((sonde.config.dispsaver%10)==2) ) return; // OFF only if no RX, but rxactive is 0
dispstate++;
Serial.printf("dispstate is %d\n", dispstate);
if( dispstate > (sonde.config.dispsaver/10) ) {
rdis->clear();
dispstate = 0;
Serial.println("Clearning display");
}
}

View File

@ -188,7 +188,7 @@ int AXP192PMU::init() {
enableLDO3();
// ADC configuration: Enable monitoring of USB [bits 2,3 in enable register]
uint8_t val = readRegister(AXP192_ADC_EN1);
writeRegister(AXP192_ADC_EN1, val | (1 << 4) | (1 << 5) );
writeRegister(AXP192_ADC_EN1, val | (1 << 2) | (1 << 3) );
}
// Common configuration for T-Beam and M5 Core2
// DCDC2: M5Core: Unused, T-Beam: Unused, so set to disabled!! (was enabled in previous versions)
@ -338,7 +338,9 @@ float AXP192PMU::getBattChargeCurrent() {
#define AXP192_ACIN_VOLTAGE_STEP (1.7F)
float AXP192PMU::getAcinVoltage() {
return readRegisters_8_4(AXP192_ACIN_VOL_H8, AXP192_ACIN_VOL_L4) * AXP192_ACIN_VOLTAGE_STEP;
float f = readRegisters_8_4(AXP192_ACIN_VOL_H8, AXP192_ACIN_VOL_L4) * AXP192_ACIN_VOLTAGE_STEP;
Serial.printf("Acin: %f\n", f);
return f;
}
#define AXP192_ACIN_CUR_STEP (0.625F)
@ -348,7 +350,9 @@ float AXP192PMU::getAcinCurrent() {
#define AXP192_VBUS_VOLTAGE_STEP (1.7F)
float AXP192PMU::getVbusVoltage() {
return readRegisters_8_4(AXP192_VBUS_VOL_H8, AXP192_VBUS_VOL_L4) * AXP192_VBUS_VOLTAGE_STEP;
float f= readRegisters_8_4(AXP192_VBUS_VOL_H8, AXP192_VBUS_VOL_L4) * AXP192_VBUS_VOLTAGE_STEP;
Serial.printf("Vbus: %f\n", f);
return f;
}
#define AXP192_VBUS_CUR_STEP (0.375F)