drivers/display/ssd1306.py: Add support for 72x40 displays.
The 72x40 OLED requires selecting the internal IREF, as opposed to the default external IREF. This is an undocumented feature in the SSD1306 datasheet, but is present in the SSD1315 datasheet. It's possible the 72x40 OLED is actually using the newer SSD1315 controller. Sending the IREF select command to SSD1306 displays has no effect on them, so it's added to the init_display() instead of wrapping in an "if width = 72". Also tested on a 128x64 OLED using the SSD1315 controller (smaller ribbon cable) and the proposed change has no effect on the display, as the module comes with the correct current limiting resistor. Internal and external IREF work the same. Fixes issue #7281.
This commit is contained in:
parent
89945b1989
commit
bc7822d8e9
@ -15,6 +15,7 @@ SET_PAGE_ADDR = const(0x22)
|
|||||||
SET_DISP_START_LINE = const(0x40)
|
SET_DISP_START_LINE = const(0x40)
|
||||||
SET_SEG_REMAP = const(0xA0)
|
SET_SEG_REMAP = const(0xA0)
|
||||||
SET_MUX_RATIO = const(0xA8)
|
SET_MUX_RATIO = const(0xA8)
|
||||||
|
SET_IREF_SELECT = const(0xAD)
|
||||||
SET_COM_OUT_DIR = const(0xC0)
|
SET_COM_OUT_DIR = const(0xC0)
|
||||||
SET_DISP_OFFSET = const(0xD3)
|
SET_DISP_OFFSET = const(0xD3)
|
||||||
SET_COM_PIN_CFG = const(0xDA)
|
SET_COM_PIN_CFG = const(0xDA)
|
||||||
@ -63,6 +64,8 @@ class SSD1306(framebuf.FrameBuffer):
|
|||||||
0xFF, # maximum
|
0xFF, # maximum
|
||||||
SET_ENTIRE_ON, # output follows RAM contents
|
SET_ENTIRE_ON, # output follows RAM contents
|
||||||
SET_NORM_INV, # not inverted
|
SET_NORM_INV, # not inverted
|
||||||
|
SET_IREF_SELECT,
|
||||||
|
0x30, # enable internal IREF during display on
|
||||||
# charge pump
|
# charge pump
|
||||||
SET_CHARGE_PUMP,
|
SET_CHARGE_PUMP,
|
||||||
0x10 if self.external_vcc else 0x14,
|
0x10 if self.external_vcc else 0x14,
|
||||||
@ -92,10 +95,11 @@ class SSD1306(framebuf.FrameBuffer):
|
|||||||
def show(self):
|
def show(self):
|
||||||
x0 = 0
|
x0 = 0
|
||||||
x1 = self.width - 1
|
x1 = self.width - 1
|
||||||
if self.width == 64:
|
if self.width != 128:
|
||||||
# displays with width of 64 pixels are shifted by 32
|
# narrow displays use centred columns
|
||||||
x0 += 32
|
col_offset = (128 - self.width) // 2
|
||||||
x1 += 32
|
x0 += col_offset
|
||||||
|
x1 += col_offset
|
||||||
self.write_cmd(SET_COL_ADDR)
|
self.write_cmd(SET_COL_ADDR)
|
||||||
self.write_cmd(x0)
|
self.write_cmd(x0)
|
||||||
self.write_cmd(x1)
|
self.write_cmd(x1)
|
||||||
|
Loading…
Reference in New Issue
Block a user