No reset on display
[uccvend-snackrom.git] / ROM2 / display_basic.c
1 /*
2  * display_basic.c - simple functions for writing to the screen of the vendie.
3  *
4  * Use set_msg(char[10]) to write a new message to the screen, replacing the
5  * previous one.
6  *
7  */
8
9 #include "display_basic.h"
10 #include "vend.h"
11
12 /* private prototypes */
13 void display_send_byte(char c);
14 void display_reset();
15
16 void set_msg(char newmsg[11]) {
17         int i;
18         //display_reset();
19         spi_enable();
20         for (i=0; i < 10; i++) {
21                 if (newmsg[i] == 0) break;
22         }
23         for (i--; i >= 0; i--) {
24                 display_send_byte(newmsg[i]&0x7f);
25         }
26         spi_disable();
27 }
28
29 void display_send_byte(char c) {
30         bset_misc_output(A3800_DISPLAY_WRITE);  /* enable the display clock */
31
32         _io_ports[M6811_SPDR] = c;                  /* load SPI with byte */
33         while(!(_io_ports[M6811_SPSR]&M6811_SPIF)); /* wait for completion */
34         _io_ports[M6811_SPDR];                      /* SPDR read to clear SPIF flag */
35
36         bclr_misc_output(A3800_DISPLAY_WRITE);  /* disable the display clock */
37 }
38
39 #define DISPLAY_DELAY  50 /* ms to delay between ops - could be tweaked */
40 void display_reset() {
41         /* lower the reset line for a while */
42         bclr((void*)&_io_ports[M6811_PORTA], PORTA_DISP_RESET);
43         delay(DISPLAY_DELAY);
44         bset((void*)&_io_ports[M6811_PORTA], PORTA_DISP_RESET);
45         delay(DISPLAY_DELAY);
46
47         spi_enable();
48
49         display_send_byte(0xC0 | 10);    /* tell the controller there are 10 digits */
50         //display_send_byte(0xE0);    /* set duty cycle to 0%                  */
51         display_send_byte(0xFF);    /* set duty cycle to 100%                */
52
53         spi_disable();
54 }
55
56 void display_init() {
57         display_reset();
58 }
59

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