mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-18 21:53:56 +00:00
ili9341: st7735: st7789: add DrawBitmap method
This adds a new DrawBitmap method, which is meant to replace DrawRGBBitmap8.
This commit is contained in:
committed by
Ron Evans
parent
100aadf585
commit
af33129f41
@@ -7,6 +7,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"tinygo.org/x/drivers"
|
"tinygo.org/x/drivers"
|
||||||
|
"tinygo.org/x/drivers/pixel"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@@ -31,6 +32,9 @@ type Device struct {
|
|||||||
rd machine.Pin
|
rd machine.Pin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Image buffer type used in the ili9341.
|
||||||
|
type Image = pixel.Image[pixel.RGB565BE]
|
||||||
|
|
||||||
var cmdBuf [6]byte
|
var cmdBuf [6]byte
|
||||||
|
|
||||||
var initCmd = []byte{
|
var initCmd = []byte{
|
||||||
@@ -173,6 +177,8 @@ func (d *Device) EnableTEOutput(on bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DrawRGBBitmap copies an RGB bitmap to the internal buffer at given coordinates
|
// DrawRGBBitmap copies an RGB bitmap to the internal buffer at given coordinates
|
||||||
|
//
|
||||||
|
// Deprecated: use DrawBitmap instead.
|
||||||
func (d *Device) DrawRGBBitmap(x, y int16, data []uint16, w, h int16) error {
|
func (d *Device) DrawRGBBitmap(x, y int16, data []uint16, w, h int16) error {
|
||||||
k, i := d.Size()
|
k, i := d.Size()
|
||||||
if x < 0 || y < 0 || w <= 0 || h <= 0 ||
|
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 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DrawRGBBitmap8 copies an RGB bitmap to the internal buffer at given coordinates
|
// DrawRGBBitmap8 copies an RGB bitmap to the internal buffer at given coordinates
|
||||||
|
//
|
||||||
|
// Deprecated: use DrawBitmap instead.
|
||||||
func (d *Device) DrawRGBBitmap8(x, y int16, data []uint8, w, h int16) error {
|
func (d *Device) DrawRGBBitmap8(x, y int16, data []uint8, w, h int16) error {
|
||||||
k, i := d.Size()
|
k, i := d.Size()
|
||||||
if x < 0 || y < 0 || w <= 0 || h <= 0 ||
|
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 {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DrawBitmap copies the bitmap to the internal buffer on the screen at the
|
||||||
|
// given coordinates. It returns once the image data has been sent completely.
|
||||||
|
func (d *Device) DrawBitmap(x, y int16, bitmap Image) error {
|
||||||
|
width, height := bitmap.Size()
|
||||||
|
return d.DrawRGBBitmap8(x, y, bitmap.RawBuffer(), int16(width), int16(height))
|
||||||
|
}
|
||||||
|
|
||||||
// FillRectangle fills a rectangle at given coordinates with a color
|
// FillRectangle fills a rectangle at given coordinates with a color
|
||||||
func (d *Device) FillRectangle(x, y, width, height int16, c color.RGBA) error {
|
func (d *Device) FillRectangle(x, y, width, height int16, c color.RGBA) error {
|
||||||
k, i := d.Size()
|
k, i := d.Size()
|
||||||
|
|||||||
@@ -305,6 +305,8 @@ func (d *DeviceOf[T]) FillRectangle(x, y, width, height int16, c color.RGBA) err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DrawRGBBitmap8 copies an RGB bitmap to the internal buffer at given coordinates
|
// DrawRGBBitmap8 copies an RGB bitmap to the internal buffer at given coordinates
|
||||||
|
//
|
||||||
|
// Deprecated: use DrawBitmap instead.
|
||||||
func (d *DeviceOf[T]) DrawRGBBitmap8(x, y int16, data []uint8, w, h int16) error {
|
func (d *DeviceOf[T]) DrawRGBBitmap8(x, y int16, data []uint8, w, h int16) error {
|
||||||
k, i := d.Size()
|
k, i := d.Size()
|
||||||
if x < 0 || y < 0 || w <= 0 || h <= 0 ||
|
if x < 0 || y < 0 || w <= 0 || h <= 0 ||
|
||||||
@@ -316,6 +318,13 @@ func (d *DeviceOf[T]) DrawRGBBitmap8(x, y int16, data []uint8, w, h int16) error
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DrawBitmap copies the bitmap to the internal buffer on the screen at the
|
||||||
|
// given coordinates. It returns once the image data has been sent completely.
|
||||||
|
func (d *DeviceOf[T]) DrawBitmap(x, y int16, bitmap pixel.Image[T]) error {
|
||||||
|
width, height := bitmap.Size()
|
||||||
|
return d.DrawRGBBitmap8(x, y, bitmap.RawBuffer(), int16(width), int16(height))
|
||||||
|
}
|
||||||
|
|
||||||
// FillRectangle fills a rectangle at a given coordinates with a buffer
|
// FillRectangle fills a rectangle at a given coordinates with a buffer
|
||||||
func (d *DeviceOf[T]) FillRectangleWithBuffer(x, y, width, height int16, buffer []color.RGBA) error {
|
func (d *DeviceOf[T]) FillRectangleWithBuffer(x, y, width, height int16, buffer []color.RGBA) error {
|
||||||
k, l := d.Size()
|
k, l := d.Size()
|
||||||
|
|||||||
@@ -382,6 +382,8 @@ func (d *DeviceOf[T]) fillRectangle(x, y, width, height int16, c color.RGBA) err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DrawRGBBitmap8 copies an RGB bitmap to the internal buffer at given coordinates
|
// DrawRGBBitmap8 copies an RGB bitmap to the internal buffer at given coordinates
|
||||||
|
//
|
||||||
|
// Deprecated: use DrawBitmap instead.
|
||||||
func (d *DeviceOf[T]) DrawRGBBitmap8(x, y int16, data []uint8, w, h int16) error {
|
func (d *DeviceOf[T]) DrawRGBBitmap8(x, y int16, data []uint8, w, h int16) error {
|
||||||
k, i := d.Size()
|
k, i := d.Size()
|
||||||
if x < 0 || y < 0 || w <= 0 || h <= 0 ||
|
if x < 0 || y < 0 || w <= 0 || h <= 0 ||
|
||||||
@@ -395,6 +397,13 @@ func (d *DeviceOf[T]) DrawRGBBitmap8(x, y int16, data []uint8, w, h int16) error
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DrawBitmap copies the bitmap to the internal buffer on the screen at the
|
||||||
|
// given coordinates. It returns once the image data has been sent completely.
|
||||||
|
func (d *DeviceOf[T]) DrawBitmap(x, y int16, bitmap pixel.Image[T]) error {
|
||||||
|
width, height := bitmap.Size()
|
||||||
|
return d.DrawRGBBitmap8(x, y, bitmap.RawBuffer(), int16(width), int16(height))
|
||||||
|
}
|
||||||
|
|
||||||
// FillRectangleWithBuffer fills buffer with a rectangle at a given coordinates.
|
// FillRectangleWithBuffer fills buffer with a rectangle at a given coordinates.
|
||||||
func (d *DeviceOf[T]) FillRectangleWithBuffer(x, y, width, height int16, buffer []color.RGBA) error {
|
func (d *DeviceOf[T]) FillRectangleWithBuffer(x, y, width, height int16, buffer []color.RGBA) error {
|
||||||
i, j := d.Size()
|
i, j := d.Size()
|
||||||
|
|||||||
Reference in New Issue
Block a user