kopia lustrzana https://github.com/dl9rdz/rdz_ttgo_sonde
fix AXP2101 battery voltage
rodzic
b5113e9c22
commit
a4744dbee1
|
@ -263,4 +263,29 @@ fonts=0,1
|
|||
6,0=xDist:
|
||||
6,6=gD
|
||||
|
||||
###########
|
||||
#
|
||||
# Default configuration for "Scanner" display:
|
||||
# - view timer disabled; rx timer=0; norx timer = 0
|
||||
# => after 1 second immediately an action is triggered
|
||||
# (norx: go to next sonde; rx: go to default receiver display)
|
||||
# - key1 actions: D,0,F,W
|
||||
# => Button press activates default receiver view, double press does nothing
|
||||
# Mid press activates Spectrum display, long press activates Wifi scan
|
||||
# - key2 has no function
|
||||
@ScannerBatt
|
||||
timer=-1,0,0
|
||||
key1action=D,#,F,W
|
||||
key2action=D,#,#,#
|
||||
timeaction=#,D,+
|
||||
0,0=XScan
|
||||
0,5=S#:
|
||||
0,9=T
|
||||
2,0,16=s
|
||||
3,0=F MHz
|
||||
6,0=bS
|
||||
6,2=bVVb
|
||||
6,10=bUVu
|
||||
7,0=gV
|
||||
7,5=n
|
||||
|
||||
|
|
|
@ -1699,6 +1699,16 @@ void Display::drawBatt(DispEntry *de) {
|
|||
snprintf(buf, 30, "%.2f%s", val/1000, de->extra+1);
|
||||
Serial.printf("Vbatt: %s\n", buf);
|
||||
break;
|
||||
case 'U':
|
||||
if(sonde.config.type == TYPE_M5_CORE2) {
|
||||
val = pmu->getAcinVoltage();
|
||||
} else {
|
||||
val = pmu->getVbusVoltage();
|
||||
}
|
||||
if(val<0) { *buf=0; break; }
|
||||
snprintf(buf, 30, "%.2f%s", val/1000, de->extra+1);
|
||||
Serial.printf("Vbus: %s\n", buf);
|
||||
break;
|
||||
}
|
||||
if(pmu->type==TYPE_AXP192) {
|
||||
switch(de->extra[0]) {
|
||||
|
@ -1712,15 +1722,6 @@ void Display::drawBatt(DispEntry *de) {
|
|||
snprintf(buf, 30, "%.2f%s", val, de->extra+1);
|
||||
Serial.printf("Idischarge: %s\n", buf);
|
||||
break;
|
||||
case 'U':
|
||||
if(sonde.config.type == TYPE_M5_CORE2) {
|
||||
val = pmu->getAcinVoltage();
|
||||
} else {
|
||||
val = pmu->getVbusVoltage();
|
||||
}
|
||||
snprintf(buf, 30, "%.2f%s", val/1000, de->extra+1);
|
||||
Serial.printf("Vbus: %s\n", buf);
|
||||
break;
|
||||
case 'I':
|
||||
if(sonde.config.type == TYPE_M5_CORE2) {
|
||||
val = pmu->getAcinCurrent();
|
||||
|
|
|
@ -374,12 +374,16 @@ float AXP192PMU::getTemperature() {
|
|||
#define AXP2101_LDO_ONOFF_CTRL0 (0x90)
|
||||
#define AXP2101_LDO_ONOFF_CTRL1 (0x91)
|
||||
|
||||
// Not the right name....
|
||||
#define AXP2101_LDO_VOL0_CTRL (0x82)
|
||||
|
||||
#define AXP2101_LDO_VOL1_CTRL (0x93)
|
||||
#define AXP2101_LDO_VOL2_CTRL (0x94)
|
||||
|
||||
#define AXP2101_ADC_CHANNEL_CTRL (0x30)
|
||||
#define AXP2101_PMU_ADC0 (0x34)
|
||||
#define AXP2101_PMU_ADC1 (0x36)
|
||||
#define AXP2101_PMU_ADC2 (0x38)
|
||||
|
||||
// vterm_cfg: Bit 2:0, 4.2V = 011 (3)
|
||||
#define AXP2101_CHG_V_CFG (0x64)
|
||||
|
@ -435,6 +439,8 @@ int AXP2101PMU::init() {
|
|||
|
||||
// ESP32 VDD 3300mV
|
||||
// No need to set, automatically open , Don't close it
|
||||
val = readRegister(AXP2101_LDO_VOL0_CTRL);
|
||||
Serial.printf("VDD: %x\n", val);
|
||||
|
||||
// LoRa VDD 3300mV on ALDO2
|
||||
val = readRegister(AXP2101_LDO_VOL1_CTRL);
|
||||
|
@ -545,11 +551,10 @@ int AXP2101PMU::isCharging() {
|
|||
// PMU status2, bit 6:5 == 01 => charge (00: standby, 10: discharge)
|
||||
return (val & 0x60) == 0x20 ? 1 : 0;
|
||||
}
|
||||
float AXP2101PMU::getBattVoltage() {
|
||||
int hi = readRegister(AXP2101_PMU_ADC0);
|
||||
float AXP2101PMU::getBattVoltage() { // returns mV
|
||||
int hi = readRegister(AXP2101_PMU_ADC0) & 0x3F;
|
||||
int lo = readRegister(AXP2101_PMU_ADC0+1);
|
||||
if( (hi==-1) || (lo==-1) ) return -1;
|
||||
return ((hi<<8) | lo ) * 0.001;
|
||||
return (float)((hi<<8) | lo );
|
||||
}
|
||||
|
||||
float AXP2101PMU::getBattDischargeCurrent() { return -1; }
|
||||
|
@ -557,10 +562,12 @@ float AXP2101PMU::getBattChargeCurrent() { return -1; }
|
|||
float AXP2101PMU::getAcinVoltage() { return -1; }
|
||||
float AXP2101PMU::getAcinCurrent() { return -1; }
|
||||
float AXP2101PMU::getVbusVoltage() {
|
||||
int hi = readRegister(AXP2101_PMU_ADC1);
|
||||
int lo = readRegister(AXP2101_PMU_ADC1+2);
|
||||
if( (hi==-1) || (lo==-1) ) return -1;
|
||||
return ((hi<<8) | lo ) * 0.001;
|
||||
int hi = readRegister(AXP2101_PMU_ADC2) & 0x3F;
|
||||
int lo = readRegister(AXP2101_PMU_ADC2+1);
|
||||
Serial.printf("vbus: %d %d\n", hi, lo);
|
||||
float vbus = (float)((hi<<8) | lo );
|
||||
if(vbus>7000) return -1;
|
||||
return vbus;
|
||||
}
|
||||
float AXP2101PMU::getVbusCurrent() { return -1; }
|
||||
float AXP2101PMU::getTemperature() { return -1; }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const char *version_name = "rdzTTGOsonde";
|
||||
const char *version_id = "devel20240419";
|
||||
const char *version_id = "devel20240514";
|
||||
const int SPIFFS_MAJOR=2;
|
||||
const int SPIFFS_MINOR=17;
|
||||
|
|
Ładowanie…
Reference in New Issue