mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-03 14:37:46 +00:00
added DrawRGBBitmap8 (same as ili9341 & st7735)
This commit is contained in:
committed by
Ron Evans
parent
cba17ef125
commit
55e100c4fe
@@ -22,6 +22,10 @@ type Rotation uint8
|
||||
// FrameRate controls the frame rate used by the display.
|
||||
type FrameRate uint8
|
||||
|
||||
var (
|
||||
errOutOfBounds = errors.New("rectangle coordinates outside display area")
|
||||
)
|
||||
|
||||
// Device wraps an SPI connection.
|
||||
type Device struct {
|
||||
bus drivers.SPI
|
||||
@@ -279,6 +283,18 @@ func (d *Device) FillRectangle(x, y, width, height int16, c color.RGBA) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// DrawRGBBitmap8 copies an RGB bitmap to the internal buffer at given coordinates
|
||||
func (d *Device) DrawRGBBitmap8(x, y int16, data []uint8, w, h int16) error {
|
||||
k, i := d.Size()
|
||||
if x < 0 || y < 0 || w <= 0 || h <= 0 ||
|
||||
x >= k || (x+w) > k || y >= i || (y+h) > i {
|
||||
return errOutOfBounds
|
||||
}
|
||||
d.setWindow(x, y, w, h)
|
||||
d.Tx(data, false)
|
||||
return nil
|
||||
}
|
||||
|
||||
// FillRectangleWithBuffer fills buffer with a rectangle at a given coordinates.
|
||||
func (d *Device) FillRectangleWithBuffer(x, y, width, height int16, buffer []color.RGBA) error {
|
||||
i, j := d.Size()
|
||||
|
||||
Reference in New Issue
Block a user