Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
nikkoxp committed Jul 31, 2024
1 parent 918b863 commit 944d56d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions examples/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@ fn main() {
return;
}
//getting the number of channels
let number_channels: usize = match Adc::get_number_of_channels() {
Ok(channel) => channel as usize,
Err(_) => {
writeln!(Console::writer(), "can't get number of channels").unwrap();
return;
}
let Ok(number_channels) = Adc::get_number_of_channels() else {
writeln!(Console::writer(), "can't get number of channels").unwrap();
return;
};
loop {
for i in 0..number_channels {
match Adc::read_single_sample_sync(i) {
match Adc::read_single_sample_sync(i as usize) {
Ok(adc_val) => writeln!(Console::writer(), "Sample: {}\n", adc_val).unwrap(),
Err(_) => writeln!(Console::writer(), "error while reading sample",).unwrap(),
}
Expand Down

0 comments on commit 944d56d

Please sign in to comment.