display-test/display/display.go
2024-09-18 22:32:47 +03:00

44 lines
620 B
Go

package display
import (
"context"
"fmt"
"image"
"io"
"log"
)
type Display interface {
Flush(crystal, page byte)
// Image functions
GetImg() *image.Gray
LockImg()
UnlockImg()
GetBounds() image.Rectangle
Test(ctx context.Context) error
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")
}