Recover from init fail
This commit was merged in pull request #46.
This commit is contained in:
@@ -15,19 +15,20 @@ pub struct TertiaryDisplayPinConfiguration<'a> {
|
||||
}
|
||||
|
||||
impl<'a> TertiaryDisplayPinConfiguration<'a> {
|
||||
pub fn build(self) -> TertiaryDisplay<'a> {
|
||||
pub fn build(self) -> Result<TertiaryDisplay<'a>, Self> {
|
||||
let device = AtomicDevice::new(self.i2c);
|
||||
let mut lcd = CharacterDisplayPCF8574T::new(device, LcdDisplayType::Lcd16x2, Delay::new());
|
||||
match lcd.init() {
|
||||
Ok(()) => {
|
||||
log::info!("I2C tertiary LCD initialized on PCF8574T at address 0x27");
|
||||
TertiaryDisplay {
|
||||
Ok(TertiaryDisplay {
|
||||
display: lcd,
|
||||
charset: create_custom_char_set!(),
|
||||
}
|
||||
})
|
||||
}
|
||||
Err(e) => {
|
||||
panic!("I2C tertiary LCD init failed on PCF8574T at address 0x27: {e}");
|
||||
log::error!("I2C tertiary LCD init failed on PCF8574T at address 0x27: {e}");
|
||||
Err(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -407,4 +408,3 @@ pub const BOX: CharMap = [
|
||||
];
|
||||
|
||||
pub const EXAMPLE: CustomCharset = create_custom_char_set!(HEART, BOX, EMPTY);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user