Skip to content

Commit 6d399b7

Browse files
Merge pull request #11 from FrameworkComputer/inputmodule-command
2 parents ff3904f + 1da316a commit 6d399b7

File tree

10 files changed

+2449
-5
lines changed

10 files changed

+2449
-5
lines changed

Cargo.lock

Lines changed: 1021 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1+
# Not stable yet :(
2+
# Trackign issue: https://github.com/rust-lang/cargo/issues/9406
3+
# cargo-features = ["per-package-target"]
4+
15
[workspace]
26
resolver = "2"
37
members = [
48
"b1display",
59
"c1minimal",
610
"ledmatrix",
711
"lotus-inputmodules",
12+
"inputmodule-control"
813
]
914
# Don't build all of them by default.
1015
# Because that'll lead to all features enabled in `lotus-inputmodules` and it
1116
# doesn't currently support building with all features enabled at the same
1217
# time.
18+
# Can't add `inputmodule-control` because it must be built with the host system
19+
# target. But we set the default target to thumbv6m-none-eabi
1320
default-members = [
14-
"lotus-inputmodules"
21+
"lotus-inputmodules",
1522
]
1623

1724
#[patch.'https://github.com/rp-rs/rp-hal.git']

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ Examples
8686
./control.py --brightness 50
8787
```
8888

89+
## Control via Rust binary
90+
91+
Currently have to specify the build target because it's not possible to specify a per package build target.
92+
Tracking issue: https://github.com/rust-lang/cargo/issues/9406
93+
94+
```
95+
> cargo build --target x86_64-unknown-linux-gnu -p inputmodule-control
96+
> cargo run --target x86_64-unknown-linux-gnu -p inputmodule-control
97+
```
98+
8999
## Building
90100

91101
Dependencies: Rust

inputmodule-control/Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
edition = "2021"
3+
name = "inputmodule-control"
4+
version = "0.1.2-pre"
5+
6+
[dependencies]
7+
clap = { version = "4.0", features = ["derive"] }
8+
serialport = "4.2.0"
9+
10+
# For ledmatrix
11+
image = "0.24.5"
12+
rand = "0.8.5"
13+
chrono = "0.4.23"

inputmodule-control/src/b1display.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
use clap::Parser;
2+
3+
/// B1 Display
4+
#[derive(Parser, Debug)]
5+
#[command(arg_required_else_help = true)]
6+
pub struct B1DisplaySubcommand {
7+
/// Set sleep status or get, if no value provided
8+
#[arg(long)]
9+
pub sleeping: Option<Option<bool>>,
10+
11+
/// Jump to the bootloader
12+
#[arg(long)]
13+
pub bootloader: bool,
14+
15+
/// Crash the firmware (TESTING ONLY!)
16+
#[arg(long)]
17+
pub panic: bool,
18+
19+
/// Serial device, like /dev/ttyACM0 or COM0
20+
#[arg(long)]
21+
pub serial_dev: Option<String>,
22+
23+
/// Get the device version
24+
#[arg(short, long)]
25+
pub version: bool,
26+
27+
/// Turn display on/off
28+
// TODO: Allow getting current state
29+
#[arg(long)]
30+
pub display_on: Option<bool>,
31+
32+
/// Invert screen on/off
33+
// TODO: Allow getting current state
34+
#[arg(long)]
35+
pub invert_screen: Option<bool>,
36+
}

inputmodule-control/src/c1minimal.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
use clap::Parser;
2+
3+
#[derive(Clone, Copy, Debug, PartialEq, clap::ValueEnum)]
4+
pub enum Color {
5+
White,
6+
Black,
7+
Red,
8+
Green,
9+
Blue,
10+
Yellow,
11+
Cyan,
12+
Purple,
13+
}
14+
15+
#[derive(Parser, Debug)]
16+
#[command(arg_required_else_help = true)]
17+
pub struct C1MinimalSubcommand {
18+
/// Set sleep status or get, if no value provided
19+
#[arg(long)]
20+
pub sleeping: Option<Option<bool>>,
21+
22+
/// Jump to the bootloader
23+
#[arg(long)]
24+
pub bootloader: bool,
25+
26+
/// Crash the firmware (TESTING ONLY!)
27+
#[arg(long)]
28+
pub panic: bool,
29+
30+
/// Serial device, like /dev/ttyACM0 or COM0
31+
#[arg(long)]
32+
pub serial_dev: Option<String>,
33+
34+
/// Get the device version
35+
#[arg(short, long)]
36+
pub version: bool,
37+
38+
/// Set color
39+
// TODO: Allow getting current state
40+
#[arg(long)]
41+
#[clap(value_enum)]
42+
pub set_color: Option<Color>,
43+
}

0 commit comments

Comments
 (0)