display-test/display/display.go

36 lines
511 B
Go
Raw Normal View History

2024-08-20 12:14:10 +00:00
package display
import (
"fmt"
"image"
"io"
"log"
)
type Display interface {
Flush(img *image.Gray) error
GetBounds() image.Rectangle
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")
}