pub fn configure_serial(ui: &mut egui::Ui, serial: &mut Serial, port: &Port) {
    let mut available_peripherals =
        pins::serial_tx(port).chain(pins::serial_rx(port)).map(|p| p.peripheral).collect_vec();
    available_peripherals.sort();
    available_peripherals.dedup();

    let first_valid_tx_pin = || {
        pins::serial_tx(port)
            .find_map(|p| (p.peripheral == available_peripherals[0]).then_some(p))
            .unwrap()
    };

    let first_valid_rx_pin = || {
        pins::serial_rx(port)
            .find_map(|p| (p.peripheral == available_peripherals[0]).then_some(p))
            .unwrap()
    };

    let mut serial_box = matches!(serial, Serial::Enabled { .. });
    ui.horizontal_wrapped(|ui| {
        ui.checkbox(&mut serial_box, "Serial Console");
        match (serial_box, &serial) {
            (true, Serial::Disabled) => {
                *serial = Serial::Enabled {
                    recovery_enabled: false,
                    tx_pin: first_valid_tx_pin(),
                    rx_pin: first_valid_rx_pin(),
                }
            }
            (false, Serial::Enabled { .. }) => *serial = Serial::Disabled,
            _ => {}
        };

        ui.label("Enable serial communications to retrieve information about the boot process.");
    });
    if let Serial::Enabled { recovery_enabled, tx_pin, rx_pin } = serial {
        define_serial_options(
            ui,
            port,
            recovery_enabled,
            tx_pin,
            rx_pin,
            available_peripherals.iter().cloned(),
        );
    }
}
/// Renders the menu that configures serial communication features, including
/// whether serial communication is available at all, whether it allows for image
/// recovery, and what pins and peripherals it uses in a particular port.
Renders the menu that configures serial communication features, including
whether serial communication is available at all, whether it allows for image
recovery, and what pins and peripherals it uses in a particular port.
Renders the menu that configures serial communication features including whether serial communication is available at all whether it allows for image recovery and what pins and peripherals it uses in a particular port .
pub fn configure_serial(ui: &mut egui::Ui, serial: &mut Serial, port: &Port) {
    let mut available_peripherals =
        pins::serial_tx(port).chain(pins::serial_rx(port)).map(|p| p.peripheral).collect_vec();
    available_peripherals.sort();
    available_peripherals.dedup();
    let first_valid_tx_pin = || {
        pins::serial_tx(port)
            .find_map(|p| (p.peripheral == available_peripherals[0]).then_some(p))
            .unwrap()
    };
    let first_valid_rx_pin = || {
        pins::serial_rx(port)
            .find_map(|p| (p.peripheral == available_peripherals[0]).then_some(p))
            .unwrap()
    };
    let mut serial_box = matches!(serial, Serial::Enabled { .. });
    ui.horizontal_wrapped(|ui| {
        ui.checkbox(&mut serial_box, "Serial Console");
        match (serial_box, &serial) {
            (true, Serial::Disabled) => {
                *serial = Serial::Enabled {
                    recovery_enabled: false,
                    tx_pin: first_valid_tx_pin(),
                    rx_pin: first_valid_rx_pin(),
                }
            }
            (false, Serial::Enabled { .. }) => *serial = Serial::Disabled,
            _ => {}
        };
        ui.label("Enable serial communications to retrieve information about the boot process.");
    });
    if let Serial::Enabled { recovery_enabled, tx_pin, rx_pin } = serial {
        define_serial_options(
            ui,
            port,
            recovery_enabled,
            tx_pin,
            rx_pin,
            available_peripherals.iter().cloned(),
        );
    }
}
pub fn configure_serial ( ui : & mut egui :: Ui , serial : & mut Serial , port : & Port ) { let mut available_peripherals = pins :: serial_tx ( port ) . chain ( pins :: serial_rx ( port ) ) . map ( | p | p . peripheral ) . collect_vec ( ) ; available_peripherals . sort ( ) ; available_peripherals . dedup ( ) ; let first_valid_tx_pin = | | { pins :: serial_tx ( port ) . find_map ( | p | ( p . peripheral == available_peripherals [ 0 ] ) . then_some ( p ) ) . unwrap ( ) } ; let first_valid_rx_pin = | | { pins :: serial_rx ( port ) . find_map ( | p | ( p . peripheral == available_peripherals [ 0 ] ) . then_some ( p ) ) . unwrap ( ) } ; let mut serial_box = matches ! ( serial Serial Enabled { } ) ; ui . horizontal_wrapped ( | ui | { ui . checkbox ( & mut serial_box , " " ) ; match ( serial_box , & serial ) { ( true , Serial :: Disabled ) => { * serial = Serial :: Enabled { recovery_enabled : false , tx_pin : first_valid_tx_pin ( ) , rx_pin : first_valid_rx_pin ( ) , } } ( false , Serial :: Enabled { .. } ) => * serial = Serial :: Disabled , _ => { } } ; ui . label ( " " ) ; } ) ; if let Serial :: Enabled { recovery_enabled , tx_pin , rx_pin } = serial { define_serial_options ( ui , port , recovery_enabled , tx_pin , rx_pin , available_peripherals . iter ( ) . cloned ( ) , ) ; } }
Renders the menu that configures serial communication features, including
whether serial communication is available at all, whether it allows for image
recovery, and what pins and peripherals it uses in a particular port.
Renders the menu that configures serial communication features including whether serial communication is available at all whether it allows for image recovery and what pins and peripherals it uses in a particular port .
ui
&mut egui::Ui
serial
&mut Serial
port
&Port
ui
&mut egui::Ui
serial
&mut Serial
port
&Port