Added units to verbose output and changed battery level from a fractional

float to a percentage.
This commit is contained in:
Sandy Mossgrave 2023-03-22 05:22:41 +00:00
parent 006725f4a3
commit 4a942d92f7

View File

@ -72,15 +72,15 @@ int main(int argc, char *const argv[]){
}
if(run_verbose){
printf("Current charge: %d\n", c_now);
printf("Full charge: %d\n", c_full);
printf("Current charge: %d\n microampere-hours", c_now);
printf("Full charge: %d\n microampere-hours", c_full);
}
if(!run_terse) {
printf("Battery percentage: ");
}
float pct = ((float)c_now) / ((float)c_full);
printf("%f\n", pct);
float frac = ((float)c_now) / ((float)c_full);
int pct = (int)(frac * 100);
printf("%d\n", pct);
return 0;
}