Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSD1327: Adjust column addressing #244

Merged
merged 6 commits into from
Mar 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions luma/oled/device/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ def _supported_dimensions(self):
def _init_sequence(self):
self.command(
0xAE, # Display off (all pixels off)
0xA0, 0x53, # gment remap (com split, com remap, nibble remap, column remap)
0xA0, 0x53, # Segment remap (com split, com remap, nibble remap, column remap)
0xA1, 0x00, # Display start line
0xA2, 0x00, # Display offset
0xA4, # regular display
Expand All @@ -587,5 +587,5 @@ def _init_sequence(self):

def _set_position(self, top, right, bottom, left):
self.command(
0x15, left, right - 1, # set column addr
0x15, left >> 1, (right - 1) >> 1, # set column addr
0x75, top, bottom - 1) # set row addr
6 changes: 4 additions & 2 deletions luma/oled/device/greyscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ def _set_position(self, top, right, bottom, left):

def _render_mono(self, buf, pixel_data):
i = 0
nibble_order = self._nibble_order
for pix in pixel_data:
if pix > 0:
if i % 2 == self._nibble_order:
if i % 2 == nibble_order:
buf[i // 2] |= 0xF0
else:
buf[i // 2] |= 0x0F
Expand All @@ -78,12 +79,13 @@ def _render_mono(self, buf, pixel_data):

def _render_greyscale(self, buf, pixel_data):
i = 0
nibble_order = self._nibble_order
for r, g, b in pixel_data:
# RGB->Greyscale luma calculation into 4-bits
grey = (r * 306 + g * 601 + b * 117) >> 14

if grey > 0:
if i % 2 == self._nibble_order:
if i % 2 == nibble_order:
buf[i // 2] |= (grey << 4)
else:
buf[i // 2] |= grey
Expand Down
6 changes: 3 additions & 3 deletions tests/test_ssd1327.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_init_128x128():
call(184, 1, 17, 34, 50, 67, 84, 101, 118),
call(179, 0, 171, 1, 177, 241, 188, 8, 190, 7, 213, 98, 182, 15),
call(129, 127),
call(21, 0, 127, 117, 0, 127),
call(21, 0, 63, 117, 0, 127),
call(175)
])

Expand Down Expand Up @@ -69,7 +69,7 @@ def test_greyscale_display():
primitives(device, draw)

# Initial command to reset the display
serial.command.assert_called_once_with(21, 0, 127, 117, 0, 127)
serial.command.assert_called_once_with(21, 0, 63, 117, 0, 127)

# Next 4096 bytes are data representing the drawn image
serial.data.assert_called_once_with(get_json_data('demo_ssd1327_greyscale'))
Expand All @@ -87,7 +87,7 @@ def test_monochrome_display():
primitives(device, draw)

# Initial command to reset the display
serial.command.assert_called_once_with(21, 0, 127, 117, 0, 127)
serial.command.assert_called_once_with(21, 0, 63, 117, 0, 127)

# Next 4096 bytes are data representing the drawn image
serial.data.assert_called_once_with(get_json_data('demo_ssd1327_monochrome'))
Expand Down