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