Add: pages, text component

This commit is contained in:
Andrey Egorov
2024-09-29 21:09:59 +03:00
parent bad142a565
commit a4fda8303b
13 changed files with 504 additions and 84 deletions

View File

@ -55,6 +55,7 @@ func (d *drawer) Clear() {
for i := range d.img.Pix {
d.img.Pix[i] = 0
}
d.dev.FlushByMask(0xFF)
}
func (d *drawer) Flush() {

View File

@ -332,4 +332,23 @@ func (d *drawer) PutText(x0, y0 int, text string) {
d.putChar(x, y0, c)
x += CharGap + FontCharW
}
// Calculate update mask
mask := uint32(0)
// Implementation dependent !!!
// Now for mt12232
my0 := min(3, max(0, int((y0)/8)))
my1 := min(3, max(0, int((y0+FontCharH-1)/8)))
mx0 := min(1, max(0, int(x0/61)))
mx1 := min(1, max(0, int((x0+FontCharW*len(text)-1)/61)))
//log.Println(x0, y0, x1, y1)
for y := my0; y <= my1; y++ {
for x := mx0; x <= mx1; x++ {
mask |= (1 << (x*4 + y))
}
}
d.dev.FlushByMask(mask)
}