MCPcopy Create free account
hub / github.com/FastLED/FastLED / FL_TEST_FILE

Function FL_TEST_FILE

tests/platforms/esp/32/drivers/spi/channel_driver_spi.cpp:21–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19#include "platforms/esp/32/drivers/spi/channel_driver_spi.h"
20
21FL_TEST_FILE(FL_FILEPATH) {
22
23using namespace fl;
24
25namespace {
26
27/// @brief Create SPI channel data (APA102, SK9822, etc.)
28ChannelDataPtr createSpiChannelData(int dataPin = 5, int clockPin = 18) {
29 SpiEncoder encoder = SpiEncoder::apa102();
30 SpiChipsetConfig spiConfig{dataPin, clockPin, encoder};
31 fl::vector_psram<uint8_t> data = {0x00, 0xFF, 0xAA, 0x55};
32 return ChannelData::create(spiConfig, fl::move(data));
33}
34
35/// @brief Create clockless channel data (WS2812, SK6812, etc.)
36ChannelDataPtr createClocklessChannelData(int pin = 5) {
37 auto timing = makeTimingConfig<TIMING_WS2812_800KHZ>();
38 fl::vector_psram<uint8_t> data = {0xFF, 0x00, 0xAA};
39 return ChannelData::create(pin, timing, fl::move(data));
40}
41
42} // anonymous namespace
43
44FL_TEST_CASE("ChannelEngineSpi - canHandle accepts WS2812 (clockless)") {
45 ChannelEngineSpi driver;
46
47 auto data = createClocklessChannelData(5);
48 CHECK_TRUE(driver.canHandle(data));
49}
50
51FL_TEST_CASE("ChannelEngineSpi - canHandle accepts SK6812 (clockless)") {
52 ChannelEngineSpi driver;
53
54 auto timing = makeTimingConfig<TIMING_SK6812>();
55 fl::vector_psram<uint8_t> channelData = {0xFF, 0x00, 0xAA};
56 auto data = ChannelData::create(5, timing, fl::move(channelData));
57
58 CHECK_TRUE(driver.canHandle(data));
59}
60
61FL_TEST_CASE("ChannelEngineSpi - canHandle rejects APA102 (true SPI)") {
62 ChannelEngineSpi driver;
63
64 auto data = createSpiChannelData(5, 18);
65 FL_CHECK_FALSE(driver.canHandle(data));
66}
67
68FL_TEST_CASE("ChannelEngineSpi - canHandle rejects SK9822 (true SPI)") {
69 ChannelEngineSpi driver;
70
71 SpiEncoder encoder = SpiEncoder::sk9822();
72 SpiChipsetConfig spiConfig{5, 18, encoder};
73 fl::vector_psram<uint8_t> channelData = {0x00, 0xFF};
74 auto data = ChannelData::create(spiConfig, fl::move(channelData));
75
76 FL_CHECK_FALSE(driver.canHandle(data));
77}
78

Callers

nothing calls this directly

Calls 5

createFunction · 0.85
createSpiChannelDataFunction · 0.70
canHandleMethod · 0.45
isSpiMethod · 0.45

Tested by

no test coverage detected