Deprecating main.c & other functions in order to be a dumb terminal.
[uccvend-snackrom.git] / ROM2 / display_basic.c
diff --git a/ROM2/display_basic.c b/ROM2/display_basic.c
new file mode 100644 (file)
index 0000000..0526d2f
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * display_basic.c - simple functions for writing to the screen of the vendie.
+ *
+ * Use set_msg(char[10]) to write a new message to the screen, replacing the
+ * previous one.
+ *
+ */
+
+#include "display_basic.h"
+#include "vend.h"
+
+/* private prototypes */
+void display_send_byte(char c);
+void display_reset();
+
+void set_msg(char newmsg[10]) {
+       int i;
+       display_reset();
+       for (i=0; i < 10; i++) {
+               display_send_byte(newmsg[i]&0x7f);
+       }
+}
+
+void display_send_byte(char c) {
+       bset_misc_output(A3800_DISPLAY_WRITE);  /* enable the display clock */
+
+       _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 */
+       bclr((void*)&_io_ports[M6811_PORTA], PORTA_DISP_RESET);
+       delay(DISPLAY_DELAY);
+       bset((void*)&_io_ports[M6811_PORTA], PORTA_DISP_RESET);
+
+       spi_enable();
+       delay(DISPLAY_DELAY);
+
+       display_send_byte(0xC0 | 10);    /* tell the controller there are 10 digits */
+       display_send_byte(0xE0);    /* set duty cycle to 100%                  */
+
+       spi_disable();
+}
+
+void display_init() {
+       display_reset();
+}
+

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