Skip to content

Commit b2848eb

Browse files
authored
Merge pull request #8 from kons-9/develop
For Tei2024
2 parents 2fbf9d1 + 757d6bc commit b2848eb

File tree

127 files changed

+5875
-1942
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+5875
-1942
lines changed

.cargo/config.toml.org

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[build]
2+
target = "riscv32imc-esp-espidf"
3+
4+
# [target.riscv32imc-esp-espidf]
5+
# linker = "ldproxy"
6+
# runner = "espflash --monitor" # Select this runner for espflash v1.x.x
7+
# runner = "espflash flash --monitor /dev/ttyACM0" # Select this runner for espflash v2.x.x
8+
# rustflags = ["-C", "default-linker-libraries"]
9+
# rustflags = ["--cfg", "espidf_time64", "-C", "default-linker-libraries"]
10+
11+
[unstable]
12+
build-std = ["std", "panic_abort"]
13+
14+
[env]
15+
# Note: these variables are not used when using pio builder (`cargo build --features pio`)
16+
ESP_IDF_VERSION = "release/v4.4"
17+
# ESP_IDF_VERSION = "v5.1"
18+

.gitignore

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
/.vscode
2-
/.embuild
3-
/target
4-
/Cargo.lock
1+
.vscode
2+
.embuild
3+
.cache
4+
target
5+
Cargo.lock
56
cfg.toml
6-
src/bin/write_efuse_localnet_*.rs
7+
tmp
8+
9+
shapechangeable-display/src/bin/write_efuse_localnet_*.rs

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "shapechangeable-display/gen_asset/raw_translater"]
2+
path = shapechangeable-display/gen_asset/raw_translater
3+
url = https://github.com/kons-9/raw_translater

Cargo.toml

Lines changed: 16 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,19 @@
1-
[package]
2-
name = "std-display"
3-
version = "0.1.0"
4-
authors = ["toshiki goto <[email protected]>"]
5-
edition = "2021"
1+
[workspace]
62
resolver = "2"
7-
rust-version = "1.66"
83

9-
[profile.release]
10-
opt-level = "s"
11-
12-
[profile.dev]
13-
debug = true # Symbols are nice and they don't increase the size on Flash
14-
opt-level = "z"
15-
16-
[features]
17-
18-
default = ["std", "hal", "esp-idf-sys/native"]
19-
20-
21-
pio = ["esp-idf-sys/pio"]
22-
all = ["std", "nightly", "experimental", "embassy"]
23-
hal = ["esp-idf-hal", "embedded-svc", "esp-idf-svc"]
24-
std = ["alloc", "esp-idf-sys/std", "esp-idf-sys/binstart", "embedded-svc?/std", "esp-idf-hal?/std", "esp-idf-svc?/std"]
25-
alloc = ["embedded-svc?/alloc", "esp-idf-hal?/alloc", "esp-idf-svc?/alloc"]
26-
nightly = ["embedded-svc?/nightly", "esp-idf-svc?/nightly"] # Future: "esp-idf-hal?/nightly"
27-
experimental = ["embedded-svc?/experimental", "esp-idf-svc?/experimental"]
28-
embassy = ["esp-idf-hal?/embassy-sync", "esp-idf-hal?/critical-section", "esp-idf-hal?/edge-executor", "esp-idf-svc?/embassy-time-driver", "esp-idf-svc?/embassy-time-isr-queue"]
29-
30-
[dependencies]
31-
log = { version = "0.4.19", default-features = false }
32-
esp-idf-sys = { version = "0.33", default-features = false }
33-
esp-idf-hal = { version = "0.41", optional = true, default-features = false }
34-
esp-idf-svc = { version = "0.46", optional = true, default-features = false }
35-
embedded-svc = { version = "0.25", optional = true, default-features = false }
36-
anyhow = "1.0.71"
37-
shtcx = "0.11.0"
38-
toml-cfg = "0.1.3"
39-
rand = "0.8.5"
40-
esp32c3 = "0.15.0"
41-
num_enum = "0.6.1"
42-
st7735-lcd = "0.9.0"
43-
embedded-graphics = "0.8.0"
44-
embedded-hal = "0.2.7"
45-
46-
[build-dependencies]
47-
embuild = "0.31.2"
48-
anyhow = "1.0.71"
49-
toml-cfg = "0.1.3"
50-
num_enum = "0.6.1"
51-
52-
# [[bin]]
53-
# name = "read_efuse"
54-
# path = "examples/read_efuse.rs"
55-
#
56-
# [[bin]]
57-
# name = "st7735_display"
58-
# path = "examples/st7735_display.rs"
59-
#
60-
# [[bin]]
61-
# name = "uartex"
62-
# path = "examples/uartex.rs"
4+
members = [
5+
"ota",
6+
"shapechangeable-display",
7+
"network-node",
8+
"global-network",
9+
"applications",
10+
]
11+
# resolver = "2"
12+
13+
# [profile.release]
14+
# opt-level = "s"
6315
#
16+
# [profile.dev]
17+
# debug = true
18+
# opt-level = "z"
19+

README.md

Lines changed: 11 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,14 @@
1-
# Shape changeable display
1+
# ShapeChangeable Display
22

3-
## WIP
3+
## Overview
4+
This project is a reference implementation of the shapechangeable display.
45

5-
## test of hardware
6-
You can use example/\*.rs as test of hardware.
7-
But be careful using efuse-write function. it is not recoverable after you execute it.(you can generate using generate.zsh)
8-
<!-- But you should not use efuse.rs before -->
6+
## Usage
7+
### Prerequisites
8+
you should install tools following [ESP Book](https://esp-rs.github.io/book/introduction.html)
99

10-
# documents
11-
## Flit
12-
Flit consists of 64 bits. Flit type is only four types, basic three types, head, body and tail, and irregular one type, nope flit.
13-
A header of flit(packet) that need only head flit begin with H.
14-
An ack flit (, which header is HAck) is generally sent by the system when it receive a flit.
15-
Nope flit will used for timing adjustment.
16-
17-
### HeadFlit
18-
HeadFlit id is 0.
19-
20-
FlitType(2) | LengthOfFlit(6) | Header(8) | SourceId(16) | DestinationId(16) | PacketId(8) | Checksum(8)
21-
:--:|:--:|:--:|:--:|:--:|:--:|:--:
22-
### Body and TailFlit
23-
24-
FlitType(2) | FlitId(6) | Message(48) | Checksum(8)
25-
:--:|:--:|:--:|:--:
26-
### NopeFlit
27-
28-
FlitType(2) | (undefined)(62)
29-
:--:|:--:
30-
31-
todo: flitId and length of flit is mod 6bit.
32-
33-
## Packet
34-
General packet, which means the packet have body and tail flit, has packetid, global sourceId, global destinationId and checksum like below.
35-
36-
packetId(8) | checksum(8) | globalDestinationId(16) | globalDestinationId(16) | data(...)
37-
:--:|:--:|:--:|:--:|:--:
38-
39-
This means first body flit doesn't have any messages.
40-
41-
## Network Protocol
42-
Network Protocol must implement `network::protocol::Protocol` trait.
43-
44-
## About Each Process and detail of Packets
45-
This section explains processes and their packets.
46-
Note that explanations of these packets is data region of Packet.
47-
48-
### General case
49-
If you want to use the library with other application, you use these packets.
50-
51-
#### General ack
52-
##### Explanation
53-
If you want to make ack packet in system such as TCP, you can use this packet.
54-
##### Implementation
55-
Only head flit.
56-
Header is `GeneralAck`, not `HAck`, which is used for the system flit.
57-
58-
#### General data
59-
##### Explanation
60-
This library is not process this packet.
61-
So, you should reshape it into any form you want.
62-
##### Implementation
63-
Header is `Data`.
64-
65-
#### Error
66-
##### Explanation
67-
Flit error is mainly processed by the library, but packet error isn't.
68-
So, you should handle with this packet.
69-
This error may occur in checksum process of packet.
70-
So, you should resend packet, but it's optional.
71-
##### Implementation
72-
Header is `Error`.
73-
74-
### Making local network
75-
These packets are used for making local network by system.
76-
The process is this:
77-
1. the system sent check connection packet periodically, and then, receive check connection.
78-
2. If the system receive check connection packet, then sent request confirmed coordinate packet.
79-
3. If the system receive sufficient number of confirm coordinate packets, the system can analyse coordinate.
80-
81-
#### Check connection
82-
##### Explanation
83-
In this system, because unit of shapechangeable display is 4 nodes, these nodes connect each others. But, the unit should connect other units. This packet is used then firstly.
84-
##### Implementation
85-
Only head flit. This packet is broadcast but processed only in other local networks.
86-
Header is `HCheckConnection`.
87-
88-
#### Request confirmed coordinate
89-
##### Explanation
90-
Due to get global coordinate, you should access other nodes' coordinate.
91-
##### Implementation
92-
Only head flit. This packet is sent by broadcast.
93-
Header is `HRequestConfirmedCoordinate`
94-
95-
#### Reply for request confirmed coordinate
96-
##### Explanation
97-
this packet is reply for request confirmed coordinate packet.
98-
99-
##### Implementation
100-
When the system receive this packet, system will check the global source address of packet.
101-
If it is sent from a node which is in the same local network and is not confirmed, the packet has information of nodes which is next to the node not in local network. Otherwise, the packet is only sent by confirmed node.
102-
103-
Data form is like this:
104-
105-
is confirmed(8) | id(16) | x(16) | y(16) | id(16) | ...
106-
:--:|:--:|:--:|:--:|:--:|:--:
107-
108-
Node that received this packet is in the same node as local
109-
This packet is sent by broadcast.
110-
Header is `ConfirmCoordinate`
111-
112-
### Joining global network
113-
Todo: These packets are used for making global network by system.
114-
115-
#### Request join network
116-
##### Explanation
117-
##### Implementation
118-
119-
#### Reply for request join network
120-
##### Explanation
121-
##### Implementation
122-
123-
# Note
124-
* a requirement of packet that has only headflit is that
125-
** this data doesn't need to have a address that specify original source id, or this data is sent to just next node and this information is included in header.
126-
127-
# todo
128-
I put `todo:` in source file in detail. Others are below.
129-
* Handle uart interruption
130-
* Handle uart buffer overflow
131-
* Use flit buffer
10+
### Run Example
11+
```
12+
% cd shapechangeable-display
13+
% cargo espflash flash --monitor --release --example estimate_coordinate_tei
14+
```

applications/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "applications"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
embedded-graphics = "0.8.1"
10+
anyhow = "1.0.72"
11+
network-node = { path = "../network-node" }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

applications/src/lib.rs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
use crate::manager::MessageQueue;
2+
use anyhow::Result;
3+
use network_node::header::Header;
4+
use std::sync::Arc;
5+
use std::thread;
6+
use std::thread::JoinHandle;
7+
8+
pub mod manager;
9+
pub mod task;
10+
11+
// App is Sized
12+
pub trait App {
13+
// interface of network
14+
// type Output;
15+
fn process_messages(&mut self, messages: Vec<u8>) -> Result<()>;
16+
17+
/// default do nothing
18+
fn set_priority(&mut self, priority: u8) {
19+
eprintln!("priority: {}, but not implemented", priority);
20+
()
21+
}
22+
23+
/// default error handler is just ignore it
24+
fn error_handler(&mut self, error: anyhow::Error) -> Result<()> {
25+
eprintln!("error: {}", error);
26+
Ok(())
27+
}
28+
29+
/// if this app is related to a specific header, return it
30+
fn my_headers(&self) -> Option<Vec<Header>> {
31+
None
32+
}
33+
34+
/// default app wake up only when message is received and host notifys it
35+
fn create_task(mut self, message: &Arc<MessageQueue>, priority: u8) -> JoinHandle<()>
36+
where
37+
Self: Sized + Send + 'static,
38+
{
39+
let message = Arc::clone(message);
40+
self.set_priority(priority);
41+
thread::spawn(move || loop {
42+
let old_message = {
43+
// swap message and release lock
44+
let message_queue = message.queue.lock().unwrap();
45+
let mut message = message
46+
.condvar
47+
.wait_while(message_queue, |q| q.is_empty())
48+
.unwrap();
49+
let mut old_message = Vec::new();
50+
std::mem::swap(&mut *message, &mut old_message);
51+
old_message
52+
};
53+
54+
self.process_messages(old_message)
55+
.map_err(|e| self.error_handler(e))
56+
.unwrap();
57+
})
58+
}
59+
}
60+
61+
pub struct Output();
62+
63+
pub mod image {
64+
use anyhow::Result;
65+
66+
pub struct GetImageApp {}
67+
impl GetImageApp {
68+
pub fn new() -> Self {
69+
Self {}
70+
}
71+
}
72+
impl super::App for GetImageApp {
73+
// type Output = (Vec<u8>, u32, Option<Point>);
74+
75+
fn process_messages(&mut self, messages: Vec<u8>) -> Result<()> {
76+
println!("get image: {:?}", messages);
77+
unimplemented!()
78+
}
79+
}
80+
}

0 commit comments

Comments
 (0)