Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
Signed-off-by: iotah <[email protected]>
  • Loading branch information
IotaHydrae committed Oct 2, 2024
1 parent 701d927 commit 86edba1
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 5 deletions.
Binary file modified assets/images/bonus-dm-0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions content/docs/bonus/dm.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ seo:

### FPC-ZH096G1321

{{< figure
process="fill 480x270"
{{< picture
src="images/bonus-dm-0.jpg"
class="rounded-3"
alt=""
>}}
Expand All @@ -41,8 +41,8 @@ seo:
### SINQ13001BL-A1

{{< figure
process="fill 480x270"
src="images/bonus-dm-1.jpg"
class="rounded-3"
alt=""
>}}
Expand Down
15 changes: 15 additions & 0 deletions content/docs/porting/arduino.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: "Arduino"
description: ""
summary: ""
date: 2024-10-03T01:05:49+08:00
lastmod: 2024-10-03T01:05:49+08:00
draft: false
weight: 1107
toc: true
seo:
title: "" # custom title (optional)
description: "" # custom description (recommended)
canonical: "" # custom canonical URL (optional)
noindex: false # false (default) or true
---
2 changes: 1 addition & 1 deletion content/docs/porting/eez-studio.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ summary: ""
date: 2024-05-04T22:52:10+08:00
lastmod: 2024-05-04T22:52:10+08:00
draft: false
weight: 1108
weight: 1110
toc: true
seo:
title: "" # custom title (optional)
Expand Down
113 changes: 113 additions & 0 deletions content/docs/porting/embedded_graphics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
title: "embedded_graphics"
description: ""
summary: ""
date: 2024-10-03T00:38:17+08:00
lastmod: 2024-10-03T00:38:17+08:00
draft: false
weight: 1108
toc: true
seo:
title: "" # custom title (optional)
description: "" # custom description (recommended)
canonical: "" # custom canonical URL (optional)
noindex: false # false (default) or true
---

[rp-rs](https://github.com/rp-rs) 组织为RP2040开发了一个 Rust Embedded-HAL [rp-hal](https://github.com/rp-rs/rp-hal),他们还提供了一个[工程模板](https://github.com/rp-rs/rp2040-project-template),我们将在此工程基础上展开移植工作。

为了支持显示功能,我们需要在Cargo.toml中添加额外的crate:
```toml
embedded-graphics = "0.8.0"
embedded-graphics-core = "0.4.0"
display-interface-parallel-gpio = "0.7.0" # 提供数据接口,实现 WriteOnlyDataCommand trait
mipidsi = "0.8.0" # 提供 Display struct
```

在main.rs中,引用必要的crate:
```rust
// 使用兼容型号 ILI9486Rgb565,旋转等。
use mipidsi::{models::ILI9486Rgb565, options::Orientation, options::Rotation};
use mipidsi::options::ColorOrder;

// embedded_graphics 的一些接口等
use embedded_graphics::{
mono_font::{ascii::FONT_10X20, MonoTextStyle},
pixelcolor::Rgb888,
prelude::*,
primitives::{
Circle, PrimitiveStyle, PrimitiveStyleBuilder, Rectangle, StrokeAlignment, Triangle,
},
text::{Alignment, Text},
};

// 提供 8080 16bit BUS GPIO 接口
use display_interface_parallel_gpio::{Generic16BitBus, PGPIO16BitInterface};

// 提供 Display struct
use mipidsi::Builder;
```

定义需要用到的 Pins
```rust
let rst = pins.gpio22.into_push_pull_output_in_state(gpio::PinState::High);
let wr = pins.gpio19.into_push_pull_output_in_state(gpio::PinState::High);
let dc = pins.gpio20.into_push_pull_output();
let _blk = pins.gpio28.into_push_pull_output_in_state(gpio::PinState::High);

let lcd_d0 = pins.gpio0.into_push_pull_output();
let lcd_d1 = pins.gpio1.into_push_pull_output();
let lcd_d2 = pins.gpio2.into_push_pull_output();
let lcd_d3 = pins.gpio3.into_push_pull_output();
let lcd_d4 = pins.gpio4.into_push_pull_output();
let lcd_d5 = pins.gpio5.into_push_pull_output();
let lcd_d6 = pins.gpio6.into_push_pull_output();
let lcd_d7 = pins.gpio7.into_push_pull_output();
let lcd_d8 = pins.gpio8.into_push_pull_output();
let lcd_d9 = pins.gpio9.into_push_pull_output();
let lcd_d10 = pins.gpio10.into_push_pull_output();
let lcd_d11 = pins.gpio11.into_push_pull_output();
let lcd_d12 = pins.gpio12.into_push_pull_output();
let lcd_d13 = pins.gpio13.into_push_pull_output();
let lcd_d14 = pins.gpio14.into_push_pull_output();
let lcd_d15 = pins.gpio15.into_push_pull_output();
```

创建 Display Interface,实现了 WriteOnlyDataCommand trait 的 struct
```rust
let bus = Generic16BitBus::new((
lcd_d0,
lcd_d1,
lcd_d2,
lcd_d3,
lcd_d4,
lcd_d5,
lcd_d6,
lcd_d7,
lcd_d8,
lcd_d9,
lcd_d10,
lcd_d11,
lcd_d12,
lcd_d13,
lcd_d14,
lcd_d15,
));

let di = PGPIO16BitInterface::new(bus, dc, wr);
```

定义旋转属性
```rust
let rotation = Orientation::new().rotate(Rotation::Deg270).flip_horizontal();
```

创建 Display struct, 并初始化,大部分显示库都是在此基础上绘制图形。
```rust
let mut display = Builder::new(ILI9486Rgb565, di)
.reset_pin(rst)
.color_order(ColorOrder::Bgr)
.orientation(rotation)
.init(&mut delay)
.unwrap();
```
2 changes: 1 addition & 1 deletion content/docs/porting/slint.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ summary: ""
date: 2024-05-04T22:52:10+08:00
lastmod: 2024-05-04T22:52:10+08:00
draft: false
weight: 1107
weight: 1109
toc: true
seo:
title: "" # custom title (optional)
Expand Down
3 changes: 3 additions & 0 deletions hugo_stats.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@
"ol",
"p",
"path",
"picture",
"pre",
"script",
"section",
"small",
"source",
"span",
"strong",
"style",
Expand Down Expand Up @@ -246,6 +248,7 @@
"px-0",
"query-no-results",
"rounded",
"rounded-3",
"rounded-pill",
"row",
"row-about",
Expand Down

0 comments on commit 86edba1

Please sign in to comment.