Skip to content

Commit 0ed9683

Browse files
deadprogramconejoninja
authored andcommitted
st7789: add scrolling functions to match st7735
Signed-off-by: deadprogram <[email protected]>
1 parent 01acd97 commit 0ed9683

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

st7789/registers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ const (
5050
GMCTRP1 = 0xE0
5151
GMCTRN1 = 0xE1
5252
GSCAN = 0x45
53+
VSCRDEF = 0x33
54+
VSCRSADD = 0x37
5355

5456
NO_ROTATION Rotation = 0
5557
ROTATION_90 Rotation = 1 // 90 degrees clock-wise rotation

st7789/st7789.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,27 @@ func (d *Device) IsBGR(bgr bool) {
435435
d.isBGR = bgr
436436
}
437437

438+
// SetScrollWindow sets an area to scroll with fixed top and bottom parts of the display
439+
func (d *Device) SetScrollArea(topFixedArea, bottomFixedArea int16) {
440+
d.Command(VSCRDEF)
441+
d.Tx([]uint8{
442+
uint8(topFixedArea >> 8), uint8(topFixedArea),
443+
uint8(d.height - topFixedArea - bottomFixedArea>>8), uint8(d.height - topFixedArea - bottomFixedArea),
444+
uint8(bottomFixedArea >> 8), uint8(bottomFixedArea)},
445+
false)
446+
}
447+
448+
// SetScroll sets the vertical scroll address of the display.
449+
func (d *Device) SetScroll(line int16) {
450+
d.Command(VSCRSADD)
451+
d.Tx([]uint8{uint8(line >> 8), uint8(line)}, false)
452+
}
453+
454+
// SpotScroll returns the display to its normal state
455+
func (d *Device) StopScroll() {
456+
d.Command(NORON)
457+
}
458+
438459
// RGBATo565 converts a color.RGBA to uint16 used in the display
439460
func RGBATo565(c color.RGBA) uint16 {
440461
r, g, b, _ := c.RGBA()

0 commit comments

Comments
 (0)