Skip to content

Commit

Permalink
Change logic for when to display pick_list of functions
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewdavidmackenzie committed Sep 8, 2024
1 parent 6ab157b commit 85765a4
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 42 deletions.
20 changes: 10 additions & 10 deletions porky/src/pin_descriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const PIN_3: PinDescription = PinDescription {
bpn: 3,
bcm: None,
name: "Ground",
options: &[PinFunction::Ground],
options: &[],
};

const PIN_4: PinDescription = PinDescription {
Expand Down Expand Up @@ -86,7 +86,7 @@ const PIN_8: PinDescription = PinDescription {
bpn: 8,
bcm: None,
name: "Ground",
options: &[PinFunction::Ground],
options: &[],
};

const PIN_9: PinDescription = PinDescription {
Expand Down Expand Up @@ -143,7 +143,7 @@ const PIN_13: PinDescription = PinDescription {
bpn: 13,
bcm: None,
name: "Ground",
options: &[PinFunction::Ground],
options: &[],
};

const PIN_14: PinDescription = PinDescription {
Expand Down Expand Up @@ -200,7 +200,7 @@ const PIN_18: PinDescription = PinDescription {
bpn: 18,
bcm: None,
name: "Ground",
options: &[PinFunction::Ground],
options: &[],
};

const PIN_19: PinDescription = PinDescription {
Expand Down Expand Up @@ -257,7 +257,7 @@ const PIN_23: PinDescription = PinDescription {
bpn: 23,
bcm: None,
name: "Ground",
options: &[PinFunction::Ground],
options: &[],
};

const PIN_24: PinDescription = PinDescription {
Expand Down Expand Up @@ -310,7 +310,7 @@ const PIN_28: PinDescription = PinDescription {
bpn: 28,
bcm: None,
name: "Ground",
options: &[PinFunction::Ground],
options: &[],
};

const PIN_29: PinDescription = PinDescription {
Expand Down Expand Up @@ -358,7 +358,7 @@ const PIN_33: PinDescription = PinDescription {
bpn: 33,
bcm: None,
name: "3V3",
options: &[PinFunction::Power3V3],
options: &[],
};

const PIN_34: PinDescription = PinDescription {
Expand All @@ -383,21 +383,21 @@ const PIN_36: PinDescription = PinDescription {
bpn: 36,
bcm: None,
name: "3V3(OUT)",
options: &[PinFunction::Power3V3],
options: &[],
};

const PIN_37: PinDescription = PinDescription {
bpn: 37,
bcm: None,
name: "3V3_EN",
options: &[PinFunction::Power3V3],
options: &[],
};

const PIN_38: PinDescription = PinDescription {
bpn: 38,
bcm: None,
name: "Ground",
options: &[PinFunction::Ground],
options: &[],
};

const PIN_39: PinDescription = PinDescription {
Expand Down
2 changes: 0 additions & 2 deletions porky/src/porky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ async fn apply_pin_config<'a>(
set_output_level(control, gpio_pins, bcm_pin_number, *l).await;
}
}

_ => error!("Unsupported Pin Function"),
}

info!("New pin config for pin #{}", bcm_pin_number);
Expand Down
1 change: 0 additions & 1 deletion src/hw/hardware_description.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ impl PinDescriptionSet {
let mut pins = self
.pins
.iter()
.filter(|pin| pin.options.len() > 1)
.filter(|pin| pin.bcm.is_some())
.collect::<Vec<&PinDescription>>();
pins.sort_by_key(|pin| pin.bcm.expect("Could not get BCM pin number"));
Expand Down
24 changes: 12 additions & 12 deletions src/hw/pin_descriptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ pub(crate) const PIN_1: PinDescription = PinDescription {
bpn: 1,
bcm: None,
name: Cow::Borrowed("3V3"),
options: Cow::Borrowed(&[PinFunction::Power3V3]),
options: Cow::Borrowed(&[]),
};

pub(crate) const PIN_2: PinDescription = PinDescription {
bpn: 2,
bcm: None,
name: Cow::Borrowed("5V"),
options: Cow::Borrowed(&[PinFunction::Power5V]),
options: Cow::Borrowed(&[]),
};

/// "Pins GPIO2 and GPIO3 have fixed pull-up resistors"
Expand All @@ -59,7 +59,7 @@ pub(crate) const PIN_4: PinDescription = PinDescription {
bpn: 4,
bcm: None,
name: Cow::Borrowed("5V"),
options: Cow::Borrowed(&[PinFunction::Power5V]),
options: Cow::Borrowed(&[]),
};

/// "Pins GPIO2 and GPIO3 have fixed pull-up resistors"
Expand All @@ -83,7 +83,7 @@ pub(crate) const PIN_6: PinDescription = PinDescription {
bpn: 6,
bcm: None,
name: Cow::Borrowed("Ground"),
options: Cow::Borrowed(&[PinFunction::Ground]),
options: Cow::Borrowed(&[]),
};

pub(crate) const PIN_7: PinDescription = PinDescription {
Expand Down Expand Up @@ -122,7 +122,7 @@ pub(crate) const PIN_9: PinDescription = PinDescription {
bpn: 9,
bcm: None,
name: Cow::Borrowed("Ground"),
options: Cow::Borrowed(&[PinFunction::Ground]),
options: Cow::Borrowed(&[]),
};

pub(crate) const PIN_10: PinDescription = PinDescription {
Expand Down Expand Up @@ -193,7 +193,7 @@ pub(crate) const PIN_14: PinDescription = PinDescription {
bpn: 14,
bcm: None,
name: Cow::Borrowed("Ground"),
options: Cow::Borrowed(&[PinFunction::Ground]),
options: Cow::Borrowed(&[]),
};

pub(crate) const PIN_15: PinDescription = PinDescription {
Expand Down Expand Up @@ -232,7 +232,7 @@ pub(crate) const PIN_17: PinDescription = PinDescription {
bpn: 17,
bcm: None,
name: Cow::Borrowed("3V3"),
options: Cow::Borrowed(&[PinFunction::Power3V3]),
options: Cow::Borrowed(&[]),
};

pub(crate) const PIN_18: PinDescription = PinDescription {
Expand Down Expand Up @@ -272,7 +272,7 @@ pub(crate) const PIN_20: PinDescription = PinDescription {
bpn: 20,
bcm: None,
name: Cow::Borrowed("Ground"),
options: Cow::Borrowed(&[PinFunction::Ground]),
options: Cow::Borrowed(&[]),
};

/// See [SPI Interface description](https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#serial-peripheral-interface-spi)
Expand Down Expand Up @@ -346,7 +346,7 @@ pub(crate) const PIN_25: PinDescription = PinDescription {
bpn: 25,
bcm: None,
name: Cow::Borrowed("Ground"),
options: Cow::Borrowed(&[PinFunction::Ground]),
options: Cow::Borrowed(&[]),
};

/// See [SPI Interface description](https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#serial-peripheral-interface-spi)
Expand Down Expand Up @@ -414,7 +414,7 @@ pub(crate) const PIN_30: PinDescription = PinDescription {
bpn: 30,
bcm: None,
name: Cow::Borrowed("Ground"),
options: Cow::Borrowed(&[PinFunction::Ground]),
options: Cow::Borrowed(&[]),
};

pub(crate) const PIN_31: PinDescription = PinDescription {
Expand Down Expand Up @@ -469,7 +469,7 @@ pub(crate) const PIN_34: PinDescription = PinDescription {
bpn: 34,
bcm: None,
name: Cow::Borrowed("Ground"),
options: Cow::Borrowed(&[PinFunction::Ground]),
options: Cow::Borrowed(&[]),
};

pub(crate) const PIN_35: PinDescription = PinDescription {
Expand Down Expand Up @@ -540,7 +540,7 @@ pub(crate) const PIN_39: PinDescription = PinDescription {
bpn: 39,
bcm: None,
name: Cow::Borrowed("Ground"),
options: Cow::Borrowed(&[PinFunction::Ground]),
options: Cow::Borrowed(&[]),
};

pub(crate) const PIN_40: PinDescription = PinDescription {
Expand Down
6 changes: 0 additions & 6 deletions src/hw/pin_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,13 @@ mod test {
#[test]
fn display_pin_function() {
let functions = vec![
PinFunction::Ground,
PinFunction::None,
PinFunction::Power3V3,
PinFunction::Output(None),
PinFunction::Output(Some(true)),
PinFunction::Output(Some(false)),
PinFunction::Input(None),
PinFunction::Input(Some(PullUp)),
PinFunction::Input(Some(PullDown)),
PinFunction::I2C_EEPROM_ID_SC,
PinFunction::I2C_EEPROM_ID_SD,
PinFunction::Power3V3,
PinFunction::Power5V,
];

for function in functions {
Expand Down
9 changes: 0 additions & 9 deletions src/hw_definition/pin_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ use serde::{Deserialize, Serialize};
pub enum PinFunction {
None,

/// HAT ID related functions - two pins to talk to HAT EEPROM via I2C
I2C_EEPROM_ID_SD,
I2C_EEPROM_ID_SC,

/// Power and Ground functions
Power3V3,
Power5V,
Ground,

/// GPIO functions
Input(Option<InputPull>),
Output(Option<PinLevel>),
Expand Down
3 changes: 1 addition & 2 deletions src/views/hardware_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,7 @@ fn create_pin_view_side<'a>(
.width(Length::Fixed(PIN_OPTION_WIDTH))
.align_items(Alignment::Center);

if pin_description.options.len() > 1 {
let bcm_pin_number = pin_description.bcm.unwrap();
if let Some(bcm_pin_number) = pin_description.bcm {
let mut pin_options_row = Row::new().align_items(Alignment::Center);

// Filter options
Expand Down

0 comments on commit 85765a4

Please sign in to comment.