Skip to content

Commit

Permalink
修复一个可能导致充电一直99%的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chase535 authored Nov 3, 2022
1 parent c94958d commit 48fda4b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions accurate_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ void set_value(char *file, char *numb)
int main()
{
FILE *fm, *fp;
char battery[4];
int power, current, full=0;
char battery[4], status[20];
int power, full=0;
while(1)
{
memset(battery, '\0', sizeof(battery));
Expand All @@ -45,11 +45,11 @@ int main()
{
if(! full)
{
fp = fopen("/sys/class/power_supply/bms/current_now", "rt");
fp = fopen("/sys/class/power_supply/bms/status", "rt");
if(fp != NULL)
{
fscanf(fp, "%d", &current);
full = (current)?0:1;
fscanf(fp, "%s", status);
full = (status == "Charging")?0:1;
fclose(fp);
fp = NULL;
}
Expand Down

0 comments on commit 48fda4b

Please sign in to comment.