package display

import (
	"fmt"
	"image"
	"log"

	"gitea.unprism.ru/yotia/display-test/pkg/mt12864a"
	"github.com/stianeikeland/go-rpio/v4"
)

type displayMt12864a struct {
	logger *log.Logger

	// GPIO pins
	dev mt12864a.Device
}

func newMt12864a(logger *log.Logger) (Display, error) {
	dev, err := mt12864a.New(log.New(logger.Writer(), "display-mt12864 : ", log.LstdFlags))
	if err != nil {
		return nil, fmt.Errorf("mt12864 create: %w", err)
	}

	dev.PowerOn()
	d := displayMt12864a{
		logger: logger,
		dev:    dev,
	}
	return &d, nil
}

func (d *displayMt12864a) GetBounds() image.Rectangle {
	return image.Rectangle{}
}

func (d *displayMt12864a) Flush(img *image.Gray) error {
	return nil
}

func (d *displayMt12864a) Close() error {
	return rpio.Close()
}