Merge pull request #98 from ghwc2015/master

button press is published on mqtt
This commit is contained in:
Tobias Blum 2018-02-24 23:11:18 +01:00 committed by GitHub
commit 24b5e28950
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -597,9 +597,15 @@ void shortKeyPress() {
if (buttonState == false) { if (buttonState == false) {
setModeByStateString(BTN_MODE_SHORT); setModeByStateString(BTN_MODE_SHORT);
buttonState = true; buttonState = true;
#ifdef ENABLE_MQTT
mqtt_client.publish(mqtt_outtopic, String("OK =static white").c_str());
#endif
} else { } else {
mode = OFF; mode = OFF;
buttonState = false; buttonState = false;
#ifdef ENABLE_MQTT
mqtt_client.publish(mqtt_outtopic, String("OK =off").c_str());
#endif
} }
} }
@ -607,12 +613,20 @@ void shortKeyPress() {
void mediumKeyPress() { void mediumKeyPress() {
DBG_OUTPUT_PORT.printf("Medium button press\n"); DBG_OUTPUT_PORT.printf("Medium button press\n");
setModeByStateString(BTN_MODE_MEDIUM); setModeByStateString(BTN_MODE_MEDIUM);
buttonState = true;
#ifdef ENABLE_MQTT
mqtt_client.publish(mqtt_outtopic, String("OK =fire flicker").c_str());
#endif
} }
// called when button is kept pressed for 2 seconds or more // called when button is kept pressed for 2 seconds or more
void longKeyPress() { void longKeyPress() {
DBG_OUTPUT_PORT.printf("Long button press\n"); DBG_OUTPUT_PORT.printf("Long button press\n");
setModeByStateString(BTN_MODE_LONG); setModeByStateString(BTN_MODE_LONG);
buttonState = true;
#ifdef ENABLE_MQTT
mqtt_client.publish(mqtt_outtopic, String("OK =fireworks random").c_str());
#endif
} }
void button() { void button() {