rit128x96: introduce rit128x96_blitRaw() to draw a raw image on screen.
authorarighi <arighi@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 22 Apr 2010 21:57:27 +0000 (21:57 +0000)
committerarighi <arighi@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 22 Apr 2010 21:57:27 +0000 (21:57 +0000)
Moreover, fix the function naming according to the coding style.

git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3495 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/drv/lcd_rit128x96.c
bertos/drv/lcd_rit128x96.h
examples/lm3s1968/hw/hw_rit128x96.h
examples/lm3s1968/lm3s1968.c

index 9922b6af77dc994cbfd1399235d20d01562d091c..fd2f359579bdea84b40e566906cbe867a1e08689 100644 (file)
@@ -110,7 +110,7 @@ static void lcd_dataWrite(const uint8_t *buf, size_t count)
 }
 
 /* Turn on the OLED display */
-void rit128x96_lcd_on(void)
+void rit128x96_on(void)
 {
        unsigned int i;
 
@@ -121,36 +121,58 @@ void rit128x96_lcd_on(void)
 }
 
 /* Turn off the OLED display */
-void rit128x96_lcd_off(void)
+void rit128x96_off(void)
 {
        LCD_SET_COMMAND();
        lcd_dataWrite(exit_cmd, sizeof(exit_cmd));
 }
 
-/* Refresh a bitmap on screen */
-void rit128x96_lcd_blitBitmap(const Bitmap *bm)
+static void lcd_start_blit(uint8_t width, uint8_t height)
 {
-       uint8_t lcd_row[bm->width / 2];
        uint8_t buffer[3];
-       uint8_t mask;
-       int i, l;
 
-       ASSERT(bm->width == LCD_WIDTH && bm->height == LCD_HEIGHT);
+       ASSERT(width == LCD_WIDTH && height == LCD_HEIGHT);
 
        /* Enter command mode */
        LCD_SET_COMMAND();
 
        buffer[0] = 0x15;
        buffer[1] = 0;
-       buffer[2] = (bm->width - 2) / 2;
+       buffer[2] = (width - 2) / 2;
        lcd_dataWrite(buffer, 3);
 
        buffer[0] = 0x75;
        buffer[1] = 0;
-       buffer[2] = bm->height - 1;
+       buffer[2] = height - 1;
        lcd_dataWrite(buffer, 3);
        lcd_dataWrite((const uint8_t *)&horizontal_inc, sizeof(horizontal_inc));
+}
+
+/* Refresh a raw image on screen */
+void rit128x96_blitRaw(const uint8_t *data, uint8_t width, uint8_t height)
+{
+       lcd_start_blit(width, height);
+       /*
+        * Enter data mode and send the encoded image data to the OLED display,
+        * over the SSI bus.
+        */
+       LCD_SET_DATA();
+       while (height--)
+       {
+               /* Write an entire row at once */
+               lcd_dataWrite(data, width / 2);
+               data += width / 2;
+       }
+}
+
+/* Refresh a bitmap on screen */
+void rit128x96_blitBitmap(const Bitmap *bm)
+{
+       uint8_t lcd_row[bm->width / 2];
+       uint8_t mask;
+       int i, l;
 
+       lcd_start_blit(bm->width, bm->height);
        /*
         * Enter data mode and send the encoded image data to the OLED display,
         * over the SSI bus.
@@ -174,11 +196,11 @@ void rit128x96_lcd_blitBitmap(const Bitmap *bm)
 }
 
 /* Initialize the OLED display */
-void rit128x96_lcd_init(void)
+void rit128x96_init(void)
 {
        /* Initialize the communication bus */
        lcd_bus_init();
 
        /* Turn on the OLED display */
-       rit128x96_lcd_on();
+       rit128x96_on();
 }
index 6a9c7f9280b6467d397121ea87dd69d4ed066ce2..fedbe29678b9638b5e621c863836ea3e6e1a0846 100644 (file)
 #define LCD_WIDTH      128
 #define LCD_HEIGHT     96
 
-void rit128x96_lcd_blitBitmap(const Bitmap *bm);
-void rit128x96_lcd_on(void);
-void rit128x96_lcd_off(void);
-void rit128x96_lcd_init(void);
+void rit128x96_blitRaw(const uint8_t *data, uint8_t width, uint8_t height);
+void rit128x96_blitBitmap(const Bitmap *bm);
+void rit128x96_on(void);
+void rit128x96_off(void);
+void rit128x96_init(void);
 
 #endif /* LCD_LM3S_H */
index 32edf8ee0af8b64db9e341b7cca4fa1b5498c23e..7ccdeb1d4b59565687c3c2a87364dc28e012203d 100644 (file)
@@ -123,6 +123,6 @@ INLINE void lcd_bus_init(void)
  * XXX: menu stuff requires lcd_blitBimap() function to be defined.
  * Find a better way to do this.
  */
-#define rit128x96_lcd_blitBitmap lcd_blitBitmap
+#define rit128x96_blitBitmap lcd_blitBitmap
 
 #endif /* HW_RIT128x96_H */
index 263712be161306d517e72073bf51f4be89eb1b30..f77f43e41a6da2e5983436c6de7f25d1a8d87b8d 100644 (file)
@@ -157,7 +157,7 @@ static void bouncing_logo(Bitmap *bm)
                        (LCD_HEIGHT - bertos_logo.height) / 2 + h / SPEED_SCALE,
                        &bertos_logo);
                text_xprintf(bm, 7, 0, TEXT_FILL | TEXT_CENTER, "Press SELECT to quit");
-               rit128x96_lcd_blitBitmap(bm);
+               rit128x96_blitBitmap(bm);
                timer_delay(5);
                if (kbd_peek() & KEY_MASK)
                        break;
@@ -179,7 +179,7 @@ static void screen_saver(Bitmap *bm)
 
                gfx_bitmapClear(bm);
                gfx_rectDraw(bm, x1, y1, x2, y2);
-               rit128x96_lcd_blitBitmap(bm);
+               rit128x96_blitBitmap(bm);
                if (kbd_peek() & KEY_MASK)
                        break;
        }
@@ -229,7 +229,7 @@ static void res_process(void)
                        " %lu.%lu usec",
                                ((end - start) * 1000000) / CPU_FREQ,
                                ((end - start) * (100000000 / CPU_FREQ)) % 100);
-               rit128x96_lcd_blitBitmap(&lcd_bitmap);
+               rit128x96_blitBitmap(&lcd_bitmap);
                timer_delay(5);
                if (kbd_peek() & KEY_MASK)
                        break;
@@ -241,9 +241,9 @@ static void context_switch_test(Bitmap *bm)
        gfx_bitmapClear(bm);
        text_xprintf(bm, 0, 0, TEXT_FILL,
                        "CPU: Cortex-M3 %luMHz", CPU_FREQ / 1000000);
-       rit128x96_lcd_blitBitmap(bm);
+       rit128x96_blitBitmap(bm);
        text_xprintf(bm, 1, 0, TEXT_FILL, "Board: LM3S1968 EVB");
-       rit128x96_lcd_blitBitmap(bm);
+       rit128x96_blitBitmap(bm);
 
        res_process();
 }
@@ -266,7 +266,7 @@ static void uptime(Bitmap *bm)
                /* Display uptime (in ticks) */
                text_xprintf(&lcd_bitmap, 2, 0, TEXT_FILL | TEXT_CENTER,
                                "%lu", clock / 1000);
-               rit128x96_lcd_blitBitmap(bm);
+               rit128x96_blitBitmap(bm);
                timer_delay(5);
                if (kbd_peek() & KEY_MASK)
                        break;
@@ -285,11 +285,11 @@ static void NORETURN soft_reset(Bitmap * bm)
        for (i = 5; i; --i)
        {
                text_xprintf(bm, 2, 0, TEXT_FILL | TEXT_CENTER, "%d", i);
-               rit128x96_lcd_blitBitmap(bm);
+               rit128x96_blitBitmap(bm);
                timer_delay(1000);
        }
        text_xprintf(bm, 2, 0, TEXT_FILL | TEXT_CENTER, "REBOOT");
-       rit128x96_lcd_blitBitmap(bm);
+       rit128x96_blitBitmap(bm);
        timer_delay(1000);
 
        /* Perform a software reset request */
@@ -341,10 +341,10 @@ int main(void)
        proc_init();
        kputs("Done.\n");
        kputs("Init OLED display..");
-       rit128x96_lcd_init();
+       rit128x96_init();
        gfx_bitmapInit(&lcd_bitmap, raster, LCD_WIDTH, LCD_HEIGHT);
        gfx_setFont(&lcd_bitmap, &font_helvB10);
-       rit128x96_lcd_blitBitmap(&lcd_bitmap);
+       rit128x96_blitBitmap(&lcd_bitmap);
        kputs("Done.\n");
        kputs("Init Keypad..");
        kbd_init();