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-08-21 16:07:29 +00:00
|
|
|
Flush(img *image.Gray) error
|
|
|
|
GetBounds() image.Rectangle
|
2024-08-20 12:14:10 +00:00
|
|
|
|
2024-09-11 15:55:26 +00:00
|
|
|
Test(ctx context.Context) error
|
|
|
|
|
2024-08-20 12:14:10 +00:00
|
|
|
io.Closer
|
|
|
|
}
|
|
|
|
|
|
|
|
type DisplayModel int
|
|
|
|
|
|
|
|
const (
|
|
|
|
SSD1306 DisplayModel = iota
|
2024-08-21 16:07:29 +00:00
|
|
|
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)
|
2024-08-21 16:07:29 +00:00
|
|
|
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")
|
|
|
|
}
|