165 lines
8.1 KiB
Go
165 lines
8.1 KiB
Go
package display
|
|
|
|
import (
|
|
"context"
|
|
"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)
|
|
}
|
|
|
|
if err := dev.PowerOn(); err != nil {
|
|
return nil, fmt.Errorf("power on: %w", err)
|
|
}
|
|
|
|
d := displayMt12864a{
|
|
logger: logger,
|
|
dev: dev,
|
|
}
|
|
|
|
// Temp debug draw
|
|
d.logger.Println("Draw...")
|
|
d.test()
|
|
d.logger.Println("Draw finished")
|
|
|
|
//return &d, nil
|
|
return nil, fmt.Errorf("IMPLEMENTATION COMMENTED")
|
|
}
|
|
|
|
func (d *displayMt12864a) Test(ctx context.Context) error {
|
|
return nil
|
|
}
|
|
|
|
func (d *displayMt12864a) test() {
|
|
//d.SetPixel(4, 10, true)
|
|
Logo128 := [][]byte{[]byte{0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFF,
|
|
}, []byte{0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xC0, 0xE0, 0xF0, 0xF0, 0xF0,
|
|
0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xC0, 0x80, 0x00,
|
|
0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80,
|
|
0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
|
|
0x80, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80,
|
|
0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00,
|
|
0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x80, 0x00,
|
|
0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x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0x00, 0x00, 0x80, 0xE0, 0xF8, 0xFE,
|
|
0xFF, 0xFF, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
|
|
}, []byte{0xFC, 0x01, 0x03, 0x04, 0x18, 0x20, 0x40, 0x81, 0x87, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
|
|
0x80, 0xE4, 0xE7, 0xFB, 0xFF, 0xFF, 0x7F, 0x3F, 0x0F, 0x03, 0x01, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
|
|
0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x07, 0x03, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
|
|
0x00, 0x70, 0xF8, 0xF8, 0xF0, 0xE0, 0xE0, 0xC0, 0xC0, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0,
|
|
0xE0, 0xF0, 0xFC, 0xFF, 0x7F, 0x3F, 0x0F, 0x81, 0xE0, 0xF8, 0xFC, 0xFF, 0xFF, 0x3F, 0x1F, 0x07,
|
|
0x01, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
|
|
}, []byte{0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x04, 0x04, 0x04, 0x0C,
|
|
0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x04, 0x04, 0x04, 0x02, 0x03, 0x01, 0x00,
|
|
0x00, 0x03, 0x07, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x07,
|
|
0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x07, 0x07, 0x03, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x03,
|
|
0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x07, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x03, 0x07, 0x07, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x03, 0x07, 0x07, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
|
|
}, []byte{0xFF, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
|
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
|
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
|
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
|
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
|
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
|
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
|
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xFF,
|
|
},
|
|
}
|
|
_ = Logo128
|
|
|
|
d.logger.Println("Write")
|
|
d.dev.WriteCodeL(0xB8)
|
|
d.dev.WriteCodeL(0x40)
|
|
d.dev.WriteDataL(47)
|
|
d.logger.Println("Read")
|
|
// d.dev.WriteCodeL(0xB8)
|
|
d.dev.WriteCodeL(0x40)
|
|
d.logger.Println(d.dev.ReadDataL())
|
|
d.logger.Println(d.dev.ReadDataL())
|
|
|
|
// for p := byte(0); p < 8; p++ {
|
|
// d.dev.WriteCodeL(p | 0xB8)
|
|
// d.dev.WriteCodeL(0x40)
|
|
// for c := 0; c < 64; c++ {
|
|
// d.dev.WriteDataL(Logo128[p][c])
|
|
// }
|
|
// d.dev.WriteCodeR(p | 0xB8)
|
|
// d.dev.WriteCodeR(0x40)
|
|
// for c := 64; c < 128; c++ {
|
|
// d.dev.WriteDataR(Logo128[p][c])
|
|
// }
|
|
// }
|
|
}
|
|
|
|
func (d *displayMt12864a) GetBounds() image.Rectangle {
|
|
return image.Rectangle{}
|
|
}
|
|
|
|
func (d *displayMt12864a) Flush(crystal, page byte) {
|
|
}
|
|
|
|
func (d *displayMt12864a) FlushByMask(mask uint32) {
|
|
}
|
|
|
|
func (d *displayMt12864a) Close() error {
|
|
return rpio.Close()
|
|
}
|
|
|
|
func (d *displayMt12864a) GetImg() *image.Gray {
|
|
return nil
|
|
}
|
|
func (d *displayMt12864a) LockImg() {
|
|
|
|
}
|
|
func (d *displayMt12864a) UnlockImg() {
|
|
|
|
}
|