2018-07-16 11:50:09 +02:00
|
|
|
/*
|
|
|
|
* Remote light control with the free Blynk app
|
|
|
|
*/
|
|
|
|
|
|
|
|
uint16_t blHue = 0;
|
|
|
|
byte blSat = 255;
|
|
|
|
|
|
|
|
void initBlynk(const char* auth)
|
|
|
|
{
|
2018-11-01 15:36:13 +01:00
|
|
|
#ifndef WLED_DISABLE_BLYNK
|
2018-07-16 11:50:09 +02:00
|
|
|
if (WiFi.status() != WL_CONNECTED) return;
|
|
|
|
blynkEnabled = (auth[0] != 0);
|
|
|
|
if (blynkEnabled) Blynk.config(auth);
|
2018-11-01 15:36:13 +01:00
|
|
|
#endif
|
2018-07-16 11:50:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void handleBlynk()
|
|
|
|
{
|
2018-11-01 15:36:13 +01:00
|
|
|
#ifndef WLED_DISABLE_BLYNK
|
2018-07-16 11:50:09 +02:00
|
|
|
if (WiFi.status() == WL_CONNECTED && blynkEnabled)
|
|
|
|
Blynk.run();
|
2018-11-01 15:36:13 +01:00
|
|
|
#endif
|
2018-07-16 11:50:09 +02:00
|
|
|
}
|
|
|
|
|
2018-07-29 14:03:02 +02:00
|
|
|
void updateBlynk()
|
|
|
|
{
|
2018-11-01 15:36:13 +01:00
|
|
|
#ifndef WLED_DISABLE_BLYNK
|
2018-10-04 18:17:01 +02:00
|
|
|
if (onlyAP) return;
|
2018-10-08 17:36:22 +02:00
|
|
|
Blynk.virtualWrite(V0, bri);
|
2018-07-29 14:03:02 +02:00
|
|
|
//we need a RGB -> HSB convert here
|
2018-10-08 17:36:22 +02:00
|
|
|
Blynk.virtualWrite(V3, bri? 1:0);
|
|
|
|
Blynk.virtualWrite(V4, effectCurrent);
|
|
|
|
Blynk.virtualWrite(V5, effectSpeed);
|
|
|
|
Blynk.virtualWrite(V6, effectIntensity);
|
|
|
|
Blynk.virtualWrite(V7, nightlightActive);
|
|
|
|
Blynk.virtualWrite(V8, notifyDirect);
|
2018-11-01 15:36:13 +01:00
|
|
|
#endif
|
2018-07-29 14:03:02 +02:00
|
|
|
}
|
|
|
|
|
2018-11-01 15:36:13 +01:00
|
|
|
#ifndef WLED_DISABLE_BLYNK
|
2018-07-16 11:50:09 +02:00
|
|
|
BLYNK_WRITE(V0)
|
|
|
|
{
|
2018-11-09 17:00:36 +01:00
|
|
|
bri = param.asInt();//bri
|
|
|
|
colorUpdated(9);
|
2018-07-16 11:50:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BLYNK_WRITE(V1)
|
|
|
|
{
|
2018-11-09 17:00:36 +01:00
|
|
|
blHue = param.asInt();//hue
|
|
|
|
colorHStoRGB(blHue*10,blSat,(false)? colSec:col);
|
|
|
|
colorUpdated(9);
|
2018-07-16 11:50:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BLYNK_WRITE(V2)
|
|
|
|
{
|
2018-11-09 17:00:36 +01:00
|
|
|
blSat = param.asInt();//sat
|
|
|
|
colorHStoRGB(blHue*10,blSat,(false)? colSec:col);
|
|
|
|
colorUpdated(9);
|
2018-07-16 11:50:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BLYNK_WRITE(V3)
|
|
|
|
{
|
2019-02-16 00:21:22 +01:00
|
|
|
handleSet(nullptr, (param.asInt()>0)?"win&T=1&IN":"win&T=0&IN");//power
|
2018-07-16 11:50:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BLYNK_WRITE(V4)
|
|
|
|
{
|
2018-11-09 17:00:36 +01:00
|
|
|
effectCurrent = param.asInt()-1;//fx
|
2018-11-24 11:52:23 +01:00
|
|
|
colorUpdated(9);
|
2018-07-16 11:50:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BLYNK_WRITE(V5)
|
|
|
|
{
|
2018-11-09 17:00:36 +01:00
|
|
|
effectSpeed = param.asInt();//sx
|
2018-11-24 11:52:23 +01:00
|
|
|
colorUpdated(9);
|
2018-07-16 11:50:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BLYNK_WRITE(V6)
|
|
|
|
{
|
2018-11-09 17:00:36 +01:00
|
|
|
effectIntensity = param.asInt();//ix
|
2018-11-24 11:52:23 +01:00
|
|
|
colorUpdated(9);
|
2018-07-16 11:50:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BLYNK_WRITE(V7)
|
|
|
|
{
|
2019-02-16 00:21:22 +01:00
|
|
|
handleSet(nullptr, (param.asInt()>0)?"win&ND&IN":"win&NL=0&IN");//nl
|
2018-07-16 11:50:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BLYNK_WRITE(V8)
|
|
|
|
{
|
|
|
|
notifyDirect = (param.asInt()>0); //send notifications
|
|
|
|
}
|
2018-11-01 15:36:13 +01:00
|
|
|
#endif
|