mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 06:06:23 +01:00
Added option to control RGB LED brightness
This commit is contained in:
@@ -66,6 +66,16 @@
|
||||
<option value="27">27</option>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label for="apcfgledbrightness">LED Brightness</label>
|
||||
<select id="apcfgledbrightness">
|
||||
<option value="-1">off</option>
|
||||
<option value="64">25%</option>
|
||||
<option value="128">50%</option>
|
||||
<option value="192">75%</option>
|
||||
<option value="255">100%</option>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<input type="button" value="Save" id="apcfgsave">
|
||||
</p>
|
||||
|
||||
@@ -315,18 +315,20 @@ $('#apconfigbutton').onclick = function () {
|
||||
table.deleteRow(i);
|
||||
}
|
||||
$('#apconfigbox').style.display = 'block'
|
||||
fetch("/get_ap_list")
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
$('#apcfgalias').value = data.alias;
|
||||
$('#apcfgchid').value = data.channel;
|
||||
})
|
||||
fetch("/get_ap_list")
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
$('#apcfgalias').value = data.alias;
|
||||
$('#apcfgchid').value = data.channel;
|
||||
$("#apcfgledbrightness").value = data.ledbrightness;
|
||||
})
|
||||
}
|
||||
|
||||
$('#apcfgsave').onclick = function () {
|
||||
let formData = new FormData();
|
||||
formData.append("alias", $('#apcfgalias').value);
|
||||
formData.append("channel", $('#apcfgchid').value);
|
||||
formData.append("channel", $('#apcfgchid').value);
|
||||
formData.append('ledbrightness', $('#apcfgledbrightness').value);
|
||||
fetch("/save_apcfg", {
|
||||
method: "POST",
|
||||
body: formData
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
#ifdef HAS_RGB_LED
|
||||
#include <FastLED.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void ledTask(void* parameter);
|
||||
void setBrightness(int brightness);
|
||||
void updateBrightnessFromConfig();
|
||||
|
||||
#ifdef HAS_RGB_LED
|
||||
void shortBlink(CRGB cname);
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
#endif
|
||||
|
||||
#include "settings.h"
|
||||
#include "tag_db.h"
|
||||
|
||||
QueueHandle_t ledQueue;
|
||||
int maxledbrightness = 255;
|
||||
|
||||
#ifdef HAS_RGB_LED
|
||||
QueueHandle_t rgbLedQueue;
|
||||
@@ -230,6 +232,23 @@ void monoIdleStep() {
|
||||
}
|
||||
}
|
||||
|
||||
void setBrightness(int brightness) {
|
||||
maxledbrightness = brightness;
|
||||
#ifdef HAS_RGB_LED
|
||||
FastLED.setBrightness(maxledbrightness);
|
||||
#endif
|
||||
}
|
||||
|
||||
void updateBrightnessFromConfig() {
|
||||
if (APconfig["ledbrightness"].as<int>() != 0) {
|
||||
int newbrightness = APconfig["ledbrightness"].as<int>();
|
||||
if (newbrightness < 0) newbrightness = 0;
|
||||
if (newbrightness != maxledbrightness) {
|
||||
setBrightness(newbrightness);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ledTask(void* parameter) {
|
||||
#ifdef HAS_RGB_LED
|
||||
FastLED.addLeds<WS2812B, FLASHER_RGB_LED, GRB>(leds, 1); // GRB ordering is typical
|
||||
@@ -285,7 +304,7 @@ void ledTask(void* parameter) {
|
||||
|
||||
if (rgbQueueFlush) {
|
||||
delete rgb;
|
||||
rgb=nullptr;
|
||||
rgb = nullptr;
|
||||
} else {
|
||||
rgbInstructionFadeTime = rgb->fadeTime;
|
||||
if (rgb->fadeTime <= 1) {
|
||||
|
||||
@@ -87,6 +87,8 @@ void setup() {
|
||||
|
||||
initAPconfig();
|
||||
|
||||
updateBrightnessFromConfig();
|
||||
|
||||
init_web();
|
||||
init_udp();
|
||||
|
||||
|
||||
@@ -227,10 +227,11 @@ void initAPconfig() {
|
||||
LittleFS.begin(true);
|
||||
File configFile = LittleFS.open("/current/apconfig.json", "r");
|
||||
if (!configFile) {
|
||||
//default values'
|
||||
// default values'
|
||||
Serial.println("APconfig not found");
|
||||
APconfig["channel"] = 0;
|
||||
APconfig["alias"] = String();
|
||||
APconfig["ledbrightness"] = 100;
|
||||
return;
|
||||
}
|
||||
DeserializationError error = deserializeJson(APconfig, configFile);
|
||||
|
||||
@@ -308,6 +308,8 @@ void init_web() {
|
||||
if (request->hasParam("alias", true) && request->hasParam("channel", true)) {
|
||||
APconfig["alias"] = request->getParam("alias", true)->value();
|
||||
APconfig["channel"] = request->getParam("channel", true)->value();
|
||||
APconfig["ledbrightness"] = request->getParam("ledbrightness", true)->value();
|
||||
updateBrightnessFromConfig();
|
||||
saveAPconfig();
|
||||
setAPchannel();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user