Skip to content

Commit 1c67da5

Browse files
committed
Adjust Charger logs.
1 parent 7240f67 commit 1c67da5

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

device/src/keyboard/charger.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,12 @@ static void updateMaxCharge() {
104104
static bool updateBatteryPresent() {
105105
uint32_t statPeriod = MIN((uint32_t)(lastStatZeroTime - lastStatOneTime), (uint32_t)(lastStatOneTime-lastStatZeroTime));
106106
uint32_t lastStat = MAX(lastStatZeroTime, lastStatOneTime);
107+
bool lastStatValue = lastStatOneTime > lastStatZeroTime;
107108
bool batteryOscilates = statPeriod < CHARGER_STAT_PERIOD;
108109
bool changedRecently = (Timer_GetCurrentTime() - lastStat) < CHARGER_STAT_PERIOD;
109110
bool batteryMissing = (changedRecently && batteryOscilates);
110111
bool batteryPresent = !batteryMissing;
112+
LOG_INF("Stat: %d, Battery present: %d, batteryOscilates: %d, changedRecently: %d, lastStatZeroTime: %d, lastStatOneTime: %d\n", lastStatValue, batteryPresent, batteryOscilates, changedRecently, lastStatZeroTime, lastStatOneTime);
111113
return setBatteryPresent(batteryPresent);
112114
}
113115

@@ -133,7 +135,9 @@ static uint16_t getVoltage() {
133135
adc_read(adc_channel.dev, &sequence);
134136
int32_t val_mv = (int32_t)buf;
135137
adc_raw_to_millivolts_dt(&adc_channel, &val_mv);
136-
return (uint16_t)(VOLTAGE_DIVIDER_MULTIPLIER*val_mv);
138+
uint16_t result = (uint16_t)(VOLTAGE_DIVIDER_MULTIPLIER*val_mv);
139+
LOG_INF("Raw voltage: %d mV", result);
140+
return result;
137141
}
138142

139143
static void printState(battery_state_t* state) {
@@ -434,9 +438,6 @@ void InitCharger_Min(void) {
434438
}
435439

436440
void InitCharger(void) {
437-
log_filter_set(NULL, 0, log_source_id_get("Battery"), LOG_LEVEL_WRN);
438-
439-
440441
InitCharger_Min();
441442

442443
gpio_pin_configure_dt(&chargerEnDt, GPIO_OUTPUT);

0 commit comments

Comments
 (0)