From: Bernard Blackham Date: Wed, 6 Aug 2003 16:16:50 +0000 (+0000) Subject: Beginnings of a UI. X-Git-Tag: ROMW~98 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=1e7218d1311dafb5c1c81e4c4ad64847432be0b5;p=uccvend-snackrom.git Beginnings of a UI. --- diff --git a/ROM2/helpers.c b/ROM2/helpers.c index 07ab7f4..ead76da 100644 --- a/ROM2/helpers.c +++ b/ROM2/helpers.c @@ -1,8 +1,8 @@ #include "vend.h" -#define DELAY_MAGIC 20 /* FIXME: number of loops required for ~ 1 millisecond */ +#define DELAY_MAGIC 20 /* FIXME: number of loops for ~ 1 millisecond (< 256) */ void delay(u16 ms) { - int i; + u8 i; for (;ms;ms--) { for (i=0;i 0, it was _not_ reset (hopefuly :) */ + set_msg("UID? ", WRAP_NONE); + set_char((last_key%10)+'0', 5); + + for (uidpos = 2; uidpos <= 5; uidpos++) { + keypad_getkey(); + if (last_key == KEY_RESET) { + uid = 0; + return 0; + } + uid = (uid*10) + (last_key%10); + set_char((last_key%10)+'0', 4+uidpos); + } + return 1; +} + + +bool pin_enter() { + u8 pinpos; + /* We ask for a pin, display a PIN: prompt. PINs must be a 4 digit number. + * Strictly, they must be 16-bit, but it's easier to use the guarantee that + * 4-digits numbers are < 65536 + * + * Also display X's on screen as the pin is entered. + */ + set_msg("PIN? ", WRAP_NONE); + for (pinpos = 1; pinpos <= 5; pinpos++) { + keypad_getkey(); + if (last_key == KEY_RESET) { + pin = 0; + return 0; + } + pin = (pin*10) + (last_key%10); + set_char('X', 4+pinpos); + } + return 1; +} + int main() { /* do stuff */ - set_msg("UNIVERSITY"); + set_msg("UNIVERSITY", WRAP_NONE); delay(1000); - set_msg(" COMPUTER "); + set_msg(" COMPUTER ", WRAP_NONE); delay(1000); - set_msg(" CLUB "); + set_msg(" CLUB ", WRAP_NONE); delay(1000); + set_msg("UCC *** INSERT COINS OR USER-ID", WRAP_SCROLL_L); while(1) { + /* this needs to be a relatively tight loop to make sure we catch + * keypresses + */ keypad_read(); if (keypad_pressed()) { - switch (last_key) { - + if (last_key != KEY_RESET) { + if (uid_enter() && pin_enter()) { + /* authenticate them */ + } else { + uid = 0; + pin = 0; + /* move on */ + } } } } @@ -28,6 +86,8 @@ void _start() { */ display_init(); set_bus_expanded(); + /* enable RTI & set rate */ + /* init coin mech */ main(); }