X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=ROM2%2Fmain.c;h=c2758019387da8443fa96bd909b820ac3937774e;hb=3781ef6863f304c8242fc1216cddbdbb0c74bebe;hp=116704b77580ba29241eb52b9cf114deeb7e35eb;hpb=1e7218d1311dafb5c1c81e4c4ad64847432be0b5;p=uccvend-snackrom.git diff --git a/ROM2/main.c b/ROM2/main.c index 116704b..c275801 100644 --- a/ROM2/main.c +++ b/ROM2/main.c @@ -1,11 +1,14 @@ #include "display.h" #include "keypad.h" #include "chime.h" +#include "server.h" #include "vend.h" u16 uid; u16 pin; +u16 scroll_timer; + bool uid_enter() { u8 uidpos; /* the user has started to type in his/her UID. grab the last key and continue @@ -51,6 +54,10 @@ bool pin_enter() { return 1; } +void selection_menu() { + set_msg("ENTER SELECTION OR INSERT COINS", WRAP_SCROLL); +} + int main() { /* do stuff */ set_msg("UNIVERSITY", WRAP_NONE); @@ -60,21 +67,38 @@ int main() { set_msg(" CLUB ", WRAP_NONE); delay(1000); - set_msg("UCC *** INSERT COINS OR USER-ID", WRAP_SCROLL_L); + /* FIXME: want this message to be changeable from the server */ + set_msg("UNIVERISTY COMPUTER CLUB *** INSERT COINS OR USER-ID ***", + WRAP_SCROLL); while(1) { /* this needs to be a relatively tight loop to make sure we catch - * keypresses + * keypresses at the main menu */ keypad_read(); if (keypad_pressed()) { if (last_key != KEY_RESET) { if (uid_enter() && pin_enter()) { /* authenticate them */ - } else { - uid = 0; - pin = 0; - /* move on */ + switch (server_authenticate(uid, pin)) { + case AUTH_GOOD: + selection_menu(); + case AUTH_BAD: + set_msg(" BAD USER ", WRAP_NONE); + delay(1000); + break; + case AUTH_NO_MONEY: + set_msg(" NO MONEY ", WRAP_NONE); + delay(1000); + break; + case AUTH_LOCKED: + set_msg("YOUR ACCOUNT IS LOCKED", WRAP_SCROLL); + delay(1000); + break; + } } + uid = 0; + pin = 0; + /* move on */ } } } @@ -92,5 +116,12 @@ void _start() { } void rti() { - chime(); + chime(); /* turn chime on or of as need be */ + + /* scroll the display if need be too */ + if (scroll_timer == 0) { + display_shift(); + scroll_timer = SCROLL_TIME; + } + scroll_timer--; }