From 016f1a247af065df5c656620d41736705a64cf3a Mon Sep 17 00:00:00 2001
From: Jon Langseth <jon.langseth@lilug.no>
Date: Fri, 5 Jul 2013 12:11:04 +0200
Subject: [PATCH] Added clear_screen() using memset from string.h. Faster
 clearing YEAH!

---
 draw.c | 14 ++++++++++----
 draw.h |  2 ++
 2 files changed, 12 insertions(+), 4 deletions(-)

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 <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 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
-- 
2.39.2