Skip to content

Commit 9ed6c8b

Browse files
committed
Stop communicating with display on error
1 parent 658e88a commit 9ed6c8b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

SSD1306/SSD1306.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ static int getRotation() {return 2;}
208208
static const int WIDTH = SSD1306_LCDWIDTH;
209209
static const int HEIGHT = SSD1306_LCDHEIGHT;
210210
static int8_t _i2caddr, _vccstate;
211+
static bool display_responding = true;
211212

212213
// the most basic function, set a single pixel
213214
void SSD1306_drawPixel(int16_t x, int16_t y, uint16_t color) {
@@ -340,6 +341,11 @@ void SSD1306_invertDisplay(uint8_t i) {
340341
#include "nrf_log_ctrl.h"
341342
void SSD1306_command(uint8_t c)
342343
{
344+
if (!display_responding)
345+
{
346+
// Do not attempt to communicate with the display
347+
return;
348+
}
343349
ret_code_t ret;
344350
static uint8_t data[2] = {0};
345351
data[1] = c;
@@ -348,8 +354,8 @@ void SSD1306_command(uint8_t c)
348354
{
349355
NRF_LOG_INFO("SSD1306_command twi failed with: %d", ret);
350356
NRF_LOG_FLUSH();
357+
display_responding = false;
351358
}
352-
APP_ERROR_CHECK(ret);
353359
}
354360

355361
// startscrollright
@@ -442,6 +448,11 @@ void SSD1306_dim(bool dim) {
442448
}
443449

444450
void SSD1306_display(void) {
451+
if (!display_responding)
452+
{
453+
// Do not attempt to communicate with the display
454+
return;
455+
}
445456
SSD1306_command(SSD1306_COLUMNADDR);
446457
SSD1306_command(0); // Column start address (0 = reset)
447458
SSD1306_command(SSD1306_LCDWIDTH-1); // Column end address (127 = reset)

0 commit comments

Comments
 (0)