Skip to content

Commit d4fab29

Browse files
authored
Add a way to add existing symbols as metrics (#25) + refactor
1 parent e391a35 commit d4fab29

31 files changed

Lines changed: 3015 additions & 1414 deletions

examples/simple/Cargo.lock

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

examples/simple/runner.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
probe-rs download $1 $2 $3
4+
../../probe-plotter-tools/target/release/viewer $1 $3

examples/simple/src/main.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
11
#![no_std]
22
#![no_main]
33

4+
use core::sync::atomic::{AtomicU32, Ordering};
45
use cortex_m_rt::entry;
56

67
use defmt_rtt as _;
78
use panic_halt as _;
8-
use probe_plotter::{make_metric, make_setting};
9+
use probe_plotter::{
10+
make_metric, make_metric_from_address, make_metric_from_base_with_offset, make_ptr,
11+
make_setting,
12+
};
13+
14+
#[unsafe(no_mangle)]
15+
static MY_ATOMIC: AtomicU32 = AtomicU32::new(42);
16+
17+
// Hardcoded address
18+
make_metric_from_address!(DWT_CYCCNT: i8 @ 0xE0001004, "DWT_CYCCNT");
919

1020
#[entry]
1121
fn main() -> ! {
1222
defmt::println!("Running...");
23+
24+
let mut my_base_ptr = make_ptr!(BASE_THING).unwrap();
25+
let mut base_thing: [u8; 10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
26+
my_base_ptr.set(&base_thing as *const _ as u32); // Ensure this is something that will effectivly live as long as this or any depending values will be plotted
27+
28+
make_metric_from_base_with_offset!(root.path.child: u8 @ BASE_THING + 3, "root.path.child");
29+
1330
let mut sawtooth = make_metric!(SAWTOOTH: i32 = 42, "(SAWTOOTH / 10) % 100").unwrap();
14-
defmt::println!("sawtooth initialized to: {}", sawtooth.get());
31+
//defmt::println!("sawtooth initialized to: {}", sawtooth.get());
1532
let mut sine = make_metric!(SINE: i32 = 42, "100 * sin(2 * pi * SINE / 4000)").unwrap();
1633

1734
let mut setting_roundtrip =
@@ -24,9 +41,13 @@ fn main() -> ! {
2441
for i in 0..i32::MAX {
2542
sawtooth.set(i);
2643
sine.set(i);
44+
MY_ATOMIC.fetch_add(1, Ordering::SeqCst);
2745

2846
setting_roundtrip.set(setting.get());
2947

48+
let idx = i as usize % base_thing.len();
49+
base_thing[idx] = base_thing[idx].wrapping_add(1);
50+
3051
cortex_m::asm::delay(100_000);
3152
}
3253
}

0 commit comments

Comments
 (0)