Skip to content

fix reporting charging status #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions Code/picocalc_keyboard/picocalc_keyboard.ino
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ void receiveEvent(int howMany) {
case REG_ID_BAT:{
//Serial1.print("REG_ID_BAT getBatteryPercent:");Serial1.print(current_bat_pcnt);Serial1.println("%");
write_buffer[0] = reg;
write_buffer[1] = (uint8_t)current_bat_pcnt;

write_buffer[1] = reg_get_value(REG_ID_BAT);
}break;
case REG_ID_KEY: {
write_buffer[0] = fifo_count();
Expand Down Expand Up @@ -171,16 +170,6 @@ void receiveEvent(int howMany) {
//-this is after receiveEvent-------------------------------
void requestEvent() { Wire.write(write_buffer,write_buffer_len ); }

void report_bat(){
if (PMU.isBatteryConnect()) {
write_buffer[0] = REG_ID_BAT;
write_buffer[1] = PMU.getBatteryPercent();

write_buffer_len = 2;
requestEvent();
}
}

void printPMU() {
Serial1.print("isCharging:");
Serial1.println(PMU.isCharging() ? "YES" : "NO");
Expand Down Expand Up @@ -269,15 +258,12 @@ void check_pmu_int() {
// set the threshold through getLowBatWarnThreshold( 5% ~ 20% )
if (PMU.isDropWarningLevel2Irq()) {
Serial1.println("isDropWarningLevel2");
report_bat();
}

// When the set low-voltage battery percentage shutdown threshold is reached
// set the threshold through setLowBatShutdownThreshold()
//This is related to the battery charging and discharging logic. If you're not sure what you're doing, please don't modify it, as it could damage the battery.
if (PMU.isDropWarningLevel1Irq()) {
report_bat();
//
PMU.shutdown();
}
if (PMU.isGaugeWdtTimeoutIrq()) {
Expand Down