Skip to content

Commit

Permalink
read&restore backlight between "battery flash"
Browse files Browse the repository at this point in the history
+minor indent corrections
  • Loading branch information
Apaczer committed Aug 4, 2023
1 parent de5b3e5 commit 21da957
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ int main(int argc, char** argv)
unsigned int actioned = 0;
unsigned int battery_counter = 0;
unsigned int battery_flash_counter = 0;
unsigned int lid_sys = 0;
while(1){
usleep(40000);

Expand All @@ -351,29 +352,32 @@ int main(int argc, char** argv)
}

battery_flash_counter%=4000;

if ((battery_flash_counter<299)&&(battery_flash_counter>210)) {
if (battery_flash_counter < 210 || battery_flash_counter > 299) {
lid_sys = read_conf(MIYOO_LID_CONF, 5);
} else if (battery_flash_counter > 210 && battery_flash_counter < 299) {
//bright
if(version<3) {
if (version < 3) {
sprintf(buf, "echo %d > %s", ((battery_flash_counter % 6) +4), MIYOO_LID_CONF);
system(buf);
} else if(battery_flash_counter == 211) {
} else if (battery_flash_counter == 211) {
vir = open("/dev/miyoo_vir", O_RDWR);
if(vir > 0){
if (vir > 0) {
ioctl(vir, MIYOO_VIR_SET_MODE, 0);
close(vir);
}
}
} else if(battery_flash_counter==300 && version > 2 ) {
} else if (battery_flash_counter == 299 && version > 2 ) {
vir = open("/dev/miyoo_vir", O_RDWR);
if(vir > 0){
if (vir > 0) {
ioctl(vir, MIYOO_VIR_SET_MODE, 1);
close(vir);
}
} else if (battery_flash_counter == 210 || battery_flash_counter == 299) {
sprintf(buf, "echo %i > " MIYOO_LID_CONF, lid_sys);
system(buf);
}

ioctl(kbd, MIYOO_KBD_GET_HOTKEY, &ret);
if(ret == 0 && lastret == 0){
if (ret == 0 && lastret == 0) {
actioned = 0;
continue;
} else if (ret == lastret) {
Expand All @@ -391,8 +395,8 @@ int main(int argc, char** argv)
actioned = 1;
switch(actionmap[lastret-1]){
case 0:
;
break;
;
break;
case 1:
//printf("backlight++\n");
lid = read_conf(MIYOO_LID_CONF, 5);
Expand Down

0 comments on commit 21da957

Please sign in to comment.