Skip to content

Commit 9d59a82

Browse files
committed
clean os/user codes for graph show
1 parent 7522d05 commit 9d59a82

File tree

6 files changed

+7
-224
lines changed

6 files changed

+7
-224
lines changed

os/src/drivers/input/mod.rs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use crate::drivers::bus::virtio::VirtioHal;
2-
use crate::{
3-
gui::{move_rect, reset},
4-
sync::UPIntrFreeCell,
5-
};
2+
use crate::sync::UPIntrFreeCell;
63
use alloc::sync::Arc;
74
use core::any::Any;
85
use virtio_drivers::{VirtIOHeader, VirtIOInput};
@@ -49,21 +46,6 @@ impl InputDevice for VirtIOInputWrapper {
4946
virtio_input_decoder::DecodeType::Key(key, r#type) => {
5047
if r#type == KeyType::Press {
5148
match key {
52-
Key::C | Key::MouseLeft => {
53-
reset();
54-
}
55-
Key::W => {
56-
move_rect(0, -10);
57-
}
58-
Key::S => {
59-
move_rect(0, 10);
60-
}
61-
Key::A => {
62-
move_rect(-10, 0);
63-
}
64-
Key::D => {
65-
move_rect(10, 0);
66-
}
6749
_ => {}
6850
}
6951
}

os/src/gui/graphic.rs

Lines changed: 0 additions & 67 deletions
This file was deleted.

os/src/gui/mod.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

os/src/gui/paint.rs

Lines changed: 0 additions & 69 deletions
This file was deleted.

os/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ mod console;
1818
mod config;
1919
mod drivers;
2020
mod fs;
21-
mod gui;
2221
mod lang_items;
2322
mod mm;
2423
mod sbi;
@@ -70,7 +69,7 @@ pub fn rust_main() -> ! {
7069
timer::set_next_trigger();
7170
board::device_init();
7271
fs::list_apps();
73-
gui::init_paint();
72+
//gui::init_paint();
7473
task::add_initproc();
7574
*DEV_NON_BLOCKING_ACCESS.exclusive_access() = true;
7675
task::run_tasks();

user/src/bin/embed_graph.rs

Lines changed: 5 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ extern crate user_lib;
88

99
extern crate alloc;
1010

11-
use alloc::sync::Arc;
1211
use embedded_graphics::pixelcolor::Rgb888;
1312
use embedded_graphics::prelude::{Drawable, Point, RgbColor, Size};
1413
use embedded_graphics::primitives::Primitive;
@@ -23,11 +22,6 @@ const INIT_X: i32 = 640;
2322
const INIT_Y: i32 = 400;
2423
const RECT_SIZE: u32 = 40;
2524

26-
// lazy_static::lazy_static! {
27-
// pub static ref FB: Arc<Display> = Arc::new(Display::new(Size::new(VIRTGPU_XRES as u32, VIRTGPU_YRES as u32), Point::new(INIT_X, INIT_Y)));
28-
// }
29-
30-
//#[derive(Clone)]
3125
pub struct Display {
3226
pub size: Size,
3327
pub point: Point,
@@ -42,15 +36,10 @@ impl Display {
4236
"Hello world from user mode program! 0x{:X} , len {}",
4337
fb_ptr as usize, VIRTGPU_LEN
4438
);
45-
// let fb =
46-
// unsafe { Arc::new(core::slice::from_raw_parts_mut(fb_ptr as *mut u8, VIRTGPU_LEN as usize)) };
47-
let fb= unsafe { core::slice::from_raw_parts_mut(fb_ptr as *mut u8, VIRTGPU_LEN as usize) };
39+
let fb =
40+
unsafe { core::slice::from_raw_parts_mut(fb_ptr as *mut u8, VIRTGPU_LEN as usize) };
4841
Self { size, point, fb }
4942
}
50-
// pub fn reset(&self) {
51-
// let fb = self.drv.get_framebuffer();
52-
// fb.fill(0u8);
53-
// }
5443
}
5544

5645
impl OriginDimensions for Display {
@@ -68,9 +57,6 @@ impl DrawTarget for Display {
6857
where
6958
I: IntoIterator<Item = embedded_graphics::Pixel<Self::Color>>,
7059
{
71-
//let fb = self.fb.clone();
72-
//let fb = self.fb;
73-
//let mut arc_data_mut = Arc::make_mut(fb);
7460
pixels.into_iter().for_each(|px| {
7561
let idx = ((self.point.y + px.0.y) * VIRTGPU_XRES as i32 + self.point.x + px.0.x)
7662
as usize
@@ -117,59 +103,16 @@ impl DrawingBoard {
117103
self.latest_pos.y += dy;
118104
self.paint();
119105
}
120-
121-
// pub fn reset(&mut self) {
122-
// self.latest_pos = Point::new(INIT_X, INIT_Y);
123-
// self.disp.reset();
124-
// }
125106
}
126107

127-
// lazy_static! {
128-
// pub static ref DRAWING_BOARD: UPIntrFreeCell<DrawingBoard> =
129-
// unsafe { UPIntrFreeCell::new(DrawingBoard::new()) };
130-
// }
131-
132-
// pub fn init_paint() {
133-
// DRAWING_BOARD.exclusive_session(|ripple| {
134-
// ripple.paint();
135-
// });
136-
// }
137-
138-
// pub fn move_rect(dx: i32, dy: i32) {
139-
// DRAWING_BOARD.exclusive_session(|ripple| {
140-
// ripple.move_rect(dx, dy);
141-
// });
142-
// }
143-
144-
// pub fn reset() {
145-
// DRAWING_BOARD.exclusive_session(|ripple| {
146-
// ripple.reset();
147-
// });
148-
// }
149-
150108
#[no_mangle]
151109
pub fn main() -> i32 {
152110
// let fb_ptr = framebuffer() as *mut u8;
153-
let mut board=DrawingBoard::new();
154-
board.paint();
155-
for i in 0..100 {
111+
let mut board = DrawingBoard::new();
112+
for i in 0..20 {
156113
board.latest_pos.x += i;
157114
board.latest_pos.y += i;
158-
board.paint();
115+
board.paint();
159116
}
160-
// println!(
161-
// "Hello world from user mode program! 0x{:X} , len {}",
162-
// fb_ptr as usize, VIRTGPU_LEN
163-
// );
164-
// let fb = unsafe { core::slice::from_raw_parts_mut(fb_ptr as *mut u8, VIRTGPU_LEN as usize) };
165-
// for y in 0..800 {
166-
// for x in 0..1280 {
167-
// let idx = (y * 1280 + x) * 4;
168-
// fb[idx] = x as u8;
169-
// fb[idx + 1] = y as u8;
170-
// fb[idx + 2] = (x + y) as u8;
171-
// }
172-
// }
173-
// framebuffer_flush();
174117
0
175118
}

0 commit comments

Comments
 (0)