16 /* the user has started to type in his/her UID. grab the last key and continue
17 * reading. Returns true if a UID was entered successfully.
18 * The UID will be entered as 5 digits. (shorter uids should be pre-padded
21 uid = last_key%10; /* 10 => 0, it was _not_ reset (hopefuly :) */
22 set_msg("UID? ", WRAP_NONE);
23 set_char((last_key%10)+'0', 5);
25 for (uidpos = 2; uidpos <= 5; uidpos++) {
27 if (last_key == KEY_RESET) {
31 uid = (uid*10) + (last_key%10);
32 set_char((last_key%10)+'0', 4+uidpos);
39 /* We ask for a pin, display a PIN: prompt. PINs must be a 4 digit number.
40 * Strictly, they must be 16-bit, but it's easier to use the guarantee that
41 * 4-digits numbers are < 65536
43 * Also display X's on screen as the pin is entered.
46 set_msg("PIN? ", WRAP_NONE);
47 for (pinpos = 1; pinpos <= 4; pinpos++) {
49 if (last_key == KEY_RESET) {
53 pin = (pin*10) + (last_key%10);
54 set_char('X', 4+pinpos);
59 void make_request(u8 selection) {
60 set_msg("REQUESTING", WRAP_NONE); /* XXX: maybe this isn't needed? */
61 switch(server_request(uid, pin, selection)) {
63 set_msg("THANK YOU!", WRAP_NONE);
65 case REQUEST_NO_MONEY:
66 set_msg("NO MONEY!", WRAP_NONE);
68 case REQUEST_SERVFAIL:
69 set_msg("SERV FAIL!", WRAP_NONE);
72 set_msg("NONE LEFT!", WRAP_NONE);
75 set_msg(" BAD SELN ", WRAP_NONE);
81 void selection_menu() {
82 /* we have a valid username & PIN number */
83 /* either ask for a 2-digit selection, or wait for coins to be entered */
84 /* get the username somehow? */
85 set_msg("ENTER SELECTION OR INSERT COINS ", WRAP_SCROLL);
88 if (coin_value) { /* we have coins inserted */
90 /* alternate between the price and a confirm message */
92 if (prev_coin != coin_value) {
93 print_amount(coin_value);
94 append_msg("0: CONFIRM", WRAP_ALTERNATE);
95 prev_coin = coin_value;
98 if (keypad_pressed()) {
101 scroll_msg("PRESS COIN REFUND");
105 switch (server_credit_account(uid, pin, coin_value)) {
108 set_msg(" SUCCESS! ", WRAP_NONE);
112 set_msg(" FAILED! " "PRESS COIN" " REFUND ",
121 /* coins were refunded */
124 if (selection) { /* half way through a selection */
126 if (keypad_pressed()) {
134 selection = selection * 10 + (last_key%10);
135 make_request(selection);
139 } else { /* else listen for the first key of a selection */
141 if (keypad_pressed()) {
148 selection = last_key%10;
155 void load_default_msg() {
156 /* FIXME: want this message to be changeable from the server */
157 set_msg("UNIVERSITY COMPUTER CLUB *** INSERT COINS OR USER-ID *** ",
161 void service_menu() {
162 while (door_open()) { /* don't quit until door is closed */
169 set_msg("UNIVERSITY", WRAP_NONE);
171 set_msg(" COMPUTER ", WRAP_NONE);
173 set_msg(" CLUB ", WRAP_NONE);
178 /* this needs to be a relatively tight loop to make sure we catch
179 * keypresses at the main menu
182 if (keypad_pressed()) {
183 if (last_key != KEY_RESET) {
184 if (uid_enter() && pin_enter()) {
185 /* authenticate them */
186 switch (server_authenticate(uid, pin)) {
191 set_msg(" BAD USER ", WRAP_NONE);
195 set_msg(" NO MONEY ", WRAP_NONE);
199 set_msg("YOUR ACCOUNT IS LOCKED", WRAP_SCROLL);
211 /* test door switch */
217 /* check on coin mech */
222 /* Initialize Stuff. Particularly some memory locations that can only be
223 * written in the first 64 clock cycles upon reset.
227 /* enable RTI & set rate */
233 chime(); /* turn chime on or of as need be */
235 /* scroll the display if need be too */
236 if (scroll_timer == 0) {
238 scroll_timer = SCROLL_TIME;