Skip to content

Commit

Permalink
Merge pull request #133 from pimoroni/feature/uc8159-640x400
Browse files Browse the repository at this point in the history
Feature/uc8159 640x400
  • Loading branch information
Gadgetoid authored Dec 20, 2021
2 parents 8bf1f5a + 7211b54 commit ff7077f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 25 deletions.
2 changes: 2 additions & 0 deletions library/inky/auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def auto(i2c_bus=None, ask_user=False, verbose=False):
return InkyWHAT(_eeprom.get_color())
if _eeprom.display_variant == 14:
return InkyUC8159()
if _eeprom.display_variant == 15:
return InkyUC8159(resolution=(640, 400))

if ask_user:
if verbose:
Expand Down
3 changes: 2 additions & 1 deletion library/inky/eeprom.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
'Red pHAT (SSD1608)',
'Yellow pHAT (SSD1608)',
None,
'7-Colour (UC8159)'
'7-Colour (UC8159)',
'7-Colour 640x400 (UC8159)'
]


Expand Down
38 changes: 14 additions & 24 deletions library/inky/inky_uc8159.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@
_SPI_DATA = 1

_RESOLUTION = {
(600, 448): (600, 448, 0, 0, 0)
(600, 448): (600, 448, 0, 0, 0, 0b11),
(640, 400): (640, 400, 0, 0, 0, 0b10)
}


Expand Down Expand Up @@ -128,7 +129,7 @@ def __init__(self, resolution=(600, 448), colour='multi', cs_pin=CS0_PIN, dc_pin
self.resolution = resolution
self.width, self.height = resolution
self.border_colour = WHITE
self.cols, self.rows, self.rotation, self.offset_x, self.offset_y = _RESOLUTION[resolution]
self.cols, self.rows, self.rotation, self.offset_x, self.offset_y, self.resolution_setting = _RESOLUTION[resolution]

if colour not in ('multi'):
raise ValueError('Colour {} is not supported!'.format(colour))
Expand All @@ -137,26 +138,13 @@ def __init__(self, resolution=(600, 448), colour='multi', cs_pin=CS0_PIN, dc_pin
self.eeprom = eeprom.read_eeprom(i2c_bus=i2c_bus)
self.lut = colour

# The EEPROM is used to disambiguate the variants of wHAT and pHAT
# 1 Red pHAT (High-Temp)
# 2 Yellow wHAT (1_E)
# 3 Black wHAT (1_E)
# 4 Black pHAT (Normal)
# 5 Yellow pHAT (DEP0213YNS75AFICP)
# 6 Red wHAT (Regular)
# 7 Red wHAT (High-Temp)
# 8 Red wHAT (DEPG0420RWS19AF0HP)
# 10 BW pHAT (ssd1608) (DEPG0213BNS800F13CP)
# 11 Red pHAT (ssd1608)
# 12 Yellow pHAT (ssd1608)
# if self.eeprom is not None:
# # Only support new-style variants
# if self.eeprom.display_variant not in (10, 11, 12):
# raise RuntimeError('This driver is not compatible with your board.')
# if self.eeprom.width != self.width or self.eeprom.height != self.height:
# pass
# # TODO flash correct heights to new EEPROMs
# # raise ValueError('Supplied width/height do not match Inky: {}x{}'.format(self.eeprom.width, self.eeprom.height))
# Check for supported display variant and select the correct resolution
# Eg: 600x480 and 640x400
if self.eeprom is not None and self.eeprom.display_variant in (14, 15):
eeprom_resolution = _RESOLUTION.keys[self.eeprom.display_variant - 14]
self.resolution = eeprom_resolution
self.width, self.height = eeprom_resolution
self.cols, self.rows, self.rotation, self.offset_x, self.offset_y, self.resolution_setting = _RESOLUTION[eeprom_resolution]

self.buf = numpy.zeros((self.rows, self.cols), dtype=numpy.uint8)

Expand Down Expand Up @@ -241,11 +229,13 @@ def setup(self):
# 0b00000100 = Source shift direction, 0 = left, 1 = right (default)
# 0b00000010 = DC-DC converter, 0 = off, 1 = on
# 0b00000001 = Soft reset, 0 = Reset, 1 = Normal (Default)
# 0b11 = 600x448
# 0b10 = 640x400
self._send_command(
UC8159_PSR,
[
0b11101111, # See above for more magic numbers
0x08 # display_colours == UC8159_7C
(self.resolution_setting << 6) | 0b101111, # See above for more magic numbers
0x08 # display_colours == UC8159_7C
]
)

Expand Down

0 comments on commit ff7077f

Please sign in to comment.