Merge branch 'master' of gitlab:wintermute/hackover2013-badge-firmware
[hackover2013-badge-firmware.git] / badge / ui / display.c
index cb91904..db04007 100644 (file)
@@ -6,8 +6,26 @@
 #include <sysdefs.h>
 #include <lpc134x.h>
 
 #include <sysdefs.h>
 #include <lpc134x.h>
 
+#ifdef R0KET
+
 #include <r0ketports.h>
 
 #include <r0ketports.h>
 
+#define CS_LOW()   gpioSetValue(RB_LCD_CS , 0)
+#define CS_HIGH()  gpioSetValue(RB_LCD_CS , 1)
+#define RST_LOW()  gpioSetValue(RB_LCD_RST, 0)
+#define RST_HIGH() gpioSetValue(RB_LCD_RST, 1)
+
+#else
+
+#include <badge/pinconfig.h>
+
+#define CS_LOW()   gpioSetValue(HOB_PORT(HOB_LCD_CS ), HOB_PIN(HOB_LCD_CS ), 0)
+#define CS_HIGH()  gpioSetValue(HOB_PORT(HOB_LCD_CS ), HOB_PIN(HOB_LCD_CS ), 1)
+#define RST_LOW()  gpioSetValue(HOB_PORT(HOB_LCD_RST), HOB_PIN(HOB_LCD_RST), 0)
+#define RST_HIGH() gpioSetValue(HOB_PORT(HOB_LCD_RST), HOB_PIN(HOB_LCD_RST), 1)
+
+#endif
+
 #ifdef CFG_USBMSC
 #include <core/usbhid-rom/usbmsc.h>
 
 #ifdef CFG_USBMSC
 #include <core/usbhid-rom/usbmsc.h>
 
@@ -27,11 +45,12 @@ static void lcd_select() {
                          | SSP_SSP0CR0_FRF_SPI    // Frame format = SPI
                          | SSP_SSP0CR0_SCR_8);    // Serial clock rate = 8
   SSP_SSP0CR0 = configReg;
                          | SSP_SSP0CR0_FRF_SPI    // Frame format = SPI
                          | SSP_SSP0CR0_SCR_8);    // Serial clock rate = 8
   SSP_SSP0CR0 = configReg;
-  gpioSetValue(RB_LCD_CS, 0);
+
+  CS_LOW();
 }
 
 static void lcd_deselect() {
 }
 
 static void lcd_deselect() {
-  gpioSetValue(RB_LCD_CS, 1);
+  CS_HIGH();
   /* reset the bus to 8-Bit frames that everyone else uses */
   uint32_t configReg = ( SSP_SSP0CR0_DSS_8BIT     // Data size = 8-bit
                          | SSP_SSP0CR0_FRF_SPI    // Frame format = SPI
   /* reset the bus to 8-Bit frames that everyone else uses */
   uint32_t configReg = ( SSP_SSP0CR0_DSS_8BIT     // Data size = 8-bit
                          | SSP_SSP0CR0_FRF_SPI    // Frame format = SPI
@@ -59,16 +78,13 @@ static void lcd_write_data   (uint8_t data) { lcd_write(0x0100 | data); }
 void badge_display_init(void) {
   sspInit(0, sspClockPolarity_Low, sspClockPhase_RisingEdge);
 
 void badge_display_init(void) {
   sspInit(0, sspClockPolarity_Low, sspClockPhase_RisingEdge);
 
-  gpioSetValue(RB_LCD_CS , 1);
-  gpioSetValue(RB_LCD_RST, 1);
-
-  gpioSetDir  (RB_LCD_CS , gpioDirection_Output);
-  gpioSetDir  (RB_LCD_RST, gpioDirection_Output);
+  CS_HIGH();
+  RST_HIGH();
 
   systickDelay(100);
 
   systickDelay(100);
-  gpioSetValue(RB_LCD_RST, 0);
+  RST_LOW();
   systickDelay(100);
   systickDelay(100);
-  gpioSetValue(RB_LCD_RST, 1);
+  RST_HIGH();
   systickDelay(100);
   /*
   int id = lcdRead(220);
   systickDelay(100);
   /*
   int id = lcdRead(220);
@@ -104,12 +120,13 @@ void badge_display_init(void) {
    * 10: set x address (upper bits): X[6-4] = 0
    */
   static uint8_t const initseq[]= { 0xE2, 0xAF, // Display ON
    * 10: set x address (upper bits): X[6-4] = 0
    */
   static uint8_t const initseq[]= { 0xE2, 0xAF, // Display ON
-                                    //      0xA1,       // Mirror-X
-                                    0xc8, // mirror-y
+                                   0xA1,       // Mirror-X
+                                    //0xc8, // mirror-y
                                     0xa7, // invert (1 = black)
                                     0xA4, 0x2F,
                                     0xa7, // invert (1 = black)
                                     0xA4, 0x2F,
+                                   // 0x9f, 0x24
                                     0xB0, 0x10,
                                     0xB0, 0x10,
-                                    0x9f, 0x24 };
+  };
   for(uint8_t i = 0; i < sizeof(initseq); ++i){
     lcd_write_command(initseq[i]);
     systickDelay(5);
   for(uint8_t i = 0; i < sizeof(initseq); ++i){
     lcd_write_command(initseq[i]);
     systickDelay(5);
@@ -126,7 +143,7 @@ void badge_framebuffer_flush(badge_framebuffer const *fb) {
   lcd_write_command(0x00);
 
 
   lcd_write_command(0x00);
 
 
-  for(int i = 0; i < 9 * 96; ++i) {
+  for(int i = 0; i < BADGE_DISPLAY_STRIPE_COUNT * BADGE_DISPLAY_WIDTH; ++i) {
     lcd_write_data(fb->data[0][i]);
   }
 
     lcd_write_data(fb->data[0][i]);
   }
 
This page took 0.025765 seconds and 4 git commands to generate.