FastLED 3.10.8
Loading...
Searching...
No Matches
sm16716.h
Go to the documentation of this file.
1#pragma once
2
3#include "pixeltypes.h"
4#include "pixel_iterator.h"
5#include "crgb.h"
6#include "eorder.h"
7// IWYU pragma: begin_keep
8#include "platforms/shared/spi_pixel_writer.h" // ok platform headers
9// IWYU pragma: end_keep
10#include "platforms/spi_output_template.h"
11#include "fl/stl/noexcept.h"
12
14//
15// SM16716 definition - takes data/clock/select pin values (N.B. should take an SPI definition?)
16//
18
24template <int DATA_PIN, fl::u8 CLOCK_PIN, EOrder RGB_ORDER = RGB, fl::u32 SPI_SPEED = DATA_RATE_MHZ(16)>
25class SM16716Controller : public CPixelLEDController<RGB_ORDER> {
26 typedef fl::SPIOutput<DATA_PIN, CLOCK_PIN, SPI_SPEED> SPI;
28
30 // Write out 50 zeros to the spi line (6 blocks of 8 followed by two single bit writes)
31 mSPI.select();
32 mSPI.template writeBit<0>(0);
33 mSPI.writeByte(0);
34 mSPI.writeByte(0);
35 mSPI.writeByte(0);
36 mSPI.template writeBit<0>(0);
37 mSPI.writeByte(0);
38 mSPI.writeByte(0);
39 mSPI.writeByte(0);
40 // Note: endTransaction() may not be strictly necessary for SM16716
41 // since we're just streaming bytes. However, it's kept here for consistency
42 // with other SPI-based controllers and as defensive programming.
43 mSPI.endTransaction();
44 }
45
46public:
48 #if defined(FL_IS_ESP32)
50 mSPI.setBus(bus);
51 return *this;
52 }
53 #endif
54
55 virtual void init() FL_NO_EXCEPT {
56 mSPI.init();
57 }
58
59protected:
62 // Make sure the FLAG_START_BIT flag is set to ensure that an extra 1 bit is sent at the start
63 // of each triplet of bytes for rgb data
64 // writeHeader();
65 fl::writePixelsToSPI<FLAG_START_BIT, DATA_NOP, RGB_ORDER>(pixels, mSPI, nullptr);
67 }
68
69};
CPixelLEDController(RegistrationMode mode) FL_NO_EXCEPT
virtual void init() FL_NO_EXCEPT
Initialize the LED controller.
Definition sm16716.h:55
void writeHeader() FL_NO_EXCEPT
Definition sm16716.h:29
virtual void showPixels(PixelController< RGB_ORDER > &pixels) FL_NO_EXCEPT
Send the LED data to the strip.
Definition sm16716.h:61
fl::SPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED > SPI
Definition sm16716.h:26
SM16716Controller() FL_NO_EXCEPT
Definition sm16716.h:47
CLEDController & setSpiBus(Esp32SpiBus bus) FL_NO_EXCEPT
Select an ESP-IDF SPI host for this clocked controller before init().
fl::CLEDController CLEDController
Esp32SpiBus
ESP-IDF SPI host selection for an individual clocked LED controller.
Definition spi_bus.h:18
Includes defintions for RGB and HSV pixels.
#define FL_NO_EXCEPT
Pixel controller class.