17 /* the user has started to type in his/her UID. grab the last key and continue
18 * reading. Returns true if a UID was entered successfully.
19 * The UID will be entered as 5 digits. (shorter uids should be pre-padded
22 uid = last_key%10; /* 10 => 0, it was _not_ reset (hopefuly :) */
23 set_msg("UID? ", WRAP_NONE);
24 set_char((last_key%10)+'0', 5);
26 for (uidpos = 2; uidpos <= 5; uidpos++) {
28 if (last_key == KEY_RESET) {
32 uid = (uid*10) + (last_key%10);
33 set_char((last_key%10)+'0', 4+uidpos);
40 /* We ask for a pin, display a PIN: prompt. PINs must be a 4 digit number.
41 * Strictly, they must be 16-bit, but it's easier to use the guarantee that
42 * 4-digits numbers are < 65536
44 * Also display X's on screen as the pin is entered.
47 set_msg("PIN? ", WRAP_NONE);
48 for (pinpos = 1; pinpos <= 4; pinpos++) {
50 if (last_key == KEY_RESET) {
54 pin = (pin*10) + (last_key%10);
55 set_char('X', 4+pinpos);
60 void make_request(u8 selection) {
61 set_msg("REQUESTING", WRAP_NONE); /* XXX: maybe this isn't needed? */
62 switch(server_request(uid, pin, selection)) {
64 set_msg("THANK YOU!", WRAP_NONE);
66 case REQUEST_NO_MONEY:
67 set_msg("NO MONEY!", WRAP_NONE);
69 case REQUEST_SERVFAIL:
70 set_msg("SERV FAIL!", WRAP_NONE);
73 set_msg("NONE LEFT!", WRAP_NONE);
76 set_msg(" BAD SELN ", WRAP_NONE);
82 void selection_menu() {
83 /* we have a valid username & PIN number */
84 /* either ask for a 2-digit selection, or wait for coins to be entered */
85 /* get the username somehow? */
86 set_msg("ENTER SELECTION OR INSERT COINS ", WRAP_SCROLL);
89 if (coin_value) { /* we have coins inserted */
91 /* alternate between the price and a confirm message */
93 if (prev_coin != coin_value) {
94 print_amount(coin_value);
95 append_msg("0: CONFIRM", WRAP_ALTERNATE);
96 prev_coin = coin_value;
99 if (keypad_pressed()) {
102 scroll_msg("PRESS COIN REFUND");
106 switch (server_credit_account(uid, pin, coin_value)) {
109 set_msg(" SUCCESS! ", WRAP_NONE);
113 set_msg(" FAILED! " "PRESS COIN" " REFUND ",
122 /* coins were refunded */
125 if (selection) { /* half way through a selection */
127 if (keypad_pressed()) {
135 selection = selection * 10 + (last_key%10);
136 make_request(selection);
140 } else { /* else listen for the first key of a selection */
142 if (keypad_pressed()) {
149 selection = last_key%10;
156 void load_default_msg() {
157 /* FIXME: want this message to be changeable from the server */
158 set_msg("UNIVERSITY COMPUTER CLUB *** INSERT COINS OR USER-ID *** ",
162 void service_menu() {
163 while (door_open()) { /* don't quit until door is closed */
170 set_msg("UNIVERSITY", WRAP_NONE);
172 set_msg(" COMPUTER ", WRAP_NONE);
174 set_msg(" CLUB ", WRAP_NONE);
179 /* this needs to be a relatively tight loop to make sure we catch
180 * keypresses at the main menu
183 if (keypad_pressed()) {
184 if (last_key != KEY_RESET) {
185 if (uid_enter() && pin_enter()) {
186 /* authenticate them */
187 switch (server_authenticate(uid, pin)) {
192 set_msg(" BAD USER ", WRAP_NONE);
196 set_msg(" NO MONEY ", WRAP_NONE);
200 set_msg("YOUR ACCOUNT IS LOCKED", WRAP_SCROLL);
212 /* test door switch */
218 /* check on coin mech */
223 /* Initialize Stuff. Particularly some memory locations that can only be
224 * written in the first 64 clock cycles upon reset.
228 /* enable RTI & set rate */
234 chime(); /* turn chime on or of as need be */
236 /* scroll the display if need be too */
237 if (scroll_timer == 0) {
239 scroll_timer = SCROLL_TIME;