Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
rcore-os
RCore Tutorial V3
提交
af05b65e
R
RCore Tutorial V3
项目概览
rcore-os
/
RCore Tutorial V3
上一次同步 1 年多
通知
15
Star
793
Fork
260
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
RCore Tutorial V3
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
af05b65e
编写于
1月 07, 2023
作者:
chyyuu1972
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
udpate gui apps, uart and gpu can work together
上级
c3ce3724
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
128 addition
and
13 deletion
+128
-13
user/src/bin/embed_graph.rs
user/src/bin/embed_graph.rs
+2
-3
user/src/bin/embed_graph_uart.rs
user/src/bin/embed_graph_uart.rs
+124
-0
user/src/bin/gui_simple.rs
user/src/bin/gui_simple.rs
+2
-10
未找到文件。
user/src/bin/embed_graph.rs
浏览文件 @
af05b65e
#![no_std]
#![no_main]
use
user_lib
::{
framebuffer
,
framebuffer_flush
};
#[macro_use]
extern
crate
user_lib
;
extern
crate
alloc
;
use
user_lib
::{
framebuffer
,
framebuffer_flush
};
use
embedded_graphics
::
pixelcolor
::
Rgb888
;
use
embedded_graphics
::
prelude
::{
Drawable
,
Point
,
RgbColor
,
Size
};
use
embedded_graphics
::
primitives
::
Primitive
;
...
...
user/src/bin/embed_graph_uart.rs
0 → 100644
浏览文件 @
af05b65e
#![no_std]
#![no_main]
#[macro_use]
extern
crate
user_lib
;
extern
crate
alloc
;
use
user_lib
::
console
::
getchar
;
use
user_lib
::{
framebuffer
,
framebuffer_flush
};
use
embedded_graphics
::
pixelcolor
::
Rgb888
;
use
embedded_graphics
::
prelude
::{
Drawable
,
Point
,
RgbColor
,
Size
};
use
embedded_graphics
::
primitives
::
Primitive
;
use
embedded_graphics
::
primitives
::{
PrimitiveStyle
,
Rectangle
};
use
embedded_graphics
::{
draw_target
::
DrawTarget
,
prelude
::
OriginDimensions
};
pub
const
VIRTGPU_XRES
:
usize
=
1280
;
pub
const
VIRTGPU_YRES
:
usize
=
800
;
pub
const
VIRTGPU_LEN
:
usize
=
VIRTGPU_XRES
*
VIRTGPU_YRES
*
4
;
const
INIT_X
:
i32
=
640
;
const
INIT_Y
:
i32
=
400
;
const
RECT_SIZE
:
u32
=
40
;
pub
struct
Display
{
pub
size
:
Size
,
pub
point
:
Point
,
//pub fb: Arc<&'static mut [u8]>,
pub
fb
:
&
'static
mut
[
u8
],
}
impl
Display
{
pub
fn
new
(
size
:
Size
,
point
:
Point
)
->
Self
{
let
fb_ptr
=
framebuffer
()
as
*
mut
u8
;
println!
(
"Hello world from user mode program! 0x{:X} , len {}"
,
fb_ptr
as
usize
,
VIRTGPU_LEN
);
let
fb
=
unsafe
{
core
::
slice
::
from_raw_parts_mut
(
fb_ptr
as
*
mut
u8
,
VIRTGPU_LEN
as
usize
)
};
Self
{
size
,
point
,
fb
}
}
}
impl
OriginDimensions
for
Display
{
fn
size
(
&
self
)
->
Size
{
self
.size
}
}
impl
DrawTarget
for
Display
{
type
Color
=
Rgb888
;
type
Error
=
core
::
convert
::
Infallible
;
fn
draw_iter
<
I
>
(
&
mut
self
,
pixels
:
I
)
->
Result
<
(),
Self
::
Error
>
where
I
:
IntoIterator
<
Item
=
embedded_graphics
::
Pixel
<
Self
::
Color
>>
,
{
pixels
.into_iter
()
.for_each
(|
px
|
{
let
idx
=
((
self
.point.y
+
px
.0
.y
)
*
VIRTGPU_XRES
as
i32
+
self
.point.x
+
px
.0
.x
)
as
usize
*
4
;
if
idx
+
2
>=
self
.fb
.len
()
{
return
;
}
self
.fb
[
idx
]
=
px
.1
.b
();
self
.fb
[
idx
+
1
]
=
px
.1
.g
();
self
.fb
[
idx
+
2
]
=
px
.1
.r
();
});
framebuffer_flush
();
Ok
(())
}
}
pub
struct
DrawingBoard
{
disp
:
Display
,
latest_pos
:
Point
,
}
impl
DrawingBoard
{
pub
fn
new
()
->
Self
{
Self
{
disp
:
Display
::
new
(
Size
::
new
(
1280
,
800
),
Point
::
new
(
0
,
0
)),
latest_pos
:
Point
::
new
(
INIT_X
,
INIT_Y
),
}
}
fn
paint
(
&
mut
self
)
{
Rectangle
::
with_center
(
self
.latest_pos
,
Size
::
new
(
RECT_SIZE
,
RECT_SIZE
))
.into_styled
(
PrimitiveStyle
::
with_stroke
(
Rgb888
::
WHITE
,
1
))
.draw
(
&
mut
self
.disp
)
.ok
();
}
fn
unpaint
(
&
mut
self
)
{
Rectangle
::
with_center
(
self
.latest_pos
,
Size
::
new
(
RECT_SIZE
,
RECT_SIZE
))
.into_styled
(
PrimitiveStyle
::
with_stroke
(
Rgb888
::
BLACK
,
1
))
.draw
(
&
mut
self
.disp
)
.ok
();
}
pub
fn
move_rect
(
&
mut
self
,
dx
:
i32
,
dy
:
i32
)
{
self
.unpaint
();
self
.latest_pos.x
+=
dx
;
self
.latest_pos.y
+=
dy
;
self
.paint
();
}
}
const
LF
:
u8
=
0x0au8
;
const
CR
:
u8
=
0x0du8
;
#[no_mangle]
pub
fn
main
()
->
i32
{
// let fb_ptr = framebuffer() as *mut u8;
let
mut
board
=
DrawingBoard
::
new
();
for
i
in
0
..
20
{
let
c
=
getchar
();
if
c
==
LF
||
c
==
CR
{
break
;
}
board
.latest_pos.x
+=
i
;
board
.latest_pos.y
+=
i
;
board
.paint
();
}
0
}
user/src/bin/gui_simple.rs
浏览文件 @
af05b65e
#![no_std]
#![no_main]
use
user_lib
::{
framebuffer
,
framebuffer_flush
};
#[macro_use]
extern
crate
user_lib
;
// use embedded_graphics::pixelcolor::Rgb888;
// use embedded_graphics::prelude::{Drawable, Point, RgbColor, Size};
// use embedded_graphics::primitives::Primitive;
// use embedded_graphics::primitives::{PrimitiveStyle, Rectangle};
// use embedded_graphics::{
// draw_target::DrawTarget,
// prelude::{OriginDimensions},
// };
use
user_lib
::{
framebuffer
,
framebuffer_flush
};
pub
const
VIRTGPU_XRES
:
usize
=
1280
;
pub
const
VIRTGPU_YRES
:
usize
=
800
;
...
...
Miykael_xxm
🚴
@xiongjiamu
mentioned in commit
1f36062f
·
1月 08, 2023
mentioned in commit
1f36062f
mentioned in commit 1f36062ffaa5538ca8a35ecdad0f8bbd86c3f4d4
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录