package drawer import ( "image" "gitea.unprism.ru/yotia/display-test/display" ) type drawer struct { dev display.Display img *image.Gray } type Drawer interface { GetDisplay() display.Display W() int H() int Clear() Flush() PutText(x, y int, text string) PutBar(x0, y0, x1, y1 int, color byte) FillBar(x0, y0, x1, y1 int, color byte) } func New(dev display.Display) Drawer { d := &drawer{ dev: dev, } d.img = d.dev.GetImg() return d } func (d *drawer) GetDisplay() display.Display { return d.dev } func (d *drawer) W() int { return d.img.Rect.Dx() } func (d *drawer) H() int { return d.img.Rect.Dy() } func (d *drawer) Clear() { d.dev.LockImg() defer d.dev.UnlockImg() for i := range d.img.Pix { d.img.Pix[i] = 0 } d.dev.FlushByMask(0xFF) } func (d *drawer) Flush() { // Flush all pages d.dev.Flush(0, 0) d.dev.Flush(0, 1) d.dev.Flush(0, 2) d.dev.Flush(0, 3) d.dev.Flush(1, 0) d.dev.Flush(1, 1) d.dev.Flush(1, 2) d.dev.Flush(1, 3) }