15 /* the user has started to type in his/her UID. grab the last key and continue
16 * reading. Returns true if a UID was entered successfully.
17 * The UID will be entered as 5 digits. (shorter uids should be pre-padded
20 uid = last_key%10; /* 10 => 0, it was _not_ reset (hopefuly :) */
21 set_msg("UID? ", WRAP_NONE);
22 set_char((last_key%10)+'0', 5);
24 for (uidpos = 2; uidpos <= 5; uidpos++) {
26 if (last_key == KEY_RESET) {
30 uid = (uid*10) + (last_key%10);
31 set_char((last_key%10)+'0', 4+uidpos);
38 /* We ask for a pin, display a PIN: prompt. PINs must be a 4 digit number.
39 * Strictly, they must be 16-bit, but it's easier to use the guarantee that
40 * 4-digits numbers are < 65536
42 * Also display X's on screen as the pin is entered.
45 set_msg("PIN? ", WRAP_NONE);
46 for (pinpos = 1; pinpos <= 4; pinpos++) {
48 if (last_key == KEY_RESET) {
52 pin = (pin*10) + (last_key%10);
53 set_char('X', 4+pinpos);
58 void make_request(u8 selection) {
59 set_msg("REQUESTING", WRAP_NONE); /* XXX: maybe this isn't needed? */
60 switch(server_request(uid, pin, selection)) {
62 set_msg("THANK YOU!", WRAP_NONE);
64 case REQUEST_NO_MONEY:
65 set_msg("NO MONEY!", WRAP_NONE);
67 case REQUEST_SERVFAIL:
68 set_msg("SERV FAIL!", WRAP_NONE);
71 set_msg("NONE LEFT!", WRAP_NONE);
74 set_msg(" BAD SELN ", WRAP_NONE);
80 void selection_menu() {
81 /* we have a valid username & PIN number */
82 /* either ask for a 2-digit selection, or wait for coins to be entered */
83 /* get the username somehow? */
84 set_msg("ENTER SELECTION OR INSERT COINS ", WRAP_SCROLL);
87 if (coin_value) { /* we have coins inserted */
89 /* alternate between the price and a confirm message */
91 if (prev_coin != coin_value) {
92 print_amount(coin_value);
93 append_msg("0: CONFIRM", WRAP_ALTERNATE);
94 prev_coin = coin_value;
97 if (keypad_pressed()) {
100 scroll_msg("PRESS COIN REFUND");
103 switch (server_credit_account(uid, pin, coin_value)) {
106 set_msg(" SUCCESS! ");
111 set_msg(" FAILED! ");
119 /* coins were refunded */
122 if (selection) { /* half way through a selection */
124 if (keypad_pressed()) {
132 selection = selection * 10 + (last_key%10);
133 make_request(uid, pin, selection);
137 } else { /* else listen for the first key of a selection */
139 if (keypad_pressed()) {
146 selection = last_key%10;
153 void load_default_msg() {
154 /* FIXME: want this message to be changeable from the server */
155 set_msg("UNIVERSITY COMPUTER CLUB *** INSERT COINS OR USER-ID *** ",
159 void service_menu() {
160 while (door_open()) { /* don't quit until door is closed */
167 set_msg("UNIVERSITY", WRAP_NONE);
169 set_msg(" COMPUTER ", WRAP_NONE);
171 set_msg(" CLUB ", WRAP_NONE);
176 /* this needs to be a relatively tight loop to make sure we catch
177 * keypresses at the main menu
180 if (keypad_pressed()) {
181 if (last_key != KEY_RESET) {
182 if (uid_enter() && pin_enter()) {
183 /* authenticate them */
184 switch (server_authenticate(uid, pin)) {
189 set_msg(" BAD USER ", WRAP_NONE);
193 set_msg(" NO MONEY ", WRAP_NONE);
197 set_msg("YOUR ACCOUNT IS LOCKED", WRAP_SCROLL);
209 /* test door switch */
215 /* check on coin mech */
220 /* Initialize Stuff. Particularly some memory locations that can only be
221 * written in the first 64 clock cycles upon reset.
225 /* enable RTI & set rate */
231 chime(); /* turn chime on or of as need be */
233 /* scroll the display if need be too */
234 if (scroll_timer == 0) {
236 scroll_timer = SCROLL_TIME;