Skip to content

Commit

Permalink
shared: add defmt-log feature
Browse files Browse the repository at this point in the history
Signed-off-by: James Hillyerd <[email protected]>
  • Loading branch information
jhillyerd committed Nov 16, 2023
1 parent 1892812 commit 3c0b7eb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
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
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

0 comments on commit 3c0b7eb

Please sign in to comment.