guild icon
Toit
#Overview of how to implement a new EPaper Display?
Thread channel in help
Kris Jenkins
Kris Jenkins 09/14/2024 05:14 PM
After a long war, I've finally got Toit working with my M5CoreInk board (GDEW0154M09 display). :🥳:

I'm so close to getting a working display driver for this, but I clearly don't understand the EPaper API well enough yet. Can anyone answer these questions, please?

* I've written a class that implements initialize and draw-two-color. Will that be enough, or are there other methods I need to look at?
* What's the commit method for?
* For draw-two-color, what's the format of the pixels array? I was expecting it to just horizontally scan the region from top-left to bottom-right, but it doesn't seem to be that simple...
(edited)
floitsch
floitsch 09/16/2024 07:43 AM
Sorry. Didn't see the message earlier.
I will try to investigate a bit today.
(edited)
Kris Jenkins
Kris Jenkins 09/16/2024 08:44 AM
Thanks! :🙏:
floitsch
floitsch 09/16/2024 03:56 PM
Fundamentally, you need to implement the AbstractDriver from the pixel-display package:
abstract class AbstractDriver: abstract width -> int abstract height -> int abstract flags -> int x-rounding -> int: return 8 y-rounding -> int: return 8 start-partial-update speed/int -> none: start-full-update speed/int -> none: clean left/int top/int right/int bottom/int -> none: commit left/int top/int right/int bottom/int -> none: draw-two-color l/int t/int r/int b/int pixels/ByteArray -> none: throw "Not a two-color driver" draw-two-bit l/int t/int r/int b/int plane0/ByteArray plane1/ByteArray -> none: throw "Not a two-bit driver" draw-gray-scale l/int t/int r/int b/int pixels/ByteArray -> none: throw "Not a gray-scale driver" draw-several-color l/int t/int r/int b/int pixels/ByteArray -> none: throw "Not a several-color driver" draw-true-color l/int t/int r/int b/int red/ByteArray green/ByteArray blue/ByteArray -> none: throw "Not a true-color driver" close -> none:

As you can see, it has all methods implemented with empty stubs.

For a two-color display, it makes sense to override:
- width
- height
- flags
- draw-to-color
- commit
- clean ?
- start-full-update
- eventually: start-partial-update ...

The EPaper class has plenty of methods, but none override the EPaper methods. These are thus just there as utility methods to help you implement the actualy methods.

Looking at one of the implemented classes (like waveshare-2-color-7-5.toit) you can see that it implements:
- draw-to-color
- clean
- start-full-update
- commit
- it also supports partial updates, but you can ignore these for now.

It uses some additional help methods (send-to-device_, redraw-rect_ ...), but these are not required for the API.

The initialize isn't required either, but you probably want it, and initialize automatically in the constructor (like the Waveshare2Color154).
Kris Jenkins
Kris Jenkins 09/19/2024 10:24 AM
Thanks for the info! I am now achingly close to getting this working. :🫠:
floitsch
floitsch 09/19/2024 10:26 AM
Very cool!
6 messages in total