Skip to content

Commit f12454d

Browse files
committed
uc8151: add FillRectangle() and SetScroll() functions to satisfy tinyterm.Displayer interface
Signed-off-by: deadprogram <ron@hybridgroup.com>
1 parent 829ae09 commit f12454d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

uc8151/uc8151.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,3 +478,31 @@ func (d *Device) SetLUT(speed Speed, flickerFree bool) error {
478478

479479
return nil
480480
}
481+
482+
// FillRectangle fills a rectangle at a given coordinates with a color
483+
func (d *Device) FillRectangle(x, y, width, height int16, c color.RGBA) error {
484+
dw, dh := d.Size()
485+
486+
if x < 0 || y < 0 || width <= 0 || height <= 0 ||
487+
x >= d.width || (x+width) > dw || y >= dh || (y+height) > dh {
488+
return errOutOfRange
489+
}
490+
491+
if x+width == dw && y+height == dh && c.R == 0 && c.G == 0 && c.B == 0 {
492+
d.ClearDisplay()
493+
return nil
494+
}
495+
496+
for i := x; i < x+width; i++ {
497+
for j := y; j < y+height; j++ {
498+
d.SetPixel(i, j, c)
499+
}
500+
}
501+
502+
return nil
503+
}
504+
505+
// SetScroll sets the vertical scrolling for the display, which is a NOP for this display.
506+
func (d *Device) SetScroll(line int16) {
507+
return
508+
}

0 commit comments

Comments
 (0)