34 lines
466 B
Go
34 lines
466 B
Go
|
package display
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"image"
|
||
|
"io"
|
||
|
"log"
|
||
|
|
||
|
"golang.org/x/image/font"
|
||
|
)
|
||
|
|
||
|
type Display interface {
|
||
|
GetImg() *image.Gray
|
||
|
GetFont() font.Face
|
||
|
Clear() error
|
||
|
PutText(x, y int, text string) error
|
||
|
|
||
|
io.Closer
|
||
|
}
|
||
|
|
||
|
type DisplayModel int
|
||
|
|
||
|
const (
|
||
|
SSD1306 DisplayModel = iota
|
||
|
)
|
||
|
|
||
|
func New(logger *log.Logger, model DisplayModel) (Display, error) {
|
||
|
switch model {
|
||
|
case SSD1306:
|
||
|
return newSsd1306(logger)
|
||
|
}
|
||
|
return nil, fmt.Errorf("invalid display model")
|
||
|
}
|