display-test/display/display.go
2024-09-11 18:55:26 +03:00

39 lines
556 B
Go

package display
import (
"context"
"fmt"
"image"
"io"
"log"
)
type Display interface {
Flush(img *image.Gray) error
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")
}