]> git.defcon.no Git - avrfbosd/commitdiff
Added clear_screen() using memset from string.h. Faster clearing YEAH!
authorJon Langseth <jon.langseth@lilug.no>
Fri, 5 Jul 2013 10:11:04 +0000 (12:11 +0200)
committerJon Langseth <jon.langseth@lilug.no>
Fri, 5 Jul 2013 10:11:04 +0000 (12:11 +0200)
draw.c
draw.h

diff --git a/draw.c b/draw.c
index 2fd89b412406574e36fe12e5301453338b3816e1..b40c033d845521a1c4f23d951d491a34f6b7c714 100644 (file)
--- a/draw.c
+++ b/draw.c
@@ -1,5 +1,6 @@
 #include "draw.h"
 #include <stdlib.h>
+#include <string.h>
 #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 1fbc3e87015d9aa635d27f0197c8edd72d4a8a72..a20cdb9014b21648d1a7de3977b3b02bd5330f1c 100644 (file)
--- 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