display-test/display/display.go

48 lines
776 B
Go
Raw Normal View History

2024-08-20 12:14:10 +00:00
package display
import (
2024-09-11 15:55:26 +00:00
"context"
2024-08-20 12:14:10 +00:00
"fmt"
"image"
"io"
"log"
)
type Display interface {
2024-09-22 18:53:22 +00:00
IsReady() error // Nil if it is ready, error with some info otherwise
2024-09-18 19:32:47 +00:00
Flush(crystal, page byte)
2024-09-22 18:53:22 +00:00
FlushByMask(mask uint32)
GetFlushMaskBit(crystal, page byte) uint32
2024-09-18 19:32:47 +00:00
// Image functions
GetImg() *image.Gray
LockImg()
UnlockImg()
GetBounds() image.Rectangle
2024-08-20 12:14:10 +00:00
2024-09-22 18:53:22 +00:00
Test(ctx context.Context) error // DEBUG ONLY
2024-09-11 15:55:26 +00:00
2024-08-20 12:14:10 +00:00
io.Closer
}
type DisplayModel int
const (
SSD1306 DisplayModel = iota
MT12864A
2024-09-04 18:05:02 +00:00
MT12232A
2024-08-20 12:14:10 +00:00
)
func New(logger *log.Logger, model DisplayModel) (Display, error) {
switch model {
case SSD1306:
return newSsd1306(logger)
case MT12864A:
return newMt12864a(logger)
2024-09-04 18:05:02 +00:00
case MT12232A:
return newMt12232a(logger)
2024-08-20 12:14:10 +00:00
}
return nil, fmt.Errorf("invalid display model")
}