From 2eaf846134f0ed45331775876e91e619b916f533 Mon Sep 17 00:00:00 2001 From: Glen McGillan Date: Mon, 31 Jul 2017 12:50:57 -0700 Subject: [PATCH] Spi pattern fix (#502) * Add files via upload Calls to writePattern() don't send the desired number of bytes when the pattern size doesn't divide evenly into the hardware FIFO size (e.g. sending 18-bit RGB data, 11 patterns take 63 bytes, so 1/64th of the data is never sent). * Add files via upload Remove white space changes. --- libraries/SPI/src/SPI.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries/SPI/src/SPI.cpp b/libraries/SPI/src/SPI.cpp index a2371fde..e1e7a15c 100644 --- a/libraries/SPI/src/SPI.cpp +++ b/libraries/SPI/src/SPI.cpp @@ -242,11 +242,12 @@ void SPIClass::writePattern(uint8_t * data, uint8_t size, uint32_t repeat) uint32_t byte = (size * repeat); uint8_t r = (64 / size); + const uint8_t max_bytes_FIFO = r * size; // Max number of whole patterns (in bytes) that can fit into the hardware FIFO while(byte) { - if(byte > 64) { + if(byte > max_bytes_FIFO) { writePattern_(data, size, r); - byte -= 64; + byte -= max_bytes_FIFO; } else { writePattern_(data, size, (byte / size)); byte = 0;