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 Clear() Flush() PutText(x, y int, text string) PutBar(x0, y0, x1, y1, color int) FillBar(x0, y0, x1, y1, color int) } 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) Clear() { d.dev.LockImg() defer d.dev.UnlockImg() for i := range d.img.Pix { d.img.Pix[i] = 0 } } 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) }