added fastLED and LED output, doesn't compile yet, compiled binary is to big
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <Arduino.h>
|
||||
#include "Core.h"
|
||||
#include <FastLED.h>
|
||||
|
||||
WiFiUDP udp;
|
||||
Preferences prefs;
|
||||
@@ -26,6 +27,13 @@ float calibratedPoints[NUM_CHANNELS][5] = {
|
||||
{0.0f, 26.0f, 50.0f, 76.0f, 99.0f}
|
||||
};
|
||||
|
||||
// -------------------------------
|
||||
// Lighting (FastLED)
|
||||
// -------------------------------
|
||||
#define LED_PIN 23
|
||||
#define NUM_LEDS 20 // or more if you expand later
|
||||
CRGB leds[NUM_LEDS];
|
||||
|
||||
uint8_t lightingHue = 0;
|
||||
uint8_t lightingSaturation = 255;
|
||||
uint8_t lightingBrightness = 255;
|
||||
@@ -63,6 +71,17 @@ float applyCalibration(uint8_t ch, float logicalDuty) {
|
||||
return calibratedPoints[ch][4];
|
||||
}
|
||||
|
||||
void applyLighting() {
|
||||
// Convert HSV (0–255 each) to RGB
|
||||
CHSV hsv(lightingHue, lightingSaturation, lightingBrightness);
|
||||
|
||||
for (int i = 0; i < NUM_LEDS; i++) {
|
||||
leds[i] = hsv;
|
||||
}
|
||||
|
||||
FastLED.show();
|
||||
}
|
||||
|
||||
void updateConnectionStatusUI(ConnectionState state) {
|
||||
const char* text = "Unknown";
|
||||
|
||||
@@ -118,6 +137,12 @@ void coreInit() {
|
||||
Serial.printf("Lighting loaded (0–255): H=%d S=%d B=%d\n",
|
||||
lightingHue, lightingSaturation, lightingBrightness);
|
||||
|
||||
// FastLED init
|
||||
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
|
||||
FastLED.setBrightness(255); // full brightness; HSV V controls actual output
|
||||
|
||||
// Apply lighting immediately at boot
|
||||
applyLighting();
|
||||
|
||||
// Start UDP with runtime port
|
||||
udp.begin(udpPort);
|
||||
|
||||
@@ -48,3 +48,4 @@ void coreUpdateState(); // called from loop()
|
||||
// Helpers used by UI
|
||||
float applyCalibration(uint8_t ch, float logicalDuty);
|
||||
void updateConnectionStatusUI(ConnectionState state);
|
||||
void applyLighting();
|
||||
|
||||
@@ -246,6 +246,7 @@ void uiInit(uint16_t& tabSettings, uint16_t& tabLighting, uint16_t& tabCalibrati
|
||||
int sliderVal = sender->value.toInt(); // 0–100
|
||||
lightingHue = fromSlider(sliderVal); // convert to 0–255
|
||||
Serial.printf("Lighting Hue changed (RAM only): %d\n", lightingHue);
|
||||
applyLighting();
|
||||
}
|
||||
);
|
||||
|
||||
@@ -260,6 +261,7 @@ void uiInit(uint16_t& tabSettings, uint16_t& tabLighting, uint16_t& tabCalibrati
|
||||
int sliderVal = sender->value.toInt(); // 0–100
|
||||
lightingSaturation = fromSlider(sliderVal);
|
||||
Serial.printf("Lighting Saturation updated (RAM only): %d\n", lightingSaturation);
|
||||
applyLighting();
|
||||
}
|
||||
);
|
||||
|
||||
@@ -274,6 +276,7 @@ void uiInit(uint16_t& tabSettings, uint16_t& tabLighting, uint16_t& tabCalibrati
|
||||
int sliderVal = sender->value.toInt(); // 0–100
|
||||
lightingBrightness = fromSlider(sliderVal);
|
||||
Serial.printf("Lighting Brightness updated (RAM only): %d\n", lightingBrightness);
|
||||
applyLighting();
|
||||
}
|
||||
);
|
||||
ESPUI.addControl(
|
||||
|
||||
Reference in New Issue
Block a user