116 lines
3.0 KiB
C++
116 lines
3.0 KiB
C++
/**
|
|
* @file LEDIndicator.cpp
|
|
* @brief Implementation of LED status indicators
|
|
*/
|
|
|
|
#include "LEDIndicator.h"
|
|
|
|
/**
|
|
* @brief Constructor - initialize with default state
|
|
*/
|
|
// LEDIndicator::LEDIndicator() :
|
|
// powerOn(false),
|
|
// dccMode(false),
|
|
// brightness(128),
|
|
// lastUpdate(0),
|
|
// pulsePhase(0)
|
|
// {}
|
|
LEDIndicator::LEDIndicator(){}
|
|
|
|
void LEDIndicator::begin() {
|
|
// FastLED.addLeds<WS2812, LED_DATA_PIN, GRB>(leds, NUM_LEDS);
|
|
// FastLED.setBrightness(brightness);
|
|
|
|
// Initialize both LEDs to off
|
|
// leds[LED_POWER] = COLOR_OFF;
|
|
// leds[LED_MODE] = COLOR_OFF;
|
|
// FastLED.show();
|
|
|
|
// Serial.println("LED Indicator initialized");
|
|
// Serial.printf("LED Data Pin: %d, Num LEDs: %d\n", LED_DATA_PIN, NUM_LEDS);
|
|
}
|
|
|
|
void LEDIndicator::update() {
|
|
// unsigned long now = millis();
|
|
|
|
// // Update power LED
|
|
// if (powerOn) {
|
|
// leds[LED_POWER] = COLOR_POWER_ON;
|
|
// } else {
|
|
// leds[LED_POWER] = COLOR_POWER_OFF;
|
|
// }
|
|
|
|
// Update mode LED with subtle pulsing effect
|
|
// if (now - lastUpdate > 20) {
|
|
// lastUpdate = now;
|
|
// pulsePhase++;
|
|
|
|
// // Create gentle pulse effect
|
|
// uint8_t pulseBrightness = 128 + (sin8(pulsePhase * 2) / 4);
|
|
|
|
// CRGB baseColor = dccMode ? COLOR_DCC : COLOR_ANALOG;
|
|
// leds[LED_MODE] = baseColor;
|
|
// leds[LED_MODE].fadeToBlackBy(255 - pulseBrightness);
|
|
// }
|
|
|
|
// FastLED.show();
|
|
}
|
|
|
|
void LEDIndicator::setPowerOn(bool on) {
|
|
// if (powerOn != on) {
|
|
// powerOn = on;
|
|
// if (on) {
|
|
// powerOnSequence();
|
|
// }
|
|
// }
|
|
}
|
|
|
|
void LEDIndicator::setMode(bool isDCC) {
|
|
// if (dccMode != isDCC) {
|
|
// dccMode = isDCC;
|
|
// modeChangeEffect();
|
|
// }
|
|
}
|
|
|
|
void LEDIndicator::setBrightness(uint8_t newBrightness) {
|
|
// brightness = newBrightness;
|
|
// FastLED.setBrightness(brightness);
|
|
}
|
|
|
|
void LEDIndicator::powerOnSequence() {
|
|
// // Quick flash sequence on power on
|
|
// for (int i = 0; i < 3; i++) {
|
|
// leds[LED_POWER] = COLOR_POWER_ON;
|
|
// FastLED.show();
|
|
// delay(100);
|
|
// leds[LED_POWER] = COLOR_OFF;
|
|
// FastLED.show();
|
|
// delay(100);
|
|
// }
|
|
// leds[LED_POWER] = COLOR_POWER_ON;
|
|
// FastLED.show();
|
|
// Serial.println("LED: Power ON sequence");
|
|
}
|
|
|
|
void LEDIndicator::modeChangeEffect() {
|
|
// // Smooth transition effect when changing modes
|
|
// CRGB targetColor = dccMode ? COLOR_DCC : COLOR_ANALOG;
|
|
|
|
// // Fade out
|
|
// for (int i = 255; i >= 0; i -= 15) {
|
|
// leds[LED_MODE].fadeToBlackBy(15);
|
|
// FastLED.show();
|
|
// delay(10);
|
|
// }
|
|
|
|
// // Fade in new color
|
|
// for (int i = 0; i <= 255; i += 15) {
|
|
// leds[LED_MODE] = targetColor;
|
|
// leds[LED_MODE].fadeToBlackBy(255 - i);
|
|
// FastLED.show();
|
|
// delay(10);
|
|
// }
|
|
|
|
// Serial.printf("LED: Mode changed to %s\n", dccMode ? "DCC (Blue)" : "Analog (Yellow)");
|
|
}
|