FastLED 3.9.15
Loading...
Searching...
No Matches

◆ writePixels()

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, fl::u32 SPI_SPEED>
template<uint8_t FLAGS, class D, EOrder RGB_ORDER>
void AVRSoftwareSPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED >::writePixels ( PixelController< RGB_ORDER > pixels,
void * context = NULL )
inline

Write LED pixel data to the SPI interface.

Data is written in groups of three, re-ordered per the RGB_ORDER.

Template Parameters
FLAGSOption flags, such as FLAG_START_BIT
DPer-byte modifier class, e.g. DATA_NOP
RGB_ORDERthe rgb ordering for the LED data (e.g. what order red, green, and blue data is written out in)
Parameters
pixelsa PixelController with the LED data and modifier options

Definition at line 355 of file fastspi_bitbang.h.

355 {
357 select();
358 int len = pixels.mLen;
359
360#ifdef FAST_SPI_INTERRUPTS_WRITE_PINS
361 // If interrupts or other things may be generating output while we're working on things, then we need
362 // to use this block
363 while(pixels.has(1)) {
364 if(FLAGS & FLAG_START_BIT) {
365 writeBit<0>(1);
366 }
367 writeByte(D::adjust(pixels.loadAndScale0()));
368 writeByte(D::adjust(pixels.loadAndScale1()));
369 writeByte(D::adjust(pixels.loadAndScale2()));
370 pixels.advanceData();
371 pixels.stepDithering();
372 }
373#else
374 // If we can guaruntee that no one else will be writing data while we are running (namely, changing the values of the PORT/PDOR pins)
375 // then we can use a bunch of optimizations in here
377
380 // If data and clock are on different ports, then writing a bit will consist of writing the value foor
381 // the bit (hi or low) to the data pin port, and then two writes to the clock port to strobe the clock line
386
387 while(pixels.has(1)) {
388 if(FLAGS & FLAG_START_BIT) {
390 }
394 pixels.advanceData();
395 pixels.stepDithering();
396 }
397
398 } else {
399 // If data and clock are on the same port then we can combine setting the data and clock pins
404
405 while(pixels.has(1)) {
406 if(FLAGS & FLAG_START_BIT) {
408 }
412 pixels.advanceData();
413 pixels.stepDithering();
414 }
415 }
416#endif
418 release();
419 }
void select()
Select the SPI output (chip select)
static void writeByte(uint8_t b)
Write a single byte over SPI.
void release()
Release the SPI chip select line.
FastPin< CLOCK_PIN >::port_t clock_t
static void writeBit(uint8_t b)
Write the BIT'th bit out via SPI, setting the data pin then strobing the clock.
FastPin< DATA_PIN >::port_t data_t
FastPin< DATA_PIN >::port_ptr_t data_ptr_t
FastPin< CLOCK_PIN >::port_ptr_t clock_ptr_t
Software SPI (aka bit-banging) support Includes aggressive optimizations for when the clock and data ...
static port_t hival()
Gets the state of the port with this pin HIGH
Definition fastpin.h:339
static port_t loval()
Gets the state of the port with this pin LOW
Definition fastpin.h:341
static port_t mask()
Get the pin mask.
Definition fastpin.h:345
static port_ptr_t port()
Get the output state of the port.
Definition fastpin.h:343
#define FASTLED_UNUSED(x)
Definition unused.h:4

References PixelController< RGB_ORDER, LANES, MASK >::advanceData(), FASTLED_REGISTER, FASTLED_UNUSED, FLAG_START_BIT, PixelController< RGB_ORDER, LANES, MASK >::has(), FastPin< PIN >::hival(), PixelController< RGB_ORDER, LANES, MASK >::loadAndScale0(), PixelController< RGB_ORDER, LANES, MASK >::loadAndScale1(), PixelController< RGB_ORDER, LANES, MASK >::loadAndScale2(), FastPin< PIN >::loval(), FastPin< PIN >::mask(), PixelController< RGB_ORDER, LANES, MASK >::mLen, FastPin< PIN >::port(), release(), select(), PixelController< RGB_ORDER, LANES, MASK >::stepDithering(), writeBit(), and writeByte().

+ Here is the call graph for this function: