From d76509a30e7b0ff2440538e2a06210dc64da9214 Mon Sep 17 00:00:00 2001 From: arighi Date: Thu, 22 Apr 2010 21:57:27 +0000 Subject: [PATCH] rit128x96: introduce rit128x96_blitRaw() to draw a raw image on screen. 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 | 46 +++++++++++++++++++++-------- bertos/drv/lcd_rit128x96.h | 9 +++--- examples/lm3s1968/hw/hw_rit128x96.h | 2 +- examples/lm3s1968/lm3s1968.c | 20 ++++++------- 4 files changed, 50 insertions(+), 27 deletions(-) diff --git a/bertos/drv/lcd_rit128x96.c b/bertos/drv/lcd_rit128x96.c index 9922b6af..fd2f3595 100644 --- a/bertos/drv/lcd_rit128x96.c +++ b/bertos/drv/lcd_rit128x96.c @@ -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(); } diff --git a/bertos/drv/lcd_rit128x96.h b/bertos/drv/lcd_rit128x96.h index 6a9c7f92..fedbe296 100644 --- a/bertos/drv/lcd_rit128x96.h +++ b/bertos/drv/lcd_rit128x96.h @@ -45,9 +45,10 @@ #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 */ diff --git a/examples/lm3s1968/hw/hw_rit128x96.h b/examples/lm3s1968/hw/hw_rit128x96.h index 32edf8ee..7ccdeb1d 100644 --- a/examples/lm3s1968/hw/hw_rit128x96.h +++ b/examples/lm3s1968/hw/hw_rit128x96.h @@ -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 */ diff --git a/examples/lm3s1968/lm3s1968.c b/examples/lm3s1968/lm3s1968.c index 263712be..f77f43e4 100644 --- a/examples/lm3s1968/lm3s1968.c +++ b/examples/lm3s1968/lm3s1968.c @@ -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(); -- 2.25.1