diff --git a/src/graphics.rs b/src/graphics.rs index 489bfce..6504144 100644 --- a/src/graphics.rs +++ b/src/graphics.rs @@ -45,24 +45,22 @@ impl GraphicsBuf { } }); - self.sprite_atlas - .draw_string(10, 10, "Hello World!", &mut gfx_buf); - - self.sprite_atlas.draw_textfield( - 10, - 20, - 110, - 10, - "I think this font has a *lot* of 'character'! ;)", - &mut gfx_buf, - ); - draw_bresenham_line(0, 0, 127, 0, &mut gfx_buf); draw_bresenham_line(0, 63, 128, 63, &mut gfx_buf); draw_bresenham_line(0, 0, 0, 63, &mut gfx_buf); draw_bresenham_line(127, 0, 127, 63, &mut gfx_buf); } + pub fn draw_string(&mut self, x: u8, y: u8, string: &str) { + self.sprite_atlas + .draw_string(x, y, string, &mut self.buffer); + } + + pub fn draw_textfield(&mut self, x: u8, y: u8, width: u8, height: u8, string: &str) { + self.sprite_atlas + .draw_textfield(x, y, width, height, string, &mut self.buffer); + } + pub fn get_px_buffer(&self) -> &[u8; 8192] { &self.buffer } diff --git a/src/main.rs b/src/main.rs index 25bcea5..323ae0d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,6 +72,9 @@ fn main() -> ! { loop { gfx_buf.clear(); + + gfx_buf.draw_textfield(10, 10, 100, 60, "Hello! This is a test. :)"); + gfx_buf.redraw(); sh1106_dev.blit_framebuffer(&mut i2c, &gfx_buf);