FastLED 3.9.15
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
29 void writeHeader() {
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
49 virtual void init() {
50 mSPI.init();
51 }
52
53protected:
55 virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
56 // Make sure the FLAG_START_BIT flag is set to ensure that an extra 1 bit is sent at the start
57 // of each triplet of bytes for rgb data
58 // writeHeader();
59 fl::writePixelsToSPI<FLAG_START_BIT, DATA_NOP, RGB_ORDER>(pixels, mSPI, nullptr);
61 }
62
63};
CPixelLEDController(RegistrationMode mode)
virtual void init()
Initialize the LED controller.
Definition sm16716.h:49
virtual void showPixels(PixelController< RGB_ORDER > &pixels)
Send the LED data to the strip.
Definition sm16716.h:55
void writeHeader()
Definition sm16716.h:29
SM16716Controller() FL_NOEXCEPT
Definition sm16716.h:47
fl::SPIOutput< DATA_PIN, CLOCK_PIN, SPI_SPEED > SPI
Definition sm16716.h:26
Includes defintions for RGB and HSV pixels.
#define FL_NOEXCEPT
Pixel controller class.