X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=ROM2%2Fdisplay.c;h=da51973669f6d5c2516b726b62ceaabfcc3b4a20;hb=3781ef6863f304c8242fc1216cddbdbb0c74bebe;hp=af969218c349ad0603345891e8995de6165c03c8;hpb=1e7218d1311dafb5c1c81e4c4ad64847432be0b5;p=uccvend-snackrom.git diff --git a/ROM2/display.c b/ROM2/display.c index af96921..da51973 100644 --- a/ROM2/display.c +++ b/ROM2/display.c @@ -9,10 +9,12 @@ * */ +#include "display.h" #include "vend.h" char display_buffer[10]; /* what each byte on the display reads */ 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 */ @@ -25,16 +27,35 @@ void set_msg(char* newmsg, u8 wrap) { char* dest = current_message; /* equivalent of a string copy */ /* while (dest++ = newmsg++); */ + msg_length = 0; while (newmsg) { dest = newmsg; dest++; newmsg++; + msg_length++; } wrap_mode = wrap; scroll_point = 0; display_update(); } +void display_shift() { + /* update the display for WRAP_SCROLL or WRAP_ALTERNATE modes */ + switch (wrap_mode) { + case WRAP_SCROLL: + scroll_point++; + if (scroll_point >= msg_length) scroll_point = 0; + display_update(); + break; + case WRAP_ALTERNATE: + scroll_point += 10; + if (scroll_point >= msg_length) scroll_point = 0; + /* the above means that only sets of multiples of 10 characters + * are shown (excess ones are not) */ + display_update(); + } +} + void set_char(char c, u8 pos) { /* sets a single character */ display_buffer[pos] = c; @@ -67,15 +88,16 @@ void display_reset() { void display_update() { u8 i; + + for (i=0; i < 10; i++) { + display_buffer[i] = current_message[(i+scroll_point)%msg_length]; + } + + /* hmmm, will this cause some flickering of the display? */ display_reset(); for (i=0; i < 10; i++) { - /* FIXME: we may need to fiddle with the character codes sent to the - * controller. It doesn't seem like we have to, but datasheets for - * the "pin-for-pin" compatible MSC1937 from OKI suggest a different - * character set - */ - display_send_byte(i[display_buffer]&0x7f); + display_send_byte(display_buffer[i]&0x7f); } }