Displays with driver subclassed from framebuf
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
I2C commands
@dhylands Have you seen PR4020? This addresses the issue of efficiently prepending a command to a buffer such that an I2C stop does not occur between command and data.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Seeking display with driver subclassed from framebuf
The second problem is self-inflicted and can be easily solved by adding a bit of C code to the framebuf module that will send the data efficiently. There is absolutely no technical reason why all the data needs to be in a single continuous buffer in memory, it's just a weirdness of the python api.
Re: I2C commands
This is another workaround that only solves the visible problem, but doesn't even try to get into the actual issue. It still forces you to use the same representation internally in the framebuf as the display you are driving, making it necessary to have a zillion kinds of framebufs, each with its own optimized graphical functions and its own bugs. Instead, there should be a single framebuf format for each color resolution, and the conversion to the format appropriate for a particular display should be done on the fly by the function that sends the data to the display. This way you only need to deal with different modes in one place.pythoncoder wrote: ↑Tue Aug 14, 2018 7:00 am@dhylands Have you seen PR4020? This addresses the issue of efficiently prepending a command to a buffer such that an I2C stop does not occur between command and data.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: I2C commands
I take your point. But if the only supported device is the SSD1306 we're a long way from a zillion
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Seeking display with driver subclassed from framebuf
Last time I checked we had at least 4 different monochrome modes in there.
Re: Seeking display with driver subclassed from framebuf
It's actually missing MVMSB - I guess no one has needed it yet.
1-bit: MVLSB, MHLSB, MHMSB
2-bit : GS2_HMSB
4-bit: GS4_HMSB
8-bit: GS8
16-bit: RGB565
1-bit: MVLSB, MHLSB, MHMSB
2-bit : GS2_HMSB
4-bit: GS4_HMSB
8-bit: GS8
16-bit: RGB565
Re: Seeking display with driver subclassed from framebuf
i played around some time ago with the limifrog oled display which worked wellThe framebuf class is able to work with multiple colours and the official SSD1306 driver is subclassed from framebuf. Are any colour displays available with drivers written in this way?
viewtopic.php?t=2736
Re: Seeking display with driver subclassed from framebuf
I updated my Nokia 5110 / PCD8544 driver with examples of both inheriting and extending the Framebuffer.
Inheriting / subclassed
https://github.com/mcauser/micropython- ... inherit.py
https://github.com/mcauser/micropython- ... 8544_fb.py
Extending / wrapper
https://github.com/mcauser/micropython- ... _extend.py
https://github.com/mcauser/micropython- ... pcd8544.py
Inheriting / subclassed
https://github.com/mcauser/micropython- ... inherit.py
https://github.com/mcauser/micropython- ... 8544_fb.py
Extending / wrapper
https://github.com/mcauser/micropython- ... _extend.py
https://github.com/mcauser/micropython- ... pcd8544.py
Re: Seeking display with driver subclassed from framebuf
I am using 16bit color framebuf class in my bare metal Raspberry Pi port.pythoncoder wrote: ↑Mon Aug 13, 2018 9:49 amThe framebuf class is able to work with multiple colours and the official SSD1306 driver is subclassed from framebuf. Are any colour displays available with drivers written in this way?
demo: https://youtu.be/aUXRWUTasrY?t=1m
Since the Pi's GPU and CPU both can access to the same RAM area, all the changes CPU made to the frame buffer will be shown on the display immediately.
Raspberry Pi screen class:
Code: Select all
import gpu
import framebuf
class RPiScreen(framebuf.FrameBuffer):
def __init__(self, width, height):
self.width = width
self.height = height
gpu.fb_init(width,height,screen_w=1920,screen_h=1080)
super().__init__(gpu.fb_data(),width,height,framebuf.RGB565)
self
The data structure of GPU frame buffer is exactly same as the one framebuf class uses, so all methods of framebuf class can be used.
A simple text console using framebuf class: https://github.com/boochow/micropython- ... Console.py
the code to show REPL on the Pi's screen using dupterm() and above classes:
Code: Select all
def set_fb_console(on=True):
global theScreen
from FBConsole import FBConsole, RPiScreen
import os
if on:
theScreen = FBConsole(RPiScreen(480,270))
os.dupterm(theScreen)
else:
theScreen = os.dupterm(None)
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Now solved
Trying your baremetal Raspberry Pi port is on my (long) todo list.
In the absence of colour display drivers based on Framebuf I've written one, for this display. The chip supports an 8-bit colour mode so the frame buffer is 6144 bytes which is manageable on a Pyboard. You wouldn't want to display pictures in 8-bit colour but for information displays it's OK.
It demonstrates the simplicity of basing a display class on framebuf.FrameBuffer: the driver comprises a mere 52 lines of code yet supports the graphics primitives and (via my writer module) text rendering in arbitrary fonts. All in glorious (well, 8-bit) Technicolor.
I'll post some code soon.
In the absence of colour display drivers based on Framebuf I've written one, for this display. The chip supports an 8-bit colour mode so the frame buffer is 6144 bytes which is manageable on a Pyboard. You wouldn't want to display pictures in 8-bit colour but for information displays it's OK.
It demonstrates the simplicity of basing a display class on framebuf.FrameBuffer: the driver comprises a mere 52 lines of code yet supports the graphics primitives and (via my writer module) text rendering in arbitrary fonts. All in glorious (well, 8-bit) Technicolor.
I'll post some code soon.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.