Browse Source

Allow to set relative brightness and relative color in mireds through command using +N and -N notation

rules-rpn
tsymbaliuk 5 years ago
parent
commit
2832dc7552
1 changed files with 20 additions and 5 deletions
  1. +20
    -5
      code/espurna/light.ino

+ 20
- 5
code/espurna/light.ino View File

@ -989,8 +989,15 @@ void _lightInitCommands() {
terminalRegisterCommand(F("BRIGHTNESS"), [](Embedis* e) {
if (e->argc > 1) {
lightBrightness(String(e->argv[1]).toInt());
lightUpdate(true, true);
const String value(e->argv[1]);
if( value.length() > 0 ) {
if( value[0] == '+' || value[0] == '-' ) {
lightBrightness(lightBrightness()+String(e->argv[1]).toInt());
} else {
lightBrightness(String(e->argv[1]).toInt());
}
lightUpdate(true, true);
}
}
DEBUG_MSG_P(PSTR("Brightness: %d\n"), lightBrightness());
terminalOK();
@ -1032,9 +1039,17 @@ void _lightInitCommands() {
terminalRegisterCommand(F("MIRED"), [](Embedis* e) {
if (e->argc > 1) {
String color = String("M") + String(e->argv[1]);
lightColor(color.c_str());
lightUpdate(true, true);
const String value(e->argv[1]);
String color = String("M");
if( value.length() > 0 ) {
if( value[0] == '+' || value[0] == '-' ) {
color += String(_light_mireds + String(e->argv[1]).toInt());
} else {
color += String(e->argv[1]);
}
lightColor(color.c_str());
lightUpdate(true, true);
}
}
DEBUG_MSG_P(PSTR("Color: %s\n"), lightColor().c_str());
terminalOK();


Loading…
Cancel
Save