Exception when i2c display is not connected during init
The following exception is thrown when i2c display support is enabled but the display is disconnected.
I don't have an SPI display to test if the issue happens there.
E (162) I2CDefaultWriteBytes: i2c_master_cmd_begin( I2CPortNumber, CommandHandle, pdMS_TO_TICKS( 1000 ) ) != ESP_OK, result: -1
abort() was called at PC 0x400e063a on core 0
0x400e063a: I2CDefaultWriteBytes at components/tarablessd1306/ifaces/default_if_i2c.c:107 (discriminator 4)
The issue can be resolved by changing line default_if_i2c.c:107, but I am unsure if this is the best practice or other implications of this change:
i2c_master_cmd_begin( I2CPortNumber, CommandHandle, pdMS_TO_TICKS( 1000 ) );
It's an acceptable workaround and raises a good issue about how I handle such errors.
The library assumes that if you initialize a display it's physically connected which is why I chose at the start for it to be a fatal error.
If you're looking at the examples you can comment out USE_I2C_DISPLAY and it will only use an SPI connected display instead,
Consider a piece of hardware using this library in the field.
If the screen becomes disconnected or damaged it prevents the whole system from coming up. In my opinion it is preferable the rest of the hardware continue operating as normal if possible, the alternative is a reboot loop.
Maybe another constant for REQUIRE_DISPLAY_ON_BOOT as it could be application specific.
OOOH I think I know what's going on.
I did make it a configurable option at one point, SSD1306_ERROR_ABORT is set by default so any time the library encounters an error it will call abort.
You can change this behaviour in menuconfig under Components->TarableSSD1306, let me know if it works and I apologize for the slowness of my reply.
hi, with SSD1306_ERROR_ABORT deactivated, the SSD1306_I2CMasterAttachDisplayDefault() returns true if the display is disconnected, and only printing the error on the console:
E (21938) I2CDefaultWriteBytes: i2c_master_cmd_begin( I2CPortNumber, CommandHandle, pdMS_TO_TICKS( 1000 ) ) != ESP_OK, result: -1
The right behavior would be to return false if the display failed to initialize.
Thank you for letting me know. I'm working out how I want to fix this.
Try the latest commit.