2 * display_basic.c - simple functions for writing to the screen of the vendie.
4 * Use set_msg(char[10]) to write a new message to the screen, replacing the
9 #include "display_basic.h"
12 /* private prototypes */
13 void display_send_byte(char c);
16 void set_msg(char newmsg[11]) {
20 for (i=0; i < 10; i++) {
21 if (newmsg[i] == 0) break;
23 display_send_byte(0xaf); // reset ptr to start
24 for (i--; i >= 0; i--) {
25 display_send_byte(newmsg[i]&0x7f);
30 void display_send_byte(char c) {
31 bset_misc_output(A3800_DISPLAY_WRITE); /* enable the display clock */
33 _io_ports[M6811_SPDR] = c; /* load SPI with byte */
34 while(!(_io_ports[M6811_SPSR]&M6811_SPIF)); /* wait for completion */
35 _io_ports[M6811_SPDR]; /* SPDR read to clear SPIF flag */
37 bclr_misc_output(A3800_DISPLAY_WRITE); /* disable the display clock */
40 #define DISPLAY_DELAY 20 /* ms to delay between ops - could be tweaked */
41 void display_reset() {
42 /* lower the reset line for a while */
43 bclr((void*)&_io_ports[M6811_PORTA], PORTA_DISP_RESET);
45 bset((void*)&_io_ports[M6811_PORTA], PORTA_DISP_RESET);
50 display_send_byte(0xC0 | 10); /* tell the controller there are 10 digits */
51 //display_send_byte(0xE0); /* set duty cycle to 0% */
52 display_send_byte(0xFF); /* set duty cycle to 100% */