Comments (5)
No idea but glad you got it working correctly. I haven't seen reports on SH1106 I2C having a wrong offset (lately).
from luma.oled.
I wonder if 72440da is related. Could you try the older 3.11.0 luma.oled and see if that changes things @blenherr ?
from luma.oled.
Successfully installed luma.core-2.4.0 luma.oled-3.11.0 pillow-10.0.0 pyftdi-0.54.0
Does not help, still 2 pixel offset.
from luma.oled.
I wonder if 72440da is related. Could you try the older 3.11.0 luma.oled and see if that changes things @blenherr ?
Is 72440da related to ssd1306 only?
I use sh1106:
class sh1106(device):
"""
Serial interface to a monochrome SH1106 OLED display.
On creation, an initialization sequence is pumped to the display
to properly configure it. Further control commands can then be called to
affect the brightness and other settings.
"""
def __init__(self, serial_interface=None, width=128, height=64, rotate=0, **kwargs):
super(sh1106, self).__init__(luma.oled.const.sh1106, serial_interface)
self.capabilities(width, height, rotate)
self._pages = self._h // 8
settings = {
(128, 128): dict(multiplex=0xFF, displayoffset=0x02),
(128, 64): dict(multiplex=0x3F, displayoffset=0x00),
(128, 32): dict(multiplex=0x20, displayoffset=0x0F)
}.get((width, height))
if settings is None:
raise luma.core.error.DeviceDisplayModeError(
f"Unsupported display mode: {width} x {height}")
self.command(
self._const.DISPLAYOFF,
self._const.MEMORYMODE,
self._const.SETHIGHCOLUMN, 0xB0, 0xC8,
self._const.SETLOWCOLUMN, 0x10, 0x40,
self._const.SETSEGMENTREMAP,
self._const.NORMALDISPLAY,
self._const.SETMULTIPLEX, settings['multiplex'],
self._const.DISPLAYALLON_RESUME,
self._const.SETDISPLAYOFFSET, settings['displayoffset'],
self._const.SETDISPLAYCLOCKDIV, 0xF0,
self._const.SETPRECHARGE, 0x22,
self._const.SETCOMPINS, 0x12,
self._const.SETVCOMDETECT, 0x20,
self._const.CHARGEPUMP, 0x14)
self.contrast(0x7F)
self.clear()
self.show()
def display(self, image):
"""
Takes a 1-bit :py:mod:`PIL.Image` and dumps it to the SH1106
OLED display.
:param image: Image to display.
:type image: :py:mod:`PIL.Image`
"""
assert image.mode == self.mode
assert image.size == self.size
image = self.preprocess(image)
set_page_address = 0xB0
image_data = image.getdata()
pixels_per_page = self.width * 8
buf = bytearray(self.width)
for y in range(0, int(self._pages * pixels_per_page), pixels_per_page):
self.command(set_page_address, 0x00, 0x10) # <----- HERE -----
set_page_address += 1
offsets = [y + self.width * i for i in range(8)]
for x in range(self.width):
buf[x] = \
(image_data[x + offsets[0]] and 0x01) | \
(image_data[x + offsets[1]] and 0x02) | \
(image_data[x + offsets[2]] and 0x04) | \
(image_data[x + offsets[3]] and 0x08) | \
(image_data[x + offsets[4]] and 0x10) | \
(image_data[x + offsets[5]] and 0x20) | \
(image_data[x + offsets[6]] and 0x40) | \
(image_data[x + offsets[7]] and 0x80)
self.data(list(buf))
from luma.oled.
My test script:
from time import sleep
from luma.core.interface.serial import i2c
from luma.core.render import canvas
from luma.oled.device import sh1106
# Display
PORT = 1
ADDRESS = 0x3C
WIDTH = 128
HEIGHT = 64
# Initialize device
serial = i2c(port=PORT, address=ADDRESS)
device = sh1106(serial, width=WIDTH, height=HEIGHT)
while True:
with canvas(device) as draw:
draw.rectangle(device.bounding_box, outline="white", fill="black")
draw.text((30, 26), "Hello World", fill="white")
sleep(0.01)
from luma.oled.
Related Issues (20)
- SSD1351 128x128 Color Issue HOT 3
- support for ssd1107/sh1107 HOT 9
- SSD1106 vs SH1106 HOT 2
- how to plot with this driver? HOT 1
- how do i change in code sh1106 driver , need location for code change ? HOT 2
- [question] access screens on remote Pi?
- Support for non-Raspberry Pi Linux boards HOT 1
- New Haven 2.7 oled with ssd1322 HOT 4
- ImportError: The _imagingft C module is not installed HOT 1
- White display SPI issue with 6.x kernels HOT 2
- Array is incorrectly shifted for 96x16 OLEDs. HOT 5
- Scrolling text within bounding box
- Input/output error for luma.oled HOT 6
- sys_info.py: error: I2C device not found on address: 0x3C.But i2c can detected on pi 4b arm64
- Low FPS on SSD1322 and Raspberry Pi 3B HOT 1
- Orange Pi zero2 error Timer expired HOT 2
- Hardware Accelerated 3D on the SSD1306
- from oled.device import ssd1306, sh1106 ModuleNotFoundError: No module named 'oled' HOT 7
- ImportError: cannot import name 'sh1107' from 'luma.oled.device' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from luma.oled.