Skip to content

Instantly share code, notes, and snippets.

@agrif
Created July 8, 2020 23:36
Show Gist options
  • Save agrif/2c5d6afc1fd27ecdcf4708d51fd4cbca to your computer and use it in GitHub Desktop.
Save agrif/2c5d6afc1fd27ecdcf4708d51fd4cbca to your computer and use it in GitHub Desktop.
#![no_std]
#![no_main]
#![feature(never_type)]
#![feature(unwrap_infallible)]
mod framebuffer;
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}
fn draw_demo<T>(fb: &mut T) -> Result<(), T::Error>
where
T: embedded_graphics::DrawTarget<embedded_graphics::pixelcolor::Rgb888>,
{
use embedded_graphics::prelude::*;
use embedded_graphics::pixelcolor::Rgb888;
use embedded_graphics::primitives::Circle;
use embedded_graphics::fonts::{Font24x32, Text};
use embedded_graphics::style::{PrimitiveStyle, TextStyle};
fb.clear(Rgb888::BLACK)?;
Circle::new(Point::new(20, 20), 8)
.into_styled(PrimitiveStyle::with_fill(Rgb888::RED))
.draw(fb)?;
Text::new("Hello framebuffer!", Point::new(20, 16))
.into_styled(TextStyle::new(Font24x32, Rgb888::BLUE))
.draw(fb)?;
Ok(())
}
blueloader_info::entry_point!(kmain);
fn kmain(info: blueloader_info::BootInfo) -> ! {
let mut fb = framebuffer::Framebuffer::new(&info.framebuffer);
draw_demo(&mut fb).into_ok();
loop {
x86_64::instructions::hlt();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment