Skip to content

Commit

Permalink
lcd 0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
buhe committed Oct 28, 2021
1 parent 1a06642 commit 5b70788
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
5 changes: 3 additions & 2 deletions os/src/console.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::fmt::{self, Write};

use crate::scall_sbi::put_char;
use crate::{driver::print_with_lcd, scall_sbi::put_char};

struct STDOUT;

Expand All @@ -14,7 +14,8 @@ impl Write for STDOUT {
}

pub fn print(args: fmt::Arguments) {
STDOUT.write_fmt(args).unwrap();
// STDOUT.write_fmt(args).unwrap();
print_with_lcd(args);
}

#[macro_export]
Expand Down
16 changes: 10 additions & 6 deletions os/src/driver/lcd/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use core::fmt;

use k210_pac::SPI0;
use lazy_static::*;
use k210_hal::prelude::*;
Expand All @@ -21,12 +23,6 @@ mod console;
pub fn init() {

DRIVER.lock();
let mut image: ScreenImage = [0; DISP_PIXELS / 2];


CONSOLE.lock().render(&mut image);// render 会导致不执行 task
DRIVER.lock().flush(&image);
// lcd.draw_picture(0, 0, DISP_WIDTH, DISP_HEIGHT, &image);
}


Expand Down Expand Up @@ -92,4 +88,12 @@ lazy_static!{
lcd.clear(lcd_colors::BLUE);
Mutex::new(lcd)
};
}

pub fn print_with_lcd(args: fmt::Arguments){
let mut image: ScreenImage = [0; DISP_PIXELS / 2];
CONSOLE.lock().write_fmt(args).unwrap();

CONSOLE.lock().render(&mut image);// render 会导致不执行 task
DRIVER.lock().flush(&image);
}
1 change: 1 addition & 0 deletions os/src/driver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ pub fn init() {
gpio::init();
lcd::init();
}
pub use lcd::print_with_lcd;

0 comments on commit 5b70788

Please sign in to comment.