added scroll functionality to st7735

This commit is contained in:
Daniel Esteban
2020-01-30 08:55:48 +01:00
committed by Ron Evans
parent 6842bdb424
commit c8e62562b5
2 changed files with 23 additions and 0 deletions
+2
View File
@@ -46,6 +46,8 @@ const (
PWCTR6 = 0xFC
GMCTRP1 = 0xE0
GMCTRN1 = 0xE1
VSCRDEF = 0x33
VSCRSADD = 0x37
GREENTAB Model = 0
MINI80x160 Model = 1
+21
View File
@@ -224,6 +224,27 @@ func (d *Device) setWindow(x, y, w, h int16) {
d.Command(RAMWR)
}
// SetScrollWindow sets an area to scroll with fixed top and bottom parts of the display
func (d *Device) SetScrollArea(topFixedArea, bottomFixedArea int16) {
d.Command(VSCRDEF)
d.Tx([]uint8{
uint8(topFixedArea >> 8), uint8(topFixedArea),
uint8(d.height - topFixedArea - bottomFixedArea>>8), uint8(d.height - topFixedArea - bottomFixedArea),
uint8(bottomFixedArea >> 8), uint8(bottomFixedArea)},
false)
}
// SetScroll sets the vertical scroll address of the display.
func (d *Device) SetScroll(line int16) {
d.Command(VSCRSADD)
d.Tx([]uint8{uint8(line >> 8), uint8(line)}, false)
}
// SpotScroll returns the display to its normal state
func (d *Device) StopScroll() {
d.Command(NORON)
}
// FillRectangle fills a rectangle at a given coordinates with a color
func (d *Device) FillRectangle(x, y, width, height int16, c color.RGBA) error {
k, i := d.Size()