#![no_std]
#![no_main]
#[allow(unused_imports)]
use panic_halt;
use pygamer as hal;
use embedded_graphics::pixelcolor::{Rgb565, RgbColor};
use embedded_graphics::prelude::*;
use embedded_graphics::{egrectangle, primitive_style};
use embedded_graphics::{image::Image, image::ImageRaw, image::ImageRawLE};
use hal::clock::GenericClockController;
use hal::entry;
use hal::pac::{CorePeripherals, Peripherals};
#[entry]
fn main() -> ! {
let mut peripherals = Peripherals::take().unwrap();
let core = CorePeripherals::take().unwrap();
let mut clocks = GenericClockController::with_internal_32kosc(
peripherals.GCLK,
&mut peripherals.MCLK,
&mut peripherals.OSC32KCTRL,
&mut peripherals.OSCCTRL,
&mut peripherals.NVMCTRL,
);
let mut pins = hal::Pins::new(peripherals.PORT).split();
let mut delay = hal::delay::Delay::new(core.SYST, &mut clocks);
let (mut display, _backlight) = pins
.display
.init(
&mut clocks,
peripherals.SERCOM4,
&mut peripherals.MCLK,
peripherals.TC2,
&mut delay,
&mut pins.port,
)
.unwrap();
egrectangle!(
top_left = (0, 0),
bottom_right = (160, 128),
style = primitive_style!(stroke_width = 0, fill_color = RgbColor::BLACK)
)
.draw(&mut display)
.unwrap();
let raw_image: ImageRawLE<Rgb565> = ImageRaw::new(include_bytes!("./ferris.raw"), 86, 64);
let ferris: Image<_, Rgb565> = Image::new(&raw_image, Point::new(32, 32));
ferris.draw(&mut display).unwrap();
loop {}
}