Initial go at pulling things together.
[uccvend-snackrom.git] / ROM2 / display.c
1 /*
2  * display.c - functions for controlling the display on the vending machine.
3  *
4  * Use set_msg(char*) to write a new message to the screen, replacing the previous
5  * one. The message can be at most 1023 characters long. Use set_wrap_mode with
6  * one of the WRAP_* options in vend.h to set the scrolling behaviour. If the
7  * message is less than 10 characters, it is centered and is not scrolled.
8  * Otherwise, the message will scroll.
9  *
10  */
11
12
13 #include "vend.h"
14
15 char display_buffer[10];    /* what each byte on the display reads          */
16 char current_message[1024]; /* message that is scrolled or switched between */
17 u8   wrap_mode;             /* whether to scroll or alternate between msgs  */
18
19 void set_msg(char* newmsg) {
20         char* dest = current_message;
21         /* while (dest++ = newmsg++); */
22         while (newmsg) {
23                 dest = newmsg;
24                 dest++;
25                 newmsg++;
26         }
27 }
28
29 void __inline__ set_wrap_mode(u8 new_wrap_mode) {
30         /* in theory it should be inlined anyway? */
31         wrap_mode = new_wrap_mode;
32 }
33
34 void display_send_byte(u8 b) {
35         bset_3800(A3800_DISPLAY_WRITE);
36 }
37
38 #define DISPLAY_DELAY  100 /* ms to delay between ops - could be tweaked */
39 void display_reset() {
40         /* lower the reset line for 100ms */
41         bclr(PORTA, PORTA_DISP_RESET);
42         delay(DISPLAY_DELAY);
43         bset(PORTA, PORTA_DISP_RESET);
44
45         /* enable the SPI */
46         bset(SPCR, SPCR_SPE);
47         delay(DISPLAY_DELAY);
48
49         /* tell the controller there are 10 digits */
50         
51 }
52
53 void display_refresh() {
54         display_reset();
55 }

UCC git Repository :: git.ucc.asn.au