]> git.defcon.no Git - avrfbosd/blobdiff - draw.c
Added support for drawing characters and strings, updated font with "limited ascii...
[avrfbosd] / draw.c
diff --git a/draw.c b/draw.c
index 567b923aaeda8dcfec66f7f048e3487eaece0547..2fd89b412406574e36fe12e5301453338b3816e1 100644 (file)
--- a/draw.c
+++ b/draw.c
@@ -1,5 +1,6 @@
 #include "draw.h"
 #include <stdlib.h>
+#include "font.h"
 
 extern uint8_t* screen_buffer;
 extern uint8_t hres_bytes;
@@ -215,3 +216,29 @@ 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)
+{
+       for ( int h = 0; h < font_height; h++ )
+       {
+               uint8_t fl = pgm_read_byte(&( font[ch-32][h]));
+               fl = fl<<(8-font_width);
+               
+               for ( int p = 0; p < font_width; p++ )
+               {
+                       uint8_t ft = fl<<p;
+                       ft = ft & 0x80;
+                       ft = ft>>7;
+                       set_pixel( pos_x+p, pos_y+h, ft);
+               }
+       }
+       
+}
+
+void draw_string ( uint8_t pos_x, uint8_t pos_y, const char *text)
+{
+       for (int i = 0; text[i] != 0; i++)
+       {
+               draw_char( pos_x+(font_width*i)+1, pos_y, text[i]);
+       }
+}
+