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

@ -41,7 +41,7 @@ int main(int argc, char *const argv[]){
printf("Literally how could you pass an unspecified argument to this program"); printf("Literally how could you pass an unspecified argument to this program");
} }
} }
FILE * fd_now = fopen(CHARGE_NOW_PATH, "r"); FILE * fd_now = fopen(CHARGE_NOW_PATH, "r");
FILE * fd_full = fopen(CHARGE_FULL_PATH, "r"); FILE * fd_full = fopen(CHARGE_FULL_PATH, "r");
@ -72,15 +72,15 @@ int main(int argc, char *const argv[]){
} }
if(run_verbose){ if(run_verbose){
printf("Current charge: %d\n", c_now); printf("Current charge: %d\n microampere-hours", c_now);
printf("Full charge: %d\n", c_full); printf("Full charge: %d\n microampere-hours", c_full);
} }
if(!run_terse) { if(!run_terse) {
printf("Battery percentage: "); printf("Battery percentage: ");
} }
float pct = ((float)c_now) / ((float)c_full); float frac = ((float)c_now) / ((float)c_full);
printf("%f\n", pct); int pct = (int)(frac * 100);
printf("%d\n", pct);
return 0; return 0;
} }