Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <[email protected]>
  • Loading branch information
patrickelectric committed Nov 22, 2024
1 parent 199b2a1 commit 22ea322
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
12 changes: 4 additions & 8 deletions benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use criterion::{criterion_group, criterion_main, Criterion};
use navigator_rs::{AdcChannel, Navigator, PwmChannel, UserLed};
use navigator_rs::{AdcChannel, Navigator, UserLed};

fn navigator_benchmark(c: &mut Criterion) {
#[macro_export]
Expand All @@ -26,17 +26,13 @@ fn navigator_benchmark(c: &mut Criterion) {
bench!(read_pressure());
bench!(read_temperature());

bench!(read_all());
bench!(read_adc_all());

// Benchmark Outputs
bench!(set_pwm_enable(false));
bench!(get_pwm_enable());
bench!(set_pwm_channel_value(PwmChannel::Ch1, 100));
bench!(set_pwm_freq_hz(60.0));
bench!(set_pwm_freq_prescale(100));

bench!(set_pwm_duty_cycle(0, 0.1));
bench!(set_pwm_frequency(60.0));
bench!(set_neopixel(&[[0, 0, 0]]));

bench!(set_led(UserLed::Led1, false));
bench!(set_led_toggle(UserLed::Led1));
bench!(get_led(UserLed::Led1));
Expand Down
14 changes: 14 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,20 @@ impl Navigator {
}
}

pub fn set_led_toggle(&mut self, select: UserLed) {
let index = match select {
UserLed::Led1 => 1,
UserLed::Led2 => 2,
UserLed::Led3 => 0,
};
let state = self.get_led(select);
if let Some(led_behaviour) = self.get_led_behaviour() {
led_behaviour.set_led(index, !state);
} else {
panic!("No LED controller available");
}
}

pub fn get_led(&mut self, select: UserLed) -> bool {
let index = match select {
UserLed::Led1 => 1,
Expand Down

0 comments on commit 22ea322

Please sign in to comment.