mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-16 12:53:23 +00:00
st7789: add scrolling functions to match st7735
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -50,6 +50,8 @@ const (
|
|||||||
GMCTRP1 = 0xE0
|
GMCTRP1 = 0xE0
|
||||||
GMCTRN1 = 0xE1
|
GMCTRN1 = 0xE1
|
||||||
GSCAN = 0x45
|
GSCAN = 0x45
|
||||||
|
VSCRDEF = 0x33
|
||||||
|
VSCRSADD = 0x37
|
||||||
|
|
||||||
NO_ROTATION Rotation = 0
|
NO_ROTATION Rotation = 0
|
||||||
ROTATION_90 Rotation = 1 // 90 degrees clock-wise rotation
|
ROTATION_90 Rotation = 1 // 90 degrees clock-wise rotation
|
||||||
|
|||||||
@@ -435,6 +435,27 @@ func (d *Device) IsBGR(bgr bool) {
|
|||||||
d.isBGR = bgr
|
d.isBGR = bgr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
}
|
||||||
|
|
||||||
// RGBATo565 converts a color.RGBA to uint16 used in the display
|
// RGBATo565 converts a color.RGBA to uint16 used in the display
|
||||||
func RGBATo565(c color.RGBA) uint16 {
|
func RGBATo565(c color.RGBA) uint16 {
|
||||||
r, g, b, _ := c.RGBA()
|
r, g, b, _ := c.RGBA()
|
||||||
|
|||||||
Reference in New Issue
Block a user