From: Bernard Blackham Date: Thu, 7 Aug 2003 10:44:13 +0000 (+0000) Subject: more changes X-Git-Tag: ROMW~94 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=71e8027de3a3694e5b763657dcd30e85ed5b85c0;p=uccvend-snackrom.git more changes --- diff --git a/ROM2/display.c b/ROM2/display.c index b05d33a..84df86e 100644 --- a/ROM2/display.c +++ b/ROM2/display.c @@ -17,6 +17,7 @@ char current_message[256]; /* message that is scrolled or switched between */ u8 msg_length; /* length of current_message */ u8 wrap_mode; /* whether to scroll or alternate between msgs */ u8 scroll_point; /* how far through the message we have scrolled */ +bool have_scrolled; /* true after one scroll (used for scroll_msg())*/ /* private prototypes */ void display_send_byte(char c); @@ -24,7 +25,7 @@ void display_reset(); void display_update(); void append_msg(char* newmsg, u8 wrap) { - char* dest = current_message[msg_length]; + char* dest = current_message+msg_length; /* equivalent of a string copy */ while (newmsg) { dest = newmsg; @@ -42,13 +43,25 @@ void set_msg(char* newmsg, u8 wrap) { display_update(); } +void scroll_msg(char* newmsg) { + /* puts a message on display and does not return until the message has + * scrolled across once. + */ + set_msg(newmsg, WRAP_SCROLL); + have_scrolled = 0; + while (!have_scrolled); +} + void display_shift() { /* update the display for WRAP_SCROLL or WRAP_ALTERNATE modes */ switch (wrap_mode) { case WRAP_SCROLL: case WRAP_ALTERNATE: scroll_point++; - if (scroll_point >= msg_length) scroll_point = 0; + if (scroll_point >= msg_length) { + scroll_point = 0; + have_scrolled = 1; + } display_update(); break; } diff --git a/ROM2/display.h b/ROM2/display.h index 0f7c3b9..6121e7f 100644 --- a/ROM2/display.h +++ b/ROM2/display.h @@ -17,6 +17,7 @@ extern void display_init(); void append_msg(char* newmsg, u8 wrap); void set_msg(char* newmsg, u8 wrap); +void scroll_msg(char* newmsg); void set_char(char c, u8 pos); void set_wrap_mode(u8 new_wrap_mode); void display_refresh(); diff --git a/ROM2/helpers.c b/ROM2/helpers.c index c4e5970..74cb40b 100644 --- a/ROM2/helpers.c +++ b/ROM2/helpers.c @@ -1,3 +1,4 @@ +#include "display.h" #include "vend.h" #define DELAY_MAGIC 20 /* FIXME: number of loops for ~ 1 millisecond (< 256) */ diff --git a/ROM2/main.c b/ROM2/main.c index 2960c52..0026edc 100644 --- a/ROM2/main.c +++ b/ROM2/main.c @@ -30,10 +30,9 @@ bool uid_enter() { uid = (uid*10) + (last_key%10); set_char((last_key%10)+'0', 4+uidpos); } - return 1; + return (uid!=0); } - bool pin_enter() { u8 pinpos; /* We ask for a pin, display a PIN: prompt. PINs must be a 4 digit number. @@ -57,6 +56,7 @@ bool pin_enter() { } void make_request(u8 selection) { + set_msg("REQUESTING", WRAP_NONE); /* XXX: maybe this isn't needed? */ switch(server_request(uid, pin, selection)) { case REQUEST_OK: set_msg("THANK YOU!", WRAP_NONE); @@ -84,7 +84,7 @@ void selection_menu() { set_msg("ENTER SELECTION OR INSERT COINS ", WRAP_SCROLL); selection = 0; while(1) { - if (coin_value) { + if (coin_value) { /* we have coins inserted */ int prev_coin = 0; /* alternate between the price and a confirm message */ while (coin_value) { @@ -97,7 +97,7 @@ void selection_menu() { if (keypad_pressed()) { switch (last_key) { case KEY_RESET: - coin_refund(); + scroll_msg("PRESS COIN REFUND"); goto reset; case KEY_0: switch (server_credit_account(uid, pin, coin_value)) { diff --git a/ROM2/types.h b/ROM2/types.h index 8746dcc..360ad58 100644 --- a/ROM2/types.h +++ b/ROM2/types.h @@ -2,6 +2,7 @@ #define _TYPES_H_ /* FIXME: are these typedefs right for m68hc11-gcc? */ +/* XXX: see gcc manual for types */ typedef unsigned char u8; typedef signed char s8; typedef unsigned short u16;