Skip to content

Commit a2013d6

Browse files
committed
ili9340: acceptPageAddressByte
1 parent 2bfd4b5 commit a2013d6

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

ili9340/ili9340.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ func (d *Display) acceptData(b byte) {
141141
d.acceptRamWrite(b)
142142
case stateColumnAddressSet:
143143
d.acceptColumnAddressByte(b)
144+
case statePageAddressSet:
145+
d.acceptPageAddressByte(b)
144146
}
145147
}
146148

@@ -167,10 +169,22 @@ func (d *Display) pixelWrite(p16 uint16) {
167169

168170
func (d *Display) acceptColumnAddressByte(b byte) {
169171
if d.paramIndex == 4 {
170-
data := d.paramData
171-
x0 := int(data >> 16)
172-
x1 := int(data & 0xFF)
173-
fmt.Printf("ILI9340: column address: x0:%d x1:%d\n", x0, x1)
174-
d.window = d.img.SubImage(image.Rect(x0, 0, x1, 240)).(*image.RGBA)
172+
x0 := int(d.paramData >> 16)
173+
x1 := int(d.paramData & 0xFFFF)
174+
d.window = d.img.SubImage(image.Rect(x0, d.window.Bounds().Min.Y, x1, d.window.Bounds().Max.Y)).(*image.RGBA)
175+
reportAddressWindow(d)
175176
}
176177
}
178+
179+
func (d *Display) acceptPageAddressByte(b byte) {
180+
if d.paramIndex == 4 {
181+
y0 := int(d.paramData >> 16)
182+
y1 := int(d.paramData & 0xFFFF)
183+
d.window = d.img.SubImage(image.Rect(d.window.Bounds().Min.X, y0, d.window.Bounds().Max.X, y1)).(*image.RGBA)
184+
reportAddressWindow(d)
185+
}
186+
}
187+
188+
func reportAddressWindow(d *Display) {
189+
fmt.Printf("ILI9340: address window: %v\n", d.window.Bounds())
190+
}

0 commit comments

Comments
 (0)