48 lines
776 B
Go
48 lines
776 B
Go
package display
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"image"
|
|
"io"
|
|
"log"
|
|
)
|
|
|
|
type Display interface {
|
|
IsReady() error // Nil if it is ready, error with some info otherwise
|
|
|
|
Flush(crystal, page byte)
|
|
FlushByMask(mask uint32)
|
|
GetFlushMaskBit(crystal, page byte) uint32
|
|
|
|
// Image functions
|
|
GetImg() *image.Gray
|
|
LockImg()
|
|
UnlockImg()
|
|
GetBounds() image.Rectangle
|
|
|
|
Test(ctx context.Context) error // DEBUG ONLY
|
|
|
|
io.Closer
|
|
}
|
|
|
|
type DisplayModel int
|
|
|
|
const (
|
|
SSD1306 DisplayModel = iota
|
|
MT12864A
|
|
MT12232A
|
|
)
|
|
|
|
func New(logger *log.Logger, model DisplayModel) (Display, error) {
|
|
switch model {
|
|
case SSD1306:
|
|
return newSsd1306(logger)
|
|
case MT12864A:
|
|
return newMt12864a(logger)
|
|
case MT12232A:
|
|
return newMt12232a(logger)
|
|
}
|
|
return nil, fmt.Errorf("invalid display model")
|
|
}
|