floitsch 09/16/2024 03:56 PMFundamentally, 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
).