Terminal program for MailStation devices
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Ignore power button as first key seen, make it actually power down

I wasted a whole day debugging why this was seemingly crashing when
it turns out it was just getting into process_keyboard() and
peekkey() was returning KEY_POWER all the time at init time, which
just rebooted the machine.

By assigning KEY_POWER to lastkey, the debouncer will ignore it as
the first key pressed. Also add a blinking sequence before calling
the powerdown function instead of rebooting, to make it clear it's
not just crashing.

+9 -4
+9 -4
main.c
··· 69 69 unsigned int b, j; 70 70 71 71 restart: 72 - lastkey = 0; 72 + /* ignore first peekkey() if it returns power button */ 73 + lastkey = KEY_POWER; 73 74 esc = 0; 74 75 source = SOURCE_WIFI; 75 76 putchar_sgr = 0; ··· 250 251 251 252 switch (b) { 252 253 case KEY_POWER: 253 - __asm 254 - jp 0x0000 255 - __endasm; 254 + for (b = 0; b < 3; b++) { 255 + new_mail(1); 256 + delay(100); 257 + new_mail(0); 258 + delay(100); 259 + } 260 + powerdown_mode(); 256 261 break; 257 262 case KEY_F1: 258 263 if (modem_curmsr & MODEM_MSR_DCD)