add check_battery

This commit is contained in:
cuu
2021-05-29 13:25:14 +08:00
parent 0824e292fd
commit 4e06a6e213
3 changed files with 118 additions and 42 deletions

View File

@@ -423,29 +423,6 @@ int glob_file(char*av) {
#endif
int bat_cap_to_pts(CONFIG*cfg) {
int pts;
long ret;
char c[12];
FILE *fptr;
if ((fptr = fopen(BAT_CAP, "r")) == NULL) {
printf("Error! Battery File cannot be opened\n");
// Program exits if the file pointer returns NULL.
return 0;
}
fscanf(fptr, "%[^\n]", c);
//printf("Data from the file:%s\n", c);
fclose(fptr);
ret = strtol(c, NULL, 10);
pts = (int)round( (float)ret/10.0 ) + 1;
return pts;
}
uint8_t print_lines8(CONFIG*cfg) {
uint8_t i,j,k;
int8_t w;
@@ -477,8 +454,6 @@ uint8_t print_lines8(CONFIG*cfg) {
row = 0;
rv = IsPaper();
cfg->max_pts = bat_cap_to_pts(cfg);
data = (uint8_t*)malloc(sizeof(uint8_t)*(pad+1));
i=0;
@@ -607,7 +582,7 @@ uint8_t print_image8(CONFIG*cfg){
addr = 0;
rv = IsPaper();
cfg->max_pts = bat_cap_to_pts(cfg);
while(y < height )
{
x=0;