X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=ROM2%2Fdisplay.c;h=45b39fc103aebb1381e1f09f0695964857d14d03;hb=c9763dcb182398266bae1c6a7a848beec1cba35d;hp=3ab045bde8cfda665b719c2440ce2284c54d2352;hpb=0f822a5a37e6e17e027b5a83b8d231a6c0de13eb;p=uccvend-snackrom.git diff --git a/ROM2/display.c b/ROM2/display.c index 3ab045b..45b39fc 100644 --- a/ROM2/display.c +++ b/ROM2/display.c @@ -1,26 +1,26 @@ /* * display.c - functions for controlling the display on the vending machine. * - * Use set_msg(char*) to write a new message to the screen, replacing the previous - * one. The message can be at most 1023 characters long. Use set_wrap_mode with - * one of the WRAP_* options in vend.h to set the scrolling behaviour. If the - * message is less than 10 characters, it is not scrolled. Otherwise, the - * message will scroll. + * Use set_msg(char*) to write a new message to the screen, replacing the + * previous one. The message can be at most 255 characters long. Use + * set_wrap_mode with one of the WRAP_* options in vend.h to set the scrolling + * behaviour. If the message is less than 10 characters, it is not scrolled. + * Otherwise, the message will scroll. * */ #include "vend.h" char display_buffer[10]; /* what each byte on the display reads */ -char current_message[1024]; /* message that is scrolled or switched between */ +char current_message[256]; /* message that is scrolled or switched between */ u8 wrap_mode; /* whether to scroll or alternate between msgs */ +u8 scroll_point; /* how far through the message we have scrolled */ /* private prototypes */ void display_send_byte(char c); void display_reset(); void display_update(); - void set_msg(char* newmsg) { char* dest = current_message; /* equivalent of a string copy */ @@ -30,35 +30,37 @@ void set_msg(char* newmsg) { dest++; newmsg++; } + scroll_point = 0; display_update(); } -inline void set_wrap_mode(u8 new_wrap_mode) { +extern inline void set_wrap_mode(u8 new_wrap_mode) { /* in theory it should be inlined anyway? */ wrap_mode = new_wrap_mode; } void display_send_byte(char c) { - *_misc_output |= A3800_DISPLAY_WRITE; /* enable the display clock */ + bset_misc_output(A3800_DISPLAY_WRITE); /* enable the display clock */ - _io_ports[M6811_SPDR] = c; /* load SPI with byte */ - while(!(_io_ports[M6811_SPDR]&0x80)); /* wait for completion */ + _io_ports[M6811_SPDR] = c; /* load SPI with byte */ + while(!(_io_ports[M6811_SPDR]&M6811_SPIE)); /* wait for completion */ + _io_ports[M6811_SPDR]; /* SPDR read to clear SPIE flag */ } #define DISPLAY_DELAY 100 /* ms to delay between ops - could be tweaked */ void display_reset() { /* lower the reset line for a while */ - _io_ports[M6811_PORTA] &= ~PORTA_DISP_RESET; + bclr(&_io_ports[M6811_PORTA], PORTA_DISP_RESET); delay(DISPLAY_DELAY); - _io_ports[M6811_PORTA] |= PORTA_DISP_RESET; + bset(&_io_ports[M6811_PORTA], PORTA_DISP_RESET); - _io_ports[M6811_SPCR] |= M6811_SPE; /* enable the SPI */ + spi_enable(); delay(DISPLAY_DELAY); - display_send_byte(0xCA); /* tell the controller there are 10 digits */ + display_send_byte(0xC0 | 10); /* tell the controller there are 10 digits */ display_send_byte(0xE0); /* set duty cycle to 100% */ - _io_ports[M6811_SPCR] &= ~M6811_SPE; /* disable the SPI again */ + spi_disable(); } void display_update() {