Trait rp6::uart::SerialWritable

source ·
pub trait SerialWritable {
    // Required method
    fn write_to_serial(&self);
}
Expand description

Trait to allow implementing specific Serial::write behavior for types.

Required Methods§

source

fn write_to_serial(&self)

Takes a reference to the instance of this type and writes it to the Serial connection.

Implementations on Foreign Types§

source§

impl SerialWritable for char

source§

fn write_to_serial(&self)

Writes a single character to the UART connection.

Example:

Serial::write('R');
Serial::write('P');
Serial::write('6');
Serial::write('\n'); // '\n' is a special code for the "new line" character!
Serial::write('0'); // the ASCII character '0'
Serial::write(48 as char); // 48 is numeric ASCII code for '0'
Serial::write(49 as char); // '1'
Serial::write(50 as char); // '2'
Serial::write(51 as char); // '3'

This example would send:

RP6
00123

via the robot’s serial connection.

source§

impl SerialWritable for &str

source§

fn write_to_serial(&self)

Write text to the Serial connection.

Implementors§

source§

impl<T: SerialWritableDecimal> SerialWritable for T

Default implementation for numbers is to format them as decimal.