chore: better docs, appease clippy
This commit is contained in:
parent
38e36b7bd5
commit
6be52230ce
@ -71,11 +71,9 @@ async fn scanner_task(mut pin_driver: pins::TransparentPins) {
|
||||
let mask = input ^ (((1 << pin_driver.n_total_pins) - 1) ^ (1 << gnd_pin));
|
||||
for input_pin in 0..pin_driver.n_total_pins {
|
||||
let input_pin = input_pin as u8;
|
||||
if ((1 << input_pin) & mask) != 0 {
|
||||
if n_connections < MAX_CONNECTIONS {
|
||||
connections[n_connections] = Some(Connection { gnd_pin, input_pin });
|
||||
n_connections += 1;
|
||||
}
|
||||
if ((1 << input_pin) & mask) != 0 && n_connections < MAX_CONNECTIONS {
|
||||
connections[n_connections] = Some(Connection { gnd_pin, input_pin });
|
||||
n_connections += 1;
|
||||
}
|
||||
}
|
||||
// this should avoid overexerting the components
|
||||
@ -84,8 +82,8 @@ async fn scanner_task(mut pin_driver: pins::TransparentPins) {
|
||||
}
|
||||
|
||||
log::info!("SCAN RESULTS");
|
||||
for i in 0..n_connections {
|
||||
match connections[i] {
|
||||
for v in connections.iter().take(n_connections) {
|
||||
match v {
|
||||
None => {}
|
||||
Some(con) => {
|
||||
log::warn!("GND {:0>2} -> INPUT {:0>2}", con.gnd_pin, con.input_pin);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
#![deny(rust_2018_idioms)]
|
||||
#![deny(rustdoc::broken_intra_doc_links)]
|
||||
|
||||
use embassy_time::Timer;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
13
src/midi.rs
13
src/midi.rs
@ -32,7 +32,7 @@ struct NoteMsg {
|
||||
|
||||
impl NoteMsg {
|
||||
fn new(on: bool, note: u8, velocity: u8) -> Self {
|
||||
return NoteMsg { on, note, velocity };
|
||||
NoteMsg { on, note, velocity }
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ struct ControllerMsg {
|
||||
|
||||
impl ControllerMsg {
|
||||
fn new(controller: Controller, value: u8) -> Self {
|
||||
return ControllerMsg { controller, value };
|
||||
ControllerMsg { controller, value }
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,10 +64,10 @@ struct MidiMsg {
|
||||
|
||||
impl MidiMsg {
|
||||
fn new(msg: MsgType, channel: u8) -> Self {
|
||||
return MidiMsg {
|
||||
MidiMsg {
|
||||
msg,
|
||||
channel: channel & 0xf,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,9 +115,10 @@ pub struct MidiChannel {
|
||||
|
||||
impl MidiChannel {
|
||||
pub fn new(channel: u8) -> Self {
|
||||
return MidiChannel { channel };
|
||||
MidiChannel { channel }
|
||||
}
|
||||
|
||||
/// MIDI Note-On
|
||||
pub async fn note_on(&self, note: u8, velocity: u8) {
|
||||
MIDI_QUEUE
|
||||
.send(MidiMsg::new(
|
||||
@ -127,6 +128,7 @@ impl MidiChannel {
|
||||
.await;
|
||||
}
|
||||
|
||||
/// MIDI Note-Off
|
||||
pub async fn note_off(&self, note: u8, velocity: u8) {
|
||||
MIDI_QUEUE
|
||||
.send(MidiMsg::new(
|
||||
@ -136,6 +138,7 @@ impl MidiChannel {
|
||||
.await;
|
||||
}
|
||||
|
||||
/// MIDI Controller (e.g. sustain pedal on/off)
|
||||
pub async fn controller(&self, ctrl: Controller, value: u8) {
|
||||
MIDI_QUEUE
|
||||
.send(MidiMsg::new(
|
||||
|
@ -103,7 +103,7 @@ pub struct TransparentPins {
|
||||
usable_extended_pins: usize,
|
||||
}
|
||||
|
||||
/// Helper to define the onboard pins in TransparentPins
|
||||
/// Helper to define the onboard pins in [`TransparentPins`]
|
||||
#[macro_export]
|
||||
macro_rules! pin_array {
|
||||
($($pin: expr),*) => {
|
||||
@ -171,7 +171,7 @@ impl TransparentPins {
|
||||
) -> Result<Self, Error> {
|
||||
let mut ret = TransparentPins {
|
||||
addrs,
|
||||
pins: pins.map(|x| Flex::new(x)),
|
||||
pins: pins.map(Flex::new),
|
||||
i2c_bus: shared_bus::BusManagerSimple::new(i2c),
|
||||
disable_unsafe_pins: false,
|
||||
usable_pins_per_extender: PINS_PER_EXTENDER,
|
||||
|
Loading…
Reference in New Issue
Block a user