From c8e62562b5ecd740e793afe1edabe57c813b175b Mon Sep 17 00:00:00 2001 From: Daniel Esteban Date: Thu, 30 Jan 2020 08:55:48 +0100 Subject: [PATCH] added scroll functionality to st7735 --- st7735/registers.go | 2 ++ st7735/st7735.go | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/st7735/registers.go b/st7735/registers.go index 0fb01c7..dca9c60 100644 --- a/st7735/registers.go +++ b/st7735/registers.go @@ -46,6 +46,8 @@ const ( PWCTR6 = 0xFC GMCTRP1 = 0xE0 GMCTRN1 = 0xE1 + VSCRDEF = 0x33 + VSCRSADD = 0x37 GREENTAB Model = 0 MINI80x160 Model = 1 diff --git a/st7735/st7735.go b/st7735/st7735.go index 9c6bbec..5909d20 100644 --- a/st7735/st7735.go +++ b/st7735/st7735.go @@ -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()