output channelization
This commit is contained in:
@@ -1,2 +1,52 @@
|
||||
pub const MCP23017_A_LED: u8 = 7;
|
||||
pub const MCP23017_B_LED: u8 = 7;
|
||||
#![allow(dead_code)]
|
||||
|
||||
use crate::hardware::mcp23017::{Mcp23017, Mcp23017OutputPin};
|
||||
use anyhow::Result;
|
||||
|
||||
pub const RCS5: PinoutChannel = PinoutChannel::ExtA(0);
|
||||
pub const RCS6: PinoutChannel = PinoutChannel::ExtA(1);
|
||||
pub const RCS7: PinoutChannel = PinoutChannel::ExtA(2);
|
||||
pub const RCS8: PinoutChannel = PinoutChannel::ExtA(3);
|
||||
pub const RCS9: PinoutChannel = PinoutChannel::ExtA(4);
|
||||
pub const MOTOR0_A: PinoutChannel = PinoutChannel::ExtA(5);
|
||||
pub const MOTOR0_B: PinoutChannel = PinoutChannel::ExtA(6);
|
||||
pub const LED_A: PinoutChannel = PinoutChannel::ExtA(7);
|
||||
pub const RCS0: PinoutChannel = PinoutChannel::ExtA(8);
|
||||
pub const RCS1: PinoutChannel = PinoutChannel::ExtA(9);
|
||||
pub const DRIVE0_BRAKE: PinoutChannel = PinoutChannel::ExtA(10);
|
||||
pub const DRIVE0_DIR: PinoutChannel = PinoutChannel::ExtA(11);
|
||||
pub const DRIVE0_DRIVEOFF: PinoutChannel = PinoutChannel::ExtA(12);
|
||||
pub const RCS2: PinoutChannel = PinoutChannel::ExtA(13);
|
||||
pub const RCS3: PinoutChannel = PinoutChannel::ExtA(14);
|
||||
pub const RCS4: PinoutChannel = PinoutChannel::ExtA(15);
|
||||
pub const MOTOR1_A: PinoutChannel = PinoutChannel::ExtB(8);
|
||||
pub const MOTOR1_B: PinoutChannel = PinoutChannel::ExtB(9);
|
||||
pub const MOTOR2_A: PinoutChannel = PinoutChannel::ExtB(10);
|
||||
pub const MOTOR2_B: PinoutChannel = PinoutChannel::ExtB(11);
|
||||
pub const MOTOR3_A: PinoutChannel = PinoutChannel::ExtB(12);
|
||||
pub const MOTOR3_B: PinoutChannel = PinoutChannel::ExtB(13);
|
||||
pub const OUT1: PinoutChannel = PinoutChannel::ExtB(14);
|
||||
pub const OUT2: PinoutChannel = PinoutChannel::ExtB(15);
|
||||
pub const OUT3: PinoutChannel = PinoutChannel::ExtB(0);
|
||||
pub const OUT4: PinoutChannel = PinoutChannel::ExtB(1);
|
||||
pub const OUT5: PinoutChannel = PinoutChannel::ExtB(2);
|
||||
pub const OUT6: PinoutChannel = PinoutChannel::ExtB(3);
|
||||
pub const OUT7: PinoutChannel = PinoutChannel::ExtB(4);
|
||||
pub const OUT8: PinoutChannel = PinoutChannel::ExtB(5);
|
||||
pub const OUT9: PinoutChannel = PinoutChannel::ExtB(6);
|
||||
pub const LED_B: PinoutChannel = PinoutChannel::ExtB(7);
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum PinoutChannel {
|
||||
ExtA(u8),
|
||||
ExtB(u8),
|
||||
}
|
||||
|
||||
impl PinoutChannel {
|
||||
pub fn new_output_pin<'a, MCP: Mcp23017>(self, ext_a: &'a MCP, ext_b: &'a MCP) -> Result<impl Mcp23017OutputPin + 'a> {
|
||||
match self {
|
||||
PinoutChannel::ExtA(pin) => ext_a.new_output_pin(pin),
|
||||
PinoutChannel::ExtB(pin) => ext_b.new_output_pin(pin),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user