Comments (9)
I would try experimenting with the multiplex and displayoffset parameters.
For example like this:
settings = {
(64, 128): dict(multiplex=0x7F, displayoffset=0x60),
(80, 128): dict(multiplex=0x4F, displayoffset=0x68),
}.get((width, height))
I am based on this source: u8x8_d_sh1107.c
from luma.oled.
thanks @Pako2, that worked!
With rotate=0
(default):
With rotate=1
:
Would you be willing to make a pull request @Pako2? I can copy your code and make one as well, just let me know.
from luma.oled.
Would you be willing to make a pull request @Pako2? I can copy your code and make one as well, just let me know.
Hi. I am glad that my code works and that it can be used to complement such a great library. And I also prefer if I don't have to make another PR. Please do it yourself.
from luma.oled.
In the end, I did it for my own needs myself. If anyone is interested, here is my new class SH1107:
class sh1107(device):
"""
Serial interface to a monochrome SH1107 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=64, height=128, rotate=0, **kwargs):
super(sh1107, self).__init__(luma.oled.const.sh1107, serial_interface)
self.capabilities(width, height, rotate)
self._pages = self._h // 8
self._pagelen = self._w
settings = {
(64, 128): dict(multiplex=0x7F, displayoffset=0x60),
}.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.NORMALDISPLAY,
self._const.SETMULTIPLEX, settings['multiplex'],
self._const.DISPLAYALLON_RESUME,
self._const.SETDISPLAYOFFSET, settings['displayoffset'],
self._const.SETDISPLAYCLOCKDIV, 0x80,
self._const.SETPRECHARGE, 0x22,
self._const.SETCOMPINS, 0x12,
self._const.SETVCOMDETECT, 0x35,
)
self.contrast(0x7F)
self.clear()
self.show()
def display(self, image):
"""
Takes a 1-bit :py:mod:`PIL.Image` and dumps it to the SH1107
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)
pixmap = image.load()
buf = bytearray(self._pagelen)
for page in range(self._pages):
for x in range(self._pagelen):
tmp = 0
for y in range(8):
tmp |= (pixmap[x, y + 8 * page] & 1) << y
buf[x] = tmp
self.command(0x10, 0x00, 0xb0 | page)
self.data(buf)
There are probably other resolutions than 64x128. However, I only have this one and therefore this new class does not allow you to select any other resolution.
from luma.oled.
thanks for sharing @Pako2
@rm-hull is this something worth including in luma.oled?
from luma.oled.
I bought a 0.78 inch SH1107 OLED (80x128) display that I'll test with your code @Pako2 when I find some time. It's a different screen than you linked but we'll see if it works.
I'll first give it a try with Arduino using something like https://github.com/adafruit/Adafruit_SH110x
from luma.oled.
I tested the 0.78 inch SH1107 OLED (80x128) documented in the comment above with your code @Pako2 and adjusted it for 80x128 by adding:
settings = {
(64, 128): dict(multiplex=0x7F, displayoffset=0x60),
(80, 128): dict(multiplex=0x7F, displayoffset=0x60),
}.get((width, height))
I have no idea what the values for multiplex
or displayoffset
should be though..
And using the following code:
serial = i2c(port=1, address=0x3C)
device = sh1107(serial, width=80, height=128, rotate=0)
with canvas(device) as draw:
draw.rectangle(device.bounding_box, outline="white", fill="black")
draw.text((30, 40), "Hello World", fill="white")
sleep(40)
produces this image on the screen:
Adding rotate=1:
device = sh1107(serial, width=80, height=128, rotate=1)
produces this image:
Any idea how to get it to properly render?
from luma.oled.
nice work .. I was about to suggest trying tweaking the display offset 😁
from luma.oled.
Sounds good @Pako2, I've opened #359
from luma.oled.
Related Issues (20)
- [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
- Wrong column offset 1.54" SH1106 I2C HOT 6
- 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
- Incremental screen updates with Luma and SH1106? HOT 1
- Semi-random pixels on SSD1322 - how to fix? HOT 4
- RPi3B multiple SPI SSD1306 displays HOT 5
- Support to display latin characters HOT 1
- luma.oled - device on SPI fails with BOOKWORM HOT 2
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.