From: Jon Langseth Date: Fri, 5 Jul 2013 10:11:04 +0000 (+0200) Subject: Added clear_screen() using memset from string.h. Faster clearing YEAH! X-Git-Url: https://git.defcon.no/?a=commitdiff_plain;h=016f1a247af065df5c656620d41736705a64cf3a;p=avrfbosd Added clear_screen() using memset from string.h. Faster clearing YEAH! --- diff --git a/draw.c b/draw.c index 2fd89b4..b40c033 100644 --- a/draw.c +++ b/draw.c @@ -1,5 +1,6 @@ #include "draw.h" #include +#include #include "font.h" extern uint8_t* screen_buffer; @@ -23,17 +24,18 @@ void fill(uint8_t color) { switch(color) { case c_BLACK: - for (int i = 0; i < (hres_bytes*VRES); i++) - screen_buffer[i] = 0; + clear_screen(); break; case c_WHITE: - for (int i = 0; i < (hres_bytes*VRES); i++) - screen_buffer[i] = 0xFF; + memset( (void*)screen_buffer, 0xFF, hres_bytes*VRES ); break; case c_INVERT: for (int i = 0; i < (hres_bytes*VRES); i++) screen_buffer[i] = ~screen_buffer[i]; break; + default: + memset( (void*)screen_buffer, color, hres_bytes*VRES ); + } } @@ -242,3 +244,7 @@ void draw_string ( uint8_t pos_x, uint8_t pos_y, const char *text) } } +void clear_screen( void ) +{ + memset( (void*)screen_buffer, 0, hres_bytes*VRES ); +} diff --git a/draw.h b/draw.h index 1fbc3e8..a20cdb9 100644 --- a/draw.h +++ b/draw.h @@ -40,4 +40,6 @@ void pgm_draw_8bpp_bitmap( uint8_t pos_x, uint8_t pos_y, uint8_t width, uint8_t void draw_char ( uint8_t pos_x, uint8_t pos_y, uint8_t ch); void draw_string ( uint8_t pos_x, uint8_t pos_y, const char *text); +void clear_screen( void ); + #endif