Recover from init fail

This commit was merged in pull request #46.
This commit is contained in:
2026-08-29 18:17:25 +02:00
parent 92c20d61cb
commit 282bcd163c
4 changed files with 58 additions and 36 deletions
+5 -5
View File
@@ -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);