Skip to content

Commit

Permalink
remove most unwrap() calls (log and move on)
Browse files Browse the repository at this point in the history
  • Loading branch information
briandorsey committed Dec 26, 2024
1 parent c247442 commit cb27f24
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crafted_volts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ async fn main(spawner: Spawner) {
let mut audio1 = adc::Channel::new_pin(p.PIN_27, gpio::Pull::None);
let mut audio2 = adc::Channel::new_pin(p.PIN_26, gpio::Pull::None);

// if we can't spawn tasks, panic is the only option? Thus unwrap() OK here.
spawner
.spawn(audio_loop(
p.PWM_SLICE5,
Expand Down Expand Up @@ -424,7 +425,8 @@ async fn audio_loop(
// mux_state.main_knob, output_value, dac_buffer[0], dac_buffer[1]
// );
cs.set_low();
spi.blocking_write(&dac_buffer).unwrap();
spi.blocking_write(&dac_buffer)
.unwrap_or_else(|e| error!("error writing to DAC: {}", e));
cs.set_high();

dac_buffer = ((output_value.to_output() << 4 >> 4) | dac_config_b).to_be_bytes();
Expand All @@ -433,7 +435,8 @@ async fn audio_loop(
// mux_state.main_knob, output_value, dac_buffer[0], dac_buffer[1]
// );
cs.set_low();
spi.blocking_write(&dac_buffer).unwrap();
spi.blocking_write(&dac_buffer)
.unwrap_or_else(|e| error!("error writing to DAC: {}", e));
cs.set_high();

// audio LEDs
Expand Down

0 comments on commit cb27f24

Please sign in to comment.