Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shared: add defmt-log feature #26

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ to make it more visually appealing.

A simple Linux daemon to send CPU info to the device.

### Building

Install rustup per your Linux distribution to get a functioning Rust toolchain.
Use `cargo run` to test the daemon:

```sh
env RUST_LOG=debug cargo run
```

## daemon/windows

Windows service to send CPU info to the device.
Expand Down
2 changes: 1 addition & 1 deletion firmware/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ panic-probe = { version = "0.3.0", features = ["print-defmt"] }
postcard = "1.0.2"
rtic-core = "1.0.0"
rtic-monotonic = "1.0.0"
shared = { path = "../shared" }
shared = { path = "../shared", features = ["defmt-log"] }
rp2040-boot2 = "0.2.1"
rp2040-hal = { version = "0.6.0", features = ["rt", "rp2040-e5"] }
rp2040-monotonic = "<=1.1.0"
Expand Down
1 change: 1 addition & 0 deletions firmware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Install build environment:

```sh
rustup target add thumbv6m-none-eabi
cargo install flip-link
cargo install probe-run
```

Expand Down
6 changes: 5 additions & 1 deletion shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
defmt = "0.3.0"
defmt = { version = "0.3", optional = true }
serde = { version = "1.0", default-features = false, features = ["derive"] }

[features]
# Enable defmt support, firmware only.
defmt-log = ["dep:defmt"]
7 changes: 4 additions & 3 deletions shared/src/message.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use defmt::Format;
use serde::{Deserialize, Serialize};

#[derive(Debug, Format, Serialize, Deserialize)]
#[cfg_attr(feature = "defmt-log", derive(defmt::Format))]
#[derive(Debug, Serialize, Deserialize)]
pub enum FromHost {
ClearScreen,
ShowPerf(PerfData),
}

#[derive(Clone, Copy, Debug, Format, Serialize, Deserialize)]
#[cfg_attr(feature = "defmt-log", derive(defmt::Format))]
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
pub struct PerfData {
// Aggregate load of all CPU cores, 0-1.0.
pub all_cores_load: f32,
Expand Down