Compare commits

..

No commits in common. '015769cbdc0912cba1060f9bfd96b75bbb808fa5' and 'a951102ab8c629c4ec0cabd33a5bbfaa21562cfe' have entirely different histories.

@ -30,8 +30,8 @@ pub enum ScreenMode {
pub struct Screen {}
impl Screen {
const SCREEN_CLEAR : u32 = 0x0000_0001;
const SCREEN_DISPLAY : u32 = 0x0000_0100;
const SCREEN_CLEAR: u32 = 0x0000_0001;
const SCREEN_DISPLAY: u32 = 0x0000_0100;
#[inline]
pub fn init(mode: ScreenMode) {
@ -48,33 +48,6 @@ impl Screen {
}
}
#[inline]
pub fn clear() {
unsafe {
// Write a 1 to the screen clear byte
write_volatile(SCREEN_CONTROL_POINTER as *mut u8, 1);
write_volatile(SCREEN_CONTROL_POINTER as *mut u8, 0);
}
}
#[inline]
pub fn display() {
unsafe {
// Write a 1 to the screen display byte
write_volatile((SCREEN_CONTROL_POINTER as *mut u8).byte_offset(1), 1);
write_volatile((SCREEN_CONTROL_POINTER as *mut u8).byte_offset(1), 0);
}
}
#[inline]
pub fn change_mode(mode: ScreenMode) {
match mode {
ScreenMode::AlwaysDisplay => unsafe {
write_volatile((SCREEN_CONTROL_POINTER as *mut u8).byte_offset(1), 1);
},
ScreenMode::Buffered => unsafe {
write_volatile((SCREEN_CONTROL_POINTER as *mut u8).byte_offset(1), 0);
},
}
}
#[inline]
pub fn turn_pixel_on(x: u8, y: u8) {
unsafe {
let mut row = read_volatile(SCREEN_POINTER.offset(y as isize));
@ -100,8 +73,8 @@ impl Screen {
pub struct TextDisplay {}
impl TextDisplay {
const TEXT_CLEAR : u32 = 0x0000_0001;
const TEXT_DISPLAY : u32 = 0x0000_0100;
const TEXT_CLEAR: u32 = 0x0000_0001;
const TEXT_DISPLAY: u32 = 0x0000_0100;
#[inline]
pub fn init(&self) {
@ -153,14 +126,14 @@ impl RNG {
pub struct Buttons {}
impl Buttons {
pub const A : u8 = 0b00000001;
pub const B : u8 = 0b00000010;
pub const X : u8 = 0b00000100;
pub const Y : u8 = 0b00001000;
pub const RIGHT : u8 = 0b00010000;
pub const DOWN : u8 = 0b00100000;
pub const LEFT : u8 = 0b01000000;
pub const UP : u8 = 0b10000000;
pub const RIGHT_RIGHT : u8 = 0b00000001;
pub const RIGHT_DOWN : u8 = 0b00000010;
pub const RIGHT_LEFT : u8 = 0b00000100;
pub const RIGHT_UP : u8 = 0b00001000;
pub const LEFT_RIGHT : u8 = 0b00010000;
pub const LEFT_DOWN : u8 = 0b00100000;
pub const LEFT_LEFT : u8 = 0b01000000;
pub const LEFT_UP : u8 = 0b10000000;
#[inline]
pub fn read() -> u8 {

@ -18,16 +18,12 @@ const HELLO_WORLD: &str = " Hello world!";
#[entry]
fn main() -> ! {
NumberDisplay::display_number(0);
Screen::init(ScreenMode::Buffered);
Screen::init(ScreenMode::AlwaysDisplay);
let mut text = TextDisplay{};
text.init();
for i in 0..32 {
Screen::set_line(i, 1 << i);
}
Screen::display();
Screen::clear();
Screen::display();
Screen::change_mode(ScreenMode::AlwaysDisplay);
unsafe {
write_volatile(SCREEN_POINTER, 0x001166ff);
write_volatile(SCREEN_POINTER.offset(1), 0xAAAAAAAA);

Loading…
Cancel
Save