7
7
"time"
8
8
9
9
"tinygo.org/x/drivers"
10
+ "tinygo.org/x/drivers/pixel"
10
11
)
11
12
12
13
type Config struct {
@@ -31,6 +32,9 @@ type Device struct {
31
32
rd machine.Pin
32
33
}
33
34
35
+ // Image buffer type used in the ili9341.
36
+ type Image = pixel.Image [pixel.RGB565BE ]
37
+
34
38
var cmdBuf [6 ]byte
35
39
36
40
var initCmd = []byte {
@@ -173,6 +177,8 @@ func (d *Device) EnableTEOutput(on bool) {
173
177
}
174
178
175
179
// DrawRGBBitmap copies an RGB bitmap to the internal buffer at given coordinates
180
+ //
181
+ // Deprecated: use DrawBitmap instead.
176
182
func (d * Device ) DrawRGBBitmap (x , y int16 , data []uint16 , w , h int16 ) error {
177
183
k , i := d .Size ()
178
184
if x < 0 || y < 0 || w <= 0 || h <= 0 ||
@@ -187,6 +193,8 @@ func (d *Device) DrawRGBBitmap(x, y int16, data []uint16, w, h int16) error {
187
193
}
188
194
189
195
// DrawRGBBitmap8 copies an RGB bitmap to the internal buffer at given coordinates
196
+ //
197
+ // Deprecated: use DrawBitmap instead.
190
198
func (d * Device ) DrawRGBBitmap8 (x , y int16 , data []uint8 , w , h int16 ) error {
191
199
k , i := d .Size ()
192
200
if x < 0 || y < 0 || w <= 0 || h <= 0 ||
@@ -200,6 +208,13 @@ func (d *Device) DrawRGBBitmap8(x, y int16, data []uint8, w, h int16) error {
200
208
return nil
201
209
}
202
210
211
+ // DrawBitmap copies the bitmap to the internal buffer on the screen at the
212
+ // given coordinates. It returns once the image data has been sent completely.
213
+ func (d * Device ) DrawBitmap (x , y int16 , bitmap Image ) error {
214
+ width , height := bitmap .Size ()
215
+ return d .DrawRGBBitmap8 (x , y , bitmap .RawBuffer (), int16 (width ), int16 (height ))
216
+ }
217
+
203
218
// FillRectangle fills a rectangle at given coordinates with a color
204
219
func (d * Device ) FillRectangle (x , y , width , height int16 , c color.RGBA ) error {
205
220
k , i := d .Size ()
0 commit comments