From 3cbc405edf2448cf1d77b0a30a5e62ddab806a85 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Tue, 14 Feb 2017 11:58:04 +0200 Subject: [PATCH] Add helper for sending 16bit color buffers --- libraries/SPI/src/SPI.cpp | 20 ++++++++++++++------ libraries/SPI/src/SPI.h | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/libraries/SPI/src/SPI.cpp b/libraries/SPI/src/SPI.cpp index 84b2cb8b..a2371fde 100644 --- a/libraries/SPI/src/SPI.cpp +++ b/libraries/SPI/src/SPI.cpp @@ -189,9 +189,6 @@ void SPIClass::transferBits(uint32_t data, uint32_t * out, uint8_t bits) } /** - * Note: - * data need to be aligned to 32Bit - * or you get an Fatal exception (9) * @param data uint8_t * * @param size uint32_t */ @@ -205,6 +202,20 @@ void SPIClass::writeBytes(uint8_t * data, uint32_t size) spiEndTransaction(_spi); } +/** + * @param data void * + * @param size uint32_t + */ +void SPIClass::writePixels(const void * data, uint32_t size) +{ + if(_inTransaction){ + return spiWritePixelsNL(_spi, data, size); + } + spiSimpleTransaction(_spi); + spiWritePixelsNL(_spi, data, size); + spiEndTransaction(_spi); +} + /** * @param data uint8_t * data buffer. can be NULL for Read Only operation * @param out uint8_t * output buffer. can be NULL for Write Only operation @@ -219,9 +230,6 @@ void SPIClass::transferBytes(uint8_t * data, uint8_t * out, uint32_t size) } /** - * Note: - * data need to be aligned to 32Bit - * or you get an Fatal exception (9) * @param data uint8_t * * @param size uint8_t max for size is 64Byte * @param repeat uint32_t diff --git a/libraries/SPI/src/SPI.h b/libraries/SPI/src/SPI.h index ffa0bdf3..38dde76f 100644 --- a/libraries/SPI/src/SPI.h +++ b/libraries/SPI/src/SPI.h @@ -73,6 +73,7 @@ public: void write16(uint16_t data); void write32(uint32_t data); void writeBytes(uint8_t * data, uint32_t size); + void writePixels(const void * data, uint32_t size);//ili9341 compatible void writePattern(uint8_t * data, uint8_t size, uint32_t repeat); spi_t * bus(){ return _spi; }