Skip to content

A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol

add LED support for 50 protocols

Geod3cb96057370
diff --git a/platformio.ini b/platformio.ini
index 544d4092..50a46950 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -68,6 +68,10 @@ build_flags =
-DIR_TX_PIN=44
-DIR_RX_PIN=1
+ ; --- LED ---
+ -DLED_DATA_PIN=1
+ -DLED_CLOCK_PIN=2
+
; --- I2S ---
-DI2S_BCLK_PIN=41
-DI2S_LRCK_PIN=43
@@ -127,6 +131,10 @@ build_flags =
-DIR_TX_PIN=19
-DIR_RX_PIN=33
+ ; --- LED ---
+ -DLED_DATA_PIN=25
+ -DLED_CLOCK_PIN=26
+
; --- TwoWire ---
-DTWOWIRE_CLK_PIN=26
-DTWOWIRE_IO_PIN=25
diff --git a/src/Controllers/InfraredController.cpp b/src/Controllers/InfraredController.cpp
index d1321a1e..7957cbea 100644
--- a/src/Controllers/InfraredController.cpp
+++ b/src/Controllers/InfraredController.cpp
@@ -202,6 +202,11 @@ void InfraredController::handleConfig() {
state.setInfraredRxPin(rxPin);
infraredService.configure(txPin, rxPin);
+ // Protocol
+ auto selectedProtocol = InfraredProtocolMapper::toString(state.getInfraredProtocol());
+ terminalView.println("Current protocol: '" + selectedProtocol + "'");
+ terminalView.println("You can change it with 'setprotocol'");
+
terminalView.println("Infrared configured.\n");
}
diff --git a/src/Controllers/LedController.cpp b/src/Controllers/LedController.cpp
index fd2b0851..2da8b73c 100644
--- a/src/Controllers/LedController.cpp
+++ b/src/Controllers/LedController.cpp
@@ -1,45 +1,362 @@
#include "LedController.h"
+#include <sstream>
+#include <algorithm>
/*
Constructor
*/
-LedController::LedController(ITerminalView& terminalView, IInput& terminalInput, LedService& ledService)
- : terminalView(terminalView), terminalInput(terminalInput), ledService(ledService) {}
+LedController::LedController(ITerminalView& terminalView, IInput& terminalInput,
+ LedService& ledService, ArgTransformer& argTransformer,
+ UserInputManager& userInputManager)
+ : terminalView(terminalView), terminalInput(terminalInput),
+ ledService(ledService), argTransformer(argTransformer), userInputManager(userInputManager) {}
/*
-Entry point for command
+Command
*/
void LedController::handleCommand(const TerminalCommand& cmd) {
- if (cmd.getRoot() == "PlaceHolder") {
- // Nothing
+ if (cmd.getRoot() == "fill") {
+ handleFill(cmd);
+ } else if (cmd.getRoot() == "scan") {
+ handleScan();
+ } else if (cmd.getRoot() == "set") {
+ handleSet(cmd);
+ } else if (cmd.getRoot() == "reset") {
+ handleReset(cmd);
+ } else if (cmd.getRoot() == "blink") {
+ handleAnimation(cmd);
+ } else if (cmd.getRoot() == "rainbow") {
+ handleAnimation(cmd);
+ } else if (cmd.getRoot() == "chase") {
+ handleAnimation(cmd);
+ } else if (cmd.getRoot() == "cycle") {
+ handleAnimation(cmd);
+ } else if (cmd.getRoot() == "wave") {
+ handleAnimation(cmd);
+ } else if (cmd.getRoot() == "config") {
+ handleConfig();
+ } else if (cmd.getRoot() == "setprotocol") {
+ handleSetProtocol();
+ } else {
+ handleHelp();
+ }
+}
+
+/*
+Instructions
+*/
+void LedController::handleInstruction(const std::vector<ByteCode>& bytecodes) {
+ terminalView.println("[ERROR] LED instructions not implemented.");
+}
+
+/*
+Scan
+*/
+void LedController::handleScan() {
+ terminalView.println("\n [INFO] LED protocol scan.");
+ terminalView.println(" A short 'chase' animation will be played for each protocol.");
+ terminalView.println(" Watch the LEDs: they should light up one by one in blue,");
+ terminalView.println(" then turn off in sequence. If it looks correct, press [ENTER].");
+ terminalView.println(" Otherwise, wait 3 seconds and it will try the next protocol.\n");
+
+ terminalView.println("Which type of LED are you scanning?");
+ terminalView.println(" 1. Single-wire (DATA only)");
+ terminalView.println(" 2. Clocked (DATA + CLOCK)\n");
+
+ // Ask for LED type
+ uint8_t typeChoice = 0;
+ while (true) {
+ typeChoice = userInputManager.readValidatedUint8("Choice", 1);
+ if (typeChoice == 1 || typeChoice == 2) break;
+ terminalView.println("Invalid choice. Enter 1 or 2.");
}
- else {
- terminalView.println("");
- terminalView.println("Unknown LED command. Usage:");
- terminalView.println(" ???");
- terminalView.println("");
+ // Define scanned protocol
+ std::vector<std::string> protocols = (typeChoice == 1)
+ ? LedService::getSingleWireProtocols()
+ : LedService::getSpiChipsets();
+
+ // Get saved pins and leds count
+ uint8_t dataPin = state.getLedDataPin();
+ uint8_t clockPin = state.getLedClockPin();
+ uint16_t length = state.getLedLength();
+ uint8_t brightness = state.getLedBrightness();
+
+ // Run chase animation for each protocol until ENTER is pressed
+ for (const auto& proto : protocols) {
+ terminalView.println("Trying protocol: " + proto);
+ ledService.configure(dataPin, clockPin, length, proto, brightness);
+ ledService.reset();
+
+ terminalView.println(">>> PRESS [ENTER] if the LEDs chase in blue (auto-skip in 3s)...");
+
+ // Show the animation for 3 sec or until ENTER is press
+ unsigned long start = millis();
+ while (millis() - start < 3000) {
+ char key = terminalInput.readChar();
+ // Found, save the protocol
+ if (key == '\r' || key == '\n') {
+ terminalView.print("\nLED: Protocol found: " + proto);
+ terminalView.println(". Successfully saved to configuration.");
+ state.setLedProtocol(proto);
+ return;
+ }
+ ledService.runAnimation("chase");
+ }
+
}
+ terminalView.println("\nLED: No protocol matched.");
}
/*
-Entry point for instruction
+Fill
*/
-void LedController::handleInstruction(const std::vector<ByteCode>& bytecodes) {
- terminalView.println("Instruction handling not yet implemented");
+void LedController::handleFill(const TerminalCommand& cmd) {
+ std::vector<std::string> args = argTransformer.splitArgs(cmd.getArgs());
+
+ // fill <r> <g> <b>
+ if (!args.empty() &&
+ argTransformer.isValidNumber(cmd.getSubcommand()) &&
+ args.size() >= 2 &&
+ argTransformer.isValidNumber(args[0]) &&
+ argTransformer.isValidNumber(args[1])) {
+
+ std::vector<std::string> full = {cmd.getSubcommand(), args[0], args[1]};
+ CRGB rgb = parseFlexibleColor(full);
+ ledService.fill(rgb);
+ return;
+ }
+
+ // fill <hex|name>
+ std::vector<std::string> colorArg = {cmd.getSubcommand()};
+ CRGB rgb = parseFlexibleColor(colorArg);
+ ledService.fill(rgb);
+}
+
+/*
+Set
+*/
+void LedController::handleSet(const TerminalCommand& cmd) {
+ auto args = argTransformer.splitArgs(cmd.getArgs());
+
+ if (args.empty()) {
+ terminalView.println("Usage: set <index> <hex RGB color | r g b | name>");
+ return;
+ }
+
+ if (!argTransformer.isValidNumber(cmd.getSubcommand())) {
+ terminalView.println("Error: Invalid index format.");
+ return;
+ }
+
+ uint16_t index = argTransformer.parseHexOrDec(cmd.getSubcommand());
+ CRGB rgb = parseFlexibleColor(args);
+
+ ledService.set(index, rgb);
+}
+
+/*
+Reset
+*/
+void LedController::handleReset(const TerminalCommand& cmd) {
+
+ if (cmd.getSubcommand().empty()) {
+ ledService.reset();
+ terminalView.println("LED: Reset all LEDs to default.");
+ return;
+ }
+
+ if (!argTransformer.isValidNumber(cmd.getSubcommand())) {
+ terminalView.println("LED: Invalid syntax. Use:");
+ terminalView.println(" reset");
+ terminalView.println(" reset <led num>");
+ return;
+ }
+
+ uint16_t index = argTransformer.parseHexOrDec(cmd.getSubcommand());
+ ledService.set(index, CRGB::Black);
+ terminalView.println("LED: Reset LED " + std::to_string(index));
}
/*
Config
*/
void LedController::handleConfig() {
- terminalView.println(" [INFO] This mode is not implemented yet.");
- terminalView.println(" Support is planned for a future release.\n");
+ terminalView.println("\nLED Configuration:");
+
+ // Get default
+ const auto& forbidden = state.getProtectedPins();
+ uint8_t defaultDataPin = state.getLedDataPin();
+ uint8_t defaultClockPin = state.getLedClockPin();
+ uint16_t defaultLength = state.getLedLength();
+
+ // LEDs pins, locked because FastLED needs them at compile time
+ uint8_t userDataPin = userInputManager.readValidatedPinNumber("Data pin", defaultDataPin, forbidden);
+ uint8_t userClockPin = userInputManager.readValidatedPinNumber("Clock pin", defaultClockPin, forbidden);
+ if (userDataPin != defaultDataPin) {
+ terminalView.println("[WARNING] Data pin cannot be changed. Data pin set to : " + std::to_string(defaultDataPin));
+ }
+ if (userClockPin != defaultClockPin) {
+ terminalView.println("[WARNING] Clock pin cannot be changed. Clock pin set to: " + std::to_string(defaultClockPin));
+ }
+
+ // LEDs count
+ uint16_t length = userInputManager.readValidatedUint32("Number of LEDs", defaultLength);
+
+ // LED Brightness
+ uint8_t defaultBrightness = state.getLedBrightness();
+ uint8_t brightness = userInputManager.readValidatedUint8("Brightness (0–255)", defaultBrightness);
+
+ // LED Protocol
+ auto selectedProtocol = state.getLedProtocol();
+ terminalView.println("Current protocol: '" + selectedProtocol + "'");
+ terminalView.println("You can change it with 'setprotocol'");
+ terminalView.println("or try to detect it automatically with 'scan'");
+
+ // Configure
+ ledService.configure(defaultDataPin, defaultClockPin, length, selectedProtocol, brightness);
+ terminalView.println("LEDs configured.\n");
+
+ // Update state
+ state.setLedLength(length);
+ state.setLedBrightness(brightness);
+ state.setLedProtocol(selectedProtocol);
+}
+
+/*
+Animation
+*/
+void LedController::handleAnimation(const TerminalCommand& cmd) {
+ const auto& validTypes = ledService.getSupportedAnimations();
+
+ // Check correct anim type
+ const std::string& type = cmd.getRoot();
+ if (std::find(validTypes.begin(), validTypes.end(), type) == validTypes.end()) {
+ terminalView.println("LED: Unknown animation type: " + type);
+ return;
+ }
+
+ // Run anim until user ENTER press
+ terminalView.println("LED: Playing animation: " + type + "... Press [ENTER] to stop.");
+ while (true) {
+ char key = terminalInput.readChar();
+ if (key == '\r' || key == '\n') {
+ terminalView.println("\nLED: Animation stopped.");
+ break;
+ }
+
+ ledService.runAnimation(type);
+ }
+}
+
+/*
+Set Protocol
+*/
+void LedController::handleSetProtocol() {
+ terminalView.println("\nSet LED Protocol:");
+
+ std::vector<std::string> oneWire = LedService::getSingleWireProtocols();
+ std::vector<std::string> spiChipsets = LedService::getSpiChipsets();
+ std::vector<std::string> allProtocols;
+ size_t index = 1;
+
+ // Show single wire protocols
+ terminalView.println(" -- Single-wire protocols (DATA only) --");
+ for (const auto& proto : oneWire) {
+ terminalView.println(" " + std::to_string(index++) + ". " + proto);
+ allProtocols.push_back(proto);
+ }
+
+ // Show clocked
+ terminalView.println(" -- Clocked chipsets (DATA + CLOCK) --");
+ for (const auto& proto : spiChipsets) {
+ terminalView.println(" " + std::to_string(index++) + ". " + proto);
+ allProtocols.push_back(proto);
+ }
+
+ // Convert saved protocol to index
+ std::string currentProtocol = state.getLedProtocol();
+ auto it = std::find(allProtocols.begin(), allProtocols.end(), currentProtocol);
+ size_t currentIndex = (it != allProtocols.end()) ? std::distance(allProtocols.begin(), it) + 1 : 1;
+
+
+ // Ask for protocol index
+ terminalView.println("");
+ uint8_t choice = 0;
+ while (true) {
+ choice = userInputManager.readValidatedUint8("Choice", currentIndex);
+ if (choice >= 1 && choice <= allProtocols.size()) break;
+ terminalView.println("Invalid choice. Try again.");
+ }
+
+ // Configure
+ std::string selectedProtocol = allProtocols[choice - 1];
+ state.setLedProtocol(selectedProtocol);
+ ensureConfigured();
+ terminalView.println("LED protocol changed.\n");
}
+/*
+Help
+*/
+void LedController::handleHelp() {
+ terminalView.println("Unknown LED command. Usage:");
+ terminalView.println(" scan");
+ terminalView.println(" fill blue");
+ terminalView.println(" set 1 red");
+ terminalView.println(" blink");
+ terminalView.println(" rainbow");
+ terminalView.println(" chase");
+ terminalView.println(" cycle");
+ terminalView.println(" wave");
+ terminalView.println(" reset [led num]");
+ terminalView.println(" setprotocol");
+ terminalView.println(" config");
+}
+
+/*
+Ensure Configuration
+*/
void LedController::ensureConfigured() {
if (!configured) {
handleConfig();
configured = true;
+ return;
}
+
+ // Reconfigure
+ std::string protocol = state.getLedProtocol();
+ uint8_t data = state.getLedDataPin();
+ uint8_t clock = state.getLedClockPin();
+ uint16_t length = state.getLedLength();
+ uint8_t brightness = state.getLedBrightness();
+ ledService.configure(data, clock, length, protocol, brightness);
+}
+
+/*
+Utils
+*/
+CRGB LedController::parseFlexibleColor(const std::vector<std::string>& args) {
+ if (args.empty()) return CRGB::Black;
+
+ // 3 nombres
+ if (args.size() >= 3 &&
+ argTransformer.isValidNumber(args[0]) &&
+ argTransformer.isValidNumber(args[1]) &&
+ argTransformer.isValidNumber(args[2])) {
+
+ uint8_t r = argTransformer.toUint8(args[0]);
+ uint8_t g = argTransformer.toUint8(args[1]);
+ uint8_t b = argTransformer.toUint8(args[2]);
+ return CRGB(r, g, b);
+ }
+
+ // #RRGGBB ou 0xRRGGBB
+ const std::string& token = args[0];
+ if (token.rfind("#", 0) == 0 || token.rfind("0x", 0) == 0 || token.rfind("0X", 0) == 0) {
+ return ledService.parseHtmlColor(token);
+ }
+
+ // blue, red, etc.
+ return ledService.parseStringColor(token);
}
diff --git a/src/Controllers/LedController.h b/src/Controllers/LedController.h
index 7f94cef6..beba08d2 100644
--- a/src/Controllers/LedController.h
+++ b/src/Controllers/LedController.h
@@ -6,30 +6,59 @@
#include "Models/TerminalCommand.h"
#include "Models/ByteCode.h"
#include "Services/LedService.h"
-
-// Placeholder implementation for LED controller
-// Future versions may support RGB patterns, animations, or PWM control
+#include "Transformers/ArgTransformer.h"
+#include "Managers/UserInputManager.h"
+#include "States/GlobalState.h"
class LedController {
public:
- // Constructor
- LedController(ITerminalView& terminalView, IInput& terminalInput, LedService& ledService);
+ LedController(ITerminalView& terminalView, IInput& terminalInput,
+ LedService& ledService, ArgTransformer& argTransformer,
+ UserInputManager& userInputManager);
- // Entry point for dispatch incoming LED command
+ // Dispatch user command for LED mode
void handleCommand(const TerminalCommand& cmd);
- // Entry point for handle bytecode-style instructions (parsed instructions)
+ // Execute LED instruction from bytecode
void handleInstruction(const std::vector<ByteCode>& bytecodes);
- // Ensure LED is properly configured before executing commands
+ // Ensure LED mode is properly configured before use
void ensureConfigured();
private:
- // Run LED configuration routine (e.g. default pin setup)
+ // Try to autodetect LED protocol by scanning different types
+ void handleScan();
+
+ // Fill all LEDs with a single color
+ void handleFill(const TerminalCommand& cmd);
+
+ // Set a specific LED index to a specific color
+ void handleSet(const TerminalCommand& cmd);
+
+ // Turn off all LEDs and clear the strip
+ void handleReset(const TerminalCommand& cmd);
+
+ // Run a predefined LED animation
+ void handleAnimation(const TerminalCommand& cmd);
+
+ // Configure LED pin, length and protocol
void handleConfig();
- ITerminalView& terminalView; // Output view for terminal
- IInput& terminalInput; // Input handler
- LedService& ledService; // Service for low-level LED operations
- bool configured = false; // Whether the controller is configured
-};
+ // Change LED protocol interactively
+ void handleSetProtocol();
+
+ // Display help for available LED commands
+ void handleHelp();
+
+ // Convert color arguments to CRGB object
+ CRGB parseFlexibleColor(const std::vector<std::string>& args);
+
+ ITerminalView& terminalView;
+ IInput& terminalInput;
+ LedService& ledService;
+ ArgTransformer& argTransformer;
+ UserInputManager& userInputManager;
+ GlobalState& state = GlobalState::getInstance();
+
+ bool configured = false;
+};
\ No newline at end of file
diff --git a/src/Controllers/UtilityController.cpp b/src/Controllers/UtilityController.cpp
index 6870e8d0..0a6e9c8b 100644
--- a/src/Controllers/UtilityController.cpp
+++ b/src/Controllers/UtilityController.cpp
@@ -323,11 +323,17 @@ void UtilityController::handleHelp() {
terminalView.println("");
terminalView.println(" 10. LED:");
- terminalView.println(" write i <r> <g> <b> - Set LED color");
- terminalView.println(" setprotocol - Select LED type");
- terminalView.println(" test - Run animation");
- terminalView.println(" config - Configure settings");
+ terminalView.println(" scan - Try to detect LEDs type");
+ terminalView.println(" fill <color> - Fill all LEDs with a color");
+ terminalView.println(" set <index> <color> - Set specific LED color");
+ terminalView.println(" blink - Blink all LEDs");
+ terminalView.println(" rainbow - Rainbow animation");
+ terminalView.println(" chase - Chasing light effect");
+ terminalView.println(" cycle - Cycle through colors");
+ terminalView.println(" wave - Wave animation");
terminalView.println(" reset - Turn off all LEDs");
+ terminalView.println(" setprotocol - Select LED protocol");
+ terminalView.println(" config - Configure LED settings");
terminalView.println("");
terminalView.println(" 11. INFRARED:");
diff --git a/src/Dispatchers/ActionDispatcher.cpp b/src/Dispatchers/ActionDispatcher.cpp
index e76836db..d4b0734a 100644
--- a/src/Dispatchers/ActionDispatcher.cpp
+++ b/src/Dispatchers/ActionDispatcher.cpp
@@ -368,6 +368,12 @@ void ActionDispatcher::setCurrentMode(ModeEnum newMode) {
break;
case ModeEnum::LED:
provider.getLedController().ensureConfigured();
+ config.setMappings({
+ "DATA GPIO " + std::to_string(state.getLedDataPin()),
+ "CLOCK GPIO " + std::to_string(state.getLedClockPin()),
+ "LED COUNT " + std::to_string(state.getLedLength()),
+ state.getLedProtocol()
+ });
break;
case ModeEnum::Infrared:
provider.getInfraredController().ensureConfigured();
diff --git a/src/Enums/LedChipsetEnum.h b/src/Enums/LedChipsetEnum.h
new file mode 100644
index 00000000..1958b61f
--- /dev/null
+++ b/src/Enums/LedChipsetEnum.h
@@ -0,0 +1,111 @@
+#pragma once
+
+#include <string>
+#include <map>
+#include <vector>
+#include <algorithm>
+#include <FastLED.h>
+
+// Enum is from FastLED, ESPIChipsets
+
+class LedChipsetMapper {
+public:
+ struct ChipsetInfo {
+ std::string name;
+ bool usesClock;
+ };
+
+ static ESPIChipsets fromString(const std::string& name) {
+ std::string lowered = toLower(name);
+ auto it = stringToEnum.find(lowered);
+ if (it != stringToEnum.end()) {
+ return it->second;
+ }
+ return ESPIChipsets::APA102; // fallback
+ }
+
+ static std::string toString(ESPIChipsets chipset) {
+ auto it = enumToString.find(chipset);
+ if (it != enumToString.end()) {
+ return it->second;
+ }
+ return "apa102"; // fallback
+ }
+
+ static std::vector<std::string> getAllChipsets() {
+ std::vector<std::string> names;
+ for (const auto& kv : stringToEnum) {
+ names.push_back(kv.first);
+ }
+ return names;
+ }
+
+ static bool isClockBased(const std::string& name) {
+ std::string lowered = toLower(name);
+ auto it = stringToChipsetInfo.find(lowered);
+ if (it != stringToChipsetInfo.end()) {
+ return it->second.usesClock;
+ }
+ return true;
+ }
+
+ static std::string normalize(const std::string& name) {
+ std::string lowered = toLower(name);
+ return stringToEnum.count(lowered) ? lowered : "apa102";
+ }
+
+private:
+ static std::string toLower(const std::string& s) {
+ std::string out = s;
+ std::transform(out.begin(), out.end(), out.begin(), ::tolower);
+ return out;
+ }
+
+ static const std::map<std::string, ESPIChipsets> stringToEnum;
+ static const std::map<ESPIChipsets, std::string> enumToString;
+ static const std::map<std::string, ChipsetInfo> stringToChipsetInfo;
+};
+
+// --- MAPPINGS ---
+
+inline const std::map<std::string, ESPIChipsets> LedChipsetMapper::stringToEnum = {
+ {"apa102", APA102},
+ {"apa102hd", APA102HD},
+ {"dotstar", DOTSTAR},
+ {"dotstarhd", DOTSTARHD},
+ {"lpd6803", LPD6803},
+ {"lpd8806", LPD8806},
+ {"ws2801", WS2801},
+ {"ws2803", WS2803},
+ // {"sm16716", SM16716}, // crash the app
+ {"p9813", P9813},
+ {"sk9822", SK9822},
+ {"sk9822hd", SK9822HD},
+ {"hd107", HD107},
+ {"hd107hd", HD107HD}
+};
+
+inline const std::map<ESPIChipsets, std::string> LedChipsetMapper::enumToString = [] {
+ std::map<ESPIChipsets, std::string> result;
+ for (const auto& pair : LedChipsetMapper::stringToEnum) {
+ result[pair.second] = pair.first;
+ }
+ return result;
+}();
+
+inline const std::map<std::string, LedChipsetMapper::ChipsetInfo> LedChipsetMapper::stringToChipsetInfo = {
+ {"apa102", {"APA102", true}},
+ {"apa102hd", {"APA102HD", true}},
+ {"dotstar", {"DOTSTAR", true}},
+ {"dotstarhd", {"DOTSTARHD", true}},
+ {"lpd6803", {"LPD6803", true}},
+ {"lpd8806", {"LPD8806", true}},
+ {"ws2801", {"WS2801", true}},
+ {"ws2803", {"WS2803", true}},
+ // {"sm16716", {"SM16716", true}}, // crash the app
+ {"p9813", {"P9813", true}},
+ {"sk9822", {"SK9822", true}},
+ {"sk9822hd", {"SK9822HD", true}},
+ {"hd107", {"HD107", true}},
+ {"hd107hd", {"HD107HD", true}},
+};
diff --git a/src/Enums/LedProtocolEnum.h b/src/Enums/LedProtocolEnum.h
new file mode 100644
index 00000000..3837947a
--- /dev/null
+++ b/src/Enums/LedProtocolEnum.h
@@ -0,0 +1,99 @@
+#pragma once
+#include <string>
+#include <map>
+#include <algorithm>
+#include <vector>
+
+enum class LedProtocolEnum {
+ NEOPIXEL,
+ WS2812, WS2812B, WS2811, WS2811_400, WS2813, WS2815, WS2816, WS2852,
+ GS1903, SK6812, SK6822, APA104, APA106, PL9823,
+ GE8822, GW6205, GW6205_400, LPD1886, LPD1886_8BIT,
+ SM16703, TM1829, TM1812, TM1809, TM1804, TM1803,
+ UCS1903, UCS1903B, UCS1904, UCS2903, UCS1912,
+ LPD6803, LPD8806, SM16716, P9813,
+ UNKNOWN
+};
+
+class LedProtocolEnumMapper {
+public:
+ static LedProtocolEnum fromString(const std::string& str) {
+ std::string lowered = toLower(str);
+ auto it = stringToEnum.find(lowered);
+ if (it != stringToEnum.end()) return it->second;
+ return LedProtocolEnum::UNKNOWN;
+ }
+
+ static std::string toString(LedProtocolEnum protocol) {
+ auto it = enumToString.find(protocol);
+ if (it != enumToString.end()) return it->second;
+ return "unknown";
+ }
+
+ static std::vector<std::string> getAllProtocols() {
+ std::vector<std::string> protocols;
+ for (const auto& pair : stringToEnum) {
+ if (pair.second != LedProtocolEnum::UNKNOWN) {
+ protocols.push_back(pair.first);
+ }
+ }
+ return protocols;
+ }
+
+private:
+ static std::string toLower(const std::string& s) {
+ std::string out = s;
+ std::transform(out.begin(), out.end(), out.begin(), ::tolower);
+ return out;
+ }
+
+ static const std::map<std::string, LedProtocolEnum> stringToEnum;
+ static const std::map<LedProtocolEnum, std::string> enumToString;
+};
+
+inline const std::map<std::string, LedProtocolEnum> LedProtocolEnumMapper::stringToEnum = {
+ {"neopixel", LedProtocolEnum::NEOPIXEL},
+ {"ws2812", LedProtocolEnum::WS2812},
+ {"ws2812b", LedProtocolEnum::WS2812B},
+ {"ws2811", LedProtocolEnum::WS2811},
+ {"ws2811_400", LedProtocolEnum::WS2811_400},
+ {"ws2813", LedProtocolEnum::WS2813},
+ {"ws2815", LedProtocolEnum::WS2815},
+ {"ws2816", LedProtocolEnum::WS2816},
+ {"ws2852", LedProtocolEnum::WS2852},
+ {"gs1903", LedProtocolEnum::GS1903},
+ {"sk6812", LedProtocolEnum::SK6812},
+ {"sk6822", LedProtocolEnum::SK6822},
+ {"apa104", LedProtocolEnum::APA104},
+ {"apa106", LedProtocolEnum::APA106},
+ {"pl9823", LedProtocolEnum::PL9823},
+ {"ge8822", LedProtocolEnum::GE8822},
+ {"gw6205", LedProtocolEnum::GW6205},
+ {"gw6205_400", LedProtocolEnum::GW6205_400},
+ {"lpd1886", LedProtocolEnum::LPD1886},
+ {"lpd1886_8bit", LedProtocolEnum::LPD1886_8BIT},
+ {"sm16703", LedProtocolEnum::SM16703},
+ {"tm1829", LedProtocolEnum::TM1829},
+ {"tm1812", LedProtocolEnum::TM1812},
+ {"tm1809", LedProtocolEnum::TM1809},
+ {"tm1804", LedProtocolEnum::TM1804},
+ {"tm1803", LedProtocolEnum::TM1803},
+ {"ucs1903", LedProtocolEnum::UCS1903},
+ {"ucs1903b", LedProtocolEnum::UCS1903B},
+ {"ucs1904", LedProtocolEnum::UCS1904},
+ {"ucs2903", LedProtocolEnum::UCS2903},
+ {"ucs1912", LedProtocolEnum::UCS1912},
+ {"lpd6803", LedProtocolEnum::LPD6803},
+ {"lpd8806", LedProtocolEnum::LPD8806},
+ {"sm16716", LedProtocolEnum::SM16716},
+ {"p9813", LedProtocolEnum::P9813},
+ {"unknown", LedProtocolEnum::UNKNOWN}
+};
+
+inline const std::map<LedProtocolEnum, std::string> LedProtocolEnumMapper::enumToString = [] {
+ std::map<LedProtocolEnum, std::string> result;
+ for (const auto& pair : LedProtocolEnumMapper::stringToEnum) {
+ result[pair.second] = pair.first;
+ }
+ return result;
+}();
diff --git a/src/Providers/DependencyProvider.cpp b/src/Providers/DependencyProvider.cpp
index 7a1dbdfe..251b1678 100644
--- a/src/Providers/DependencyProvider.cpp
+++ b/src/Providers/DependencyProvider.cpp
@@ -42,7 +42,7 @@ DependencyProvider::DependencyProvider(ITerminalView& terminalView, IDeviceView&
twoWireController(terminalView, terminalInput, userInputManager, twoWireService),
threeWireController(terminalView, terminalInput),
dioController(terminalView, terminalInput, pinService, argTransformer),
- ledController(terminalView, terminalInput, ledService),
+ ledController(terminalView, terminalInput, ledService, argTransformer, userInputManager),
bluetoothController(terminalView, terminalInput, bluetoothService, argTransformer),
i2sController(terminalView, terminalInput, i2sService, argTransformer, userInputManager),
wifiController(terminalView, terminalInput, wifiService, nvsService, argTransformer)
diff --git a/src/Services/LedService.cpp b/src/Services/LedService.cpp
index 0d6a335e..04e33f71 100644
--- a/src/Services/LedService.cpp
+++ b/src/Services/LedService.cpp
@@ -1,17 +1,327 @@
#include "LedService.h"
+#include <FastLED.h>
+#include <Enums/LedProtocolEnum.h>
+#include <Enums/LedChipsetEnum.h>
-void LedService::blink() {
- showLed();
- delay(30);
- clearLed();
+LedService::LedService() {}
+
+void LedService::configure(uint8_t dataPin, uint8_t clockPin, uint16_t length, const std::string& protocol, uint8_t brightness) {
+ if (leds) {
+ delete[] leds;
+ leds = nullptr;
+ }
+
+ ledCount = length;
+ leds = new CRGB[ledCount];
+ FastLED.clear();
+ FastLED.clearData();
+
+ /*
+ Fastled need defined pins and protocol at compile time,
+ cant find another way to do it than using switch for each one
+ */
+
+ // --- Only DATA Pin ---
+
+ auto proto = LedProtocolEnumMapper::fromString(protocol);
+ if (proto != LedProtocolEnum::UNKNOWN) {
+ switch (proto) {
+ case LedProtocolEnum::NEOPIXEL:
+ FastLED.addLeds<NEOPIXEL, LED_DATA_PIN>(leds, ledCount); break;
+ case LedProtocolEnum::WS2812:
+ FastLED.addLeds<WS2812, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::WS2812B:
+ FastLED.addLeds<WS2812B, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::WS2811:
+ FastLED.addLeds<WS2811, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::WS2811_400:
+ FastLED.addLeds<WS2811_400, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::WS2813:
+ FastLED.addLeds<WS2813, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::WS2815:
+ FastLED.addLeds<WS2815, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::WS2816:
+ FastLED.addLeds<WS2816, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::GS1903:
+ FastLED.addLeds<GS1903, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::SK6812:
+ FastLED.addLeds<SK6812, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::SK6822:
+ FastLED.addLeds<SK6822, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::APA104:
+ FastLED.addLeds<APA104, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::APA106:
+ FastLED.addLeds<APA106, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::PL9823:
+ FastLED.addLeds<PL9823, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::GE8822:
+ FastLED.addLeds<GE8822, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::GW6205:
+ FastLED.addLeds<GW6205, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::GW6205_400:
+ FastLED.addLeds<GW6205_400, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::LPD1886:
+ FastLED.addLeds<LPD1886, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::LPD1886_8BIT:
+ FastLED.addLeds<LPD1886_8BIT, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::SM16703:
+ FastLED.addLeds<SM16703, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::TM1829:
+ FastLED.addLeds<TM1829, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::TM1812:
+ FastLED.addLeds<TM1812, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::TM1809:
+ FastLED.addLeds<TM1809, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::TM1804:
+ FastLED.addLeds<TM1804, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::TM1803:
+ FastLED.addLeds<TM1803, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::UCS1903:
+ FastLED.addLeds<UCS1903, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::UCS1903B:
+ FastLED.addLeds<UCS1903B, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::UCS1904:
+ FastLED.addLeds<UCS1904, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::UCS2903:
+ FastLED.addLeds<UCS2903, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ case LedProtocolEnum::UCS1912:
+ FastLED.addLeds<UCS1912, LED_DATA_PIN, GRB>(leds, ledCount); break;
+ default:
+ delete[] leds;
+ leds = nullptr;
+ return;
+ }
+ usesClock = false;
+ FastLED.setBrightness(brightness);
+ FastLED.show();
+ return;
+ }
+
+ // --- Chipsets DATA + CLOCK ---
+
+ auto chipset = LedChipsetMapper::fromString(protocol);
+ switch (chipset) {
+ case LPD6803:
+ FastLED.addLeds<LPD6803, LED_DATA_PIN, LED_CLOCK_PIN>(leds, ledCount); break;
+ case LPD8806:
+ FastLED.addLeds<LPD8806, LED_DATA_PIN, LED_CLOCK_PIN>(leds, ledCount); break;
+ case WS2801:
+ FastLED.addLeds<WS2801, LED_DATA_PIN, LED_CLOCK_PIN>(leds, ledCount); break;
+ case WS2803:
+ FastLED.addLeds<WS2803, LED_DATA_PIN, LED_CLOCK_PIN>(leds, ledCount); break;
+ case SM16716:
+ FastLED.addLeds<SM16716, LED_DATA_PIN, LED_CLOCK_PIN>(leds, ledCount); break;
+ case P9813:
+ FastLED.addLeds<P9813, LED_DATA_PIN, LED_CLOCK_PIN>(leds, ledCount); break;
+ case APA102:
+ FastLED.addLeds<APA102, LED_DATA_PIN, LED_CLOCK_PIN, BGR>(leds, ledCount); break;
+ case APA102HD:
+ FastLED.addLeds<APA102, LED_DATA_PIN, LED_CLOCK_PIN, BGR>(leds, ledCount); break;
+ case DOTSTAR:
+ FastLED.addLeds<DOTSTAR, LED_DATA_PIN, LED_CLOCK_PIN, BGR>(leds, ledCount); break;
+ case DOTSTARHD:
+ FastLED.addLeds<DOTSTARHD, LED_DATA_PIN, LED_CLOCK_PIN, BGR>(leds, ledCount); break;
+ case SK9822:
+ FastLED.addLeds<SK9822, LED_DATA_PIN, LED_CLOCK_PIN, BGR>(leds, ledCount); break;
+ case SK9822HD:
+ FastLED.addLeds<SK9822HD, LED_DATA_PIN, LED_CLOCK_PIN, BGR>(leds, ledCount); break;
+ case HD107:
+ FastLED.addLeds<HD107, LED_DATA_PIN, LED_CLOCK_PIN, BGR>(leds, ledCount); break;
+ case HD107HD:
+ FastLED.addLeds<HD107HD, LED_DATA_PIN, LED_CLOCK_PIN, BGR>(leds, ledCount); break;
+ default:
+ delete[] leds;
+ leds = nullptr;
+ return;
+ }
+
+ usesClock = true;
+ FastLED.setBrightness(brightness);
+ FastLED.show();
}
-void LedService::showLed() {
- FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, 1); // we use define LED_PIN Builtin for now
- leds[0] = CRGB::OrangeRed;
+void LedService::fill(const CRGB& color) {
+ if (!leds) return;
+ FastLED.clear(true);
+ for (uint16_t i = 0; i < ledCount; ++i) {
+ leds[i] = color;
+ }
FastLED.show();
}
-void LedService::clearLed() {
+void LedService::set(uint16_t index, const CRGB& color) {
+ if (!leds || index >= ledCount) return;
+
+ // Clear the LED
+ leds[index] = CRGB::Black;
+ FastLED.show();
+
+ // Show new color
+ leds[index] = color;
+ FastLED.show();
+}
+
+void LedService::reset() {
+ if (!leds) return;
+ fill(CRGB::Black);
FastLED.clear(true);
-}
\ No newline at end of file
+ animationRunning = false;
+}
+
+void LedService::runAnimation(const std::string& type) {
+ if (!leds) return;
+ animationRunning = true;
+ FastLED.clear();
+
+ if (type == "blink") {
+ for (int i = 0; i < 3 && animationRunning; ++i) {
+ fill(CRGB::White);
+ delay(50);
+ reset();
+ delay(50);
+ }
+ } else if (type == "rainbow") {
+ for (int j = 0; j < 256 && animationRunning; ++j) {
+ for (uint16_t i = 0; i < ledCount; ++i) {
+ leds[i] = CHSV((i * 10 + j) % 255, 255, 255);
+ }
+ FastLED.show();
+ delay(1);
+ }
+ } else if (type == "chase") {
+ for (int i = 0; i < ledCount * 2 && animationRunning; ++i) {
+ fill(CRGB::Black);
+ leds[i % ledCount] = CRGB::Blue;
+ FastLED.show();
+ delay(100);
+ }
+ } else if (type == "cycle") {
+ CRGB colors[] = {CRGB::Red, CRGB::Green, CRGB::Blue};
+ for (int c = 0; c < 3 && animationRunning; ++c) {
+ fill(colors[c]);
+ delay(100);
+ }
+ } else if (type == "wave") {
+ for (int t = 0; t < 256 && animationRunning; ++t) {
+ for (uint16_t i = 0; i < ledCount; ++i) {
+ uint8_t level = (sin8(i * 8 + t));
+ leds[i] = CHSV(160, 255, level);
+ }
+ FastLED.show();
+ delay(1);
+ }
+ }
+ animationRunning = false;
+}
+
+bool LedService::isAnimationRunning() const {
+ return animationRunning;
+}
+
+std::vector<std::string> LedService::getSingleWireProtocols() {
+ return LedProtocolEnumMapper::getAllProtocols();
+}
+
+std::vector<std::string> LedService::getSpiChipsets() {
+ return LedChipsetMapper::getAllChipsets();
+}
+
+std::vector<std::string> LedService::getSupportedProtocols() {
+ std::vector<std::string> all = getSingleWireProtocols();
+ std::vector<std::string> spi = getSpiChipsets();
+ all.insert(all.end(), spi.begin(), spi.end());
+ return all;
+}
+
+std::vector<std::string> LedService::getSupportedAnimations() {
+ return {
+ "blink", "rainbow", "chase", "cycle", "wave"
+ };
+}
+
+CRGB LedService::parseStringColor(const std::string& input) {
+ auto toLower = [](const std::string& str) {
+ std::string result = str;
+ std::transform(result.begin(), result.end(), result.begin(), ::tolower);
+ return result;
+ };
+
+ std::string lowered = toLower(input);
+
+ static const std::map<std::string, CRGB> namedColors = {
+ {"black", CRGB(0x00, 0x00, 0x00)},
+ {"off", CRGB(0x00, 0x00, 0x00)},
+ {"white", CRGB(0xFF, 0xFF, 0xFF)},
+ {"on", CRGB(0xFF, 0xFF, 0xFF)},
+ {"red", CRGB(0xFF, 0x00, 0x00)},
+ {"green", CRGB(0x00, 0x80, 0x00)},
+ {"blue", CRGB(0x00, 0x00, 0xFF)},
+ {"yellow", CRGB(0xFF, 0xFF, 0x00)},
+ {"cyan", CRGB(0x00, 0xFF, 0xFF)},
+ {"magenta", CRGB(0xFF, 0x00, 0xFF)},
+ {"purple", CRGB(0x80, 0x00, 0x80)},
+ {"orange", CRGB(0xFF, 0xA5, 0x00)},
+ {"pink", CRGB(0xFF, 0xC0, 0xCB)},
+ {"brown", CRGB(0xA5, 0x2A, 0x2A)},
+ {"gray", CRGB(0x80, 0x80, 0x80)},
+ {"navy", CRGB(0x00, 0x00, 0x80)},
+ {"teal", CRGB(0x00, 0x80, 0x80)},
+ {"olive", CRGB(0x80, 0x80, 0x00)},
+ {"lime", CRGB(0x00, 0xFF, 0x00)},
+ {"aqua", CRGB(0x00, 0xFF, 0xFF)},
+ {"maroon", CRGB(0x80, 0x00, 0x00)},
+ {"silver", CRGB(0xC0, 0xC0, 0xC0)},
+ {"gold", CRGB(0xFF, 0xD7, 0x00)},
+ {"skyblue", CRGB(0x87, 0xCE, 0xEB)},
+ {"violet", CRGB(0xEE, 0x82, 0xEE)},
+ {"turquoise", CRGB(0x40, 0xE0, 0xD0)},
+ {"coral", CRGB(0xFF, 0x7F, 0x50)},
+ {"indigo", CRGB(0x4B, 0x00, 0x82)},
+ {"salmon", CRGB(0xFA, 0x80, 0x72)},
+ {"beige", CRGB(0xF5, 0xF5, 0xDC)},
+ {"khaki", CRGB(0xF0, 0xE6, 0x8C)},
+ {"plum", CRGB(0xDD, 0xA0, 0xDD)},
+ {"orchid", CRGB(0xDA, 0x70, 0xD6)},
+ {"tan", CRGB(0xD2, 0xB4, 0x8C)},
+ {"chocolate", CRGB(0xD2, 0x69, 0x1E)},
+ {"crimson", CRGB(0xDC, 0x14, 0x3C)},
+ {"tomato", CRGB(0xFF, 0x63, 0x47)},
+ {"darkpink", CRGB(0xFF, 0x14, 0x93)},
+ {"darkblue", CRGB(0x00, 0xBF, 0xFF)},
+ };
+
+ auto it = namedColors.find(lowered);
+ if (it != namedColors.end())
+ return it->second;
+
+ return CRGB::White; // fallback
+}
+
+CRGB LedService::parseHtmlColor(const std::string& input) {
+ auto toLower = [](const std::string& str) {
+ std::string result = str;
+ std::transform(result.begin(), result.end(), result.begin(), ::tolower);
+ return result;
+ };
+
+ std::string lowered = toLower(input);
+
+ // #RRGGBB ou 0xRRGGBB
+ std::string hex = lowered;
+ if (hex.rfind("#", 0) == 0)
+ hex = "0x" + hex.substr(1); // convert # to 0x
+
+ if (hex.rfind("0x", 0) == 0 && hex.length() == 8) {
+ try {
+ uint32_t value = std::stoul(hex, nullptr, 16);
+ uint8_t r = (value >> 16) & 0xFF;
+ uint8_t g = (value >> 8) & 0xFF;
+ uint8_t b = value & 0xFF;
+ return CRGB(r, g, b);
+ } catch (...) {
+ return CRGB::White;
+ }
+ }
+
+ return CRGB::White;
+}
diff --git a/src/Services/LedService.h b/src/Services/LedService.h
index 355502e2..e551e2f3 100644
--- a/src/Services/LedService.h
+++ b/src/Services/LedService.h
@@ -1,20 +1,29 @@
-#ifndef LED_SERVICE_H
-#define LED_SERVICE_H
+#pragma once
#include <FastLED.h>
-#include <States/GlobalState.h>
-
-#define LED_PIN 21 // Builtin, TODO: use context
+#include <string>
+#include <vector>
+#include <map>
class LedService {
public:
- void blink();
- void showLed();
- void clearLed();
+ LedService();
+ void configure(uint8_t dataPin, uint8_t clockPin, uint16_t length, const std::string& protocol, uint8_t brightness);
+ void fill(const CRGB& color);
+ void set(uint16_t index, const CRGB& color);
+ void reset();
+ void runAnimation(const std::string& type);
+ bool isAnimationRunning() const;
+ static std::vector<std::string> getSingleWireProtocols();
+ static std::vector<std::string> getSpiChipsets();
+ static std::vector<std::string> getSupportedProtocols();
+ static std::vector<std::string> getSupportedAnimations();
+ CRGB parseStringColor(const std::string& input);
+ CRGB parseHtmlColor(const std::string& input);
private:
- CRGB leds[1];
-};
-
-
-#endif
+ CRGB* leds = nullptr;
+ uint16_t ledCount = 0;
+ bool usesClock = false;
+ bool animationRunning = false;
+};
\ No newline at end of file
diff --git a/src/States/GlobalState.h b/src/States/GlobalState.h
index 30f81d89..698cd91a 100644
--- a/src/States/GlobalState.h
+++ b/src/States/GlobalState.h
@@ -82,6 +82,13 @@ private:
uint8_t infraredRxPin = 1;
InfraredProtocolEnum infraredProtocol = InfraredProtocolEnum::_NEC;
+ // LED Mode
+ uint8_t ledDataPin = 1;
+ uint8_t ledClockPin = 2;
+ uint16_t ledLength = 8;
+ std::string ledProtocol = "ws2812";
+ uint8_t ledBrightness = 128;
+
// I2S Default Configuration
uint8_t i2sBclkPin = 41;
uint8_t i2sLrckPin = 43;
@@ -211,6 +218,19 @@ public:
InfraredProtocolEnum getInfraredProtocol() const { return infraredProtocol ; }
void setInfraredProtocol(InfraredProtocolEnum prot) { infraredProtocol = prot; }
+ // LED Mode
+ uint8_t getLedDataPin() const { return ledDataPin; }
+ uint8_t getLedClockPin() const { return ledClockPin; }
+ uint16_t getLedLength() const { return ledLength; }
+ const std::string& getLedProtocol() const { return ledProtocol; }
+ uint8_t getLedBrightness() const { return ledBrightness; }
+
+ void setLedDataPin(uint8_t pin) { ledDataPin = pin; }
+ void setLedClockPin(uint8_t pin) { ledClockPin = pin; }
+ void setLedLength(uint16_t len) { ledLength = len; }
+ void setLedProtocol(const std::string& prot) { ledProtocol = prot; }
+ void setLedBrightness(uint8_t brightness) { ledBrightness = brightness; }
+
// I2S
uint8_t getI2sBclkPin() const { return i2sBclkPin; }
uint8_t getI2sLrckPin() const { return i2sLrckPin; }
@@ -324,6 +344,12 @@ public:
#ifdef TWOWIRE_RST_PIN
twoWireRstPin = TWOWIRE_RST_PIN;
#endif
+ #ifdef LED_DATA_PIN
+ ledDataPin = LED_DATA_PIN;
+ #endif
+ #ifdef LED_CLOCK_PIN
+ ledClockPin = LED_CLOCK_PIN;
+ #endif
#ifdef PROTECTED_PINS
{