Skip to content

Commit

Permalink
Merge pull request #1607 from tsymbaliuk/dev
Browse files Browse the repository at this point in the history
Allow to set relative brightness and relative color in mireds through…
  • Loading branch information
xoseperez authored Mar 5, 2019
2 parents b878c71 + 2832dc7 commit dfef249
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions code/espurna/light.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit dfef249

Please sign in to comment.