From b92bf18490e94e7ed7e034b0645157aa2a87407e Mon Sep 17 00:00:00 2001 From: Adam Candy Date: Thu, 3 Dec 2020 09:52:12 +0100 Subject: [PATCH 1/2] Adds support for the smaller 64x32 ssd1306 displays --- adafruit_ssd1306.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/adafruit_ssd1306.py b/adafruit_ssd1306.py index a95d815..daceedb 100644 --- a/adafruit_ssd1306.py +++ b/adafruit_ssd1306.py @@ -89,6 +89,16 @@ def power(self): def init_display(self): """Base class to initialize display""" + # The various screen sizes available with the ssd1306 OLED driver + # chip require differing configuration values for the display clock + # div and com pin, which are listed below for reference and future + # compatibility: + # w, h: DISP_CLK_DIV COM_PIN_CFG + # 128, 64: 0x80 0x12 + # 128, 32: 0x80 0x02 + # 96, 16: 0x60 0x02 + # 64, 48: 0x80 0x12 + # 64, 32: 0x80 0x12 for cmd in ( SET_DISP | 0x00, # off # address setting @@ -103,7 +113,7 @@ def init_display(self): SET_DISP_OFFSET, 0x00, SET_COM_PIN_CFG, - 0x02 if self.height == 32 or self.height == 16 else 0x12, + 0x02 if (self.height == 32 or self.height == 16) and (self.width != 64) else 0x12, # timing and driving scheme SET_DISP_CLK_DIV, 0x80, From dd1da50420132469d2127ea10a50d6dea8bc47d7 Mon Sep 17 00:00:00 2001 From: Adam Candy Date: Thu, 3 Dec 2020 10:31:14 +0100 Subject: [PATCH 2/2] Acquiesce to black's very stict expectations --- adafruit_ssd1306.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adafruit_ssd1306.py b/adafruit_ssd1306.py index daceedb..0f8e705 100644 --- a/adafruit_ssd1306.py +++ b/adafruit_ssd1306.py @@ -113,7 +113,9 @@ def init_display(self): SET_DISP_OFFSET, 0x00, SET_COM_PIN_CFG, - 0x02 if (self.height == 32 or self.height == 16) and (self.width != 64) else 0x12, + 0x02 + if (self.height == 32 or self.height == 16) and (self.width != 64) + else 0x12, # timing and driving scheme SET_DISP_CLK_DIV, 0x80,