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

◆ writePixels()

template<uint8_t DATA_PIN, uint8_t CLOCK_PIN, uint32_t 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 354 of file fastspi_bitbang.h.

354 {
356 select();
357 int len = pixels.mLen;
358
359#ifdef FAST_SPI_INTERRUPTS_WRITE_PINS
360 // If interrupts or other things may be generating output while we're working on things, then we need
361 // to use this block
362 while(pixels.has(1)) {
363 if(FLAGS & FLAG_START_BIT) {
364 writeBit<0>(1);
365 }
366 writeByte(D::adjust(pixels.loadAndScale0()));
367 writeByte(D::adjust(pixels.loadAndScale1()));
368 writeByte(D::adjust(pixels.loadAndScale2()));
369 pixels.advanceData();
370 pixels.stepDithering();
371 }
372#else
373 // 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)
374 // then we can use a bunch of optimizations in here
376
379 // If data and clock are on different ports, then writing a bit will consist of writing the value foor
380 // the bit (hi or low) to the data pin port, and then two writes to the clock port to strobe the clock line
385
386 while(pixels.has(1)) {
387 if(FLAGS & FLAG_START_BIT) {
389 }
393 pixels.advanceData();
394 pixels.stepDithering();
395 }
396
397 } else {
398 // If data and clock are on the same port then we can combine setting the data and clock pins
403
404 while(pixels.has(1)) {
405 if(FLAGS & FLAG_START_BIT) {
407 }
411 pixels.advanceData();
412 pixels.stepDithering();
413 }
414 }
415#endif
417 release();
418 }
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:262
static port_t loval()
Gets the state of the port with this pin LOW
Definition fastpin.h:264
static port_t mask()
Get the pin mask.
Definition fastpin.h:268
static port_ptr_t port()
Get the output state of the port.
Definition fastpin.h:266
#define FASTLED_UNUSED(x)
Definition unused.h:3

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: