Blynk library for embedded hardware. Works with Arduino, ESP8266, Raspberry Pi, Intel Edison/Galileo, LinkIt ONE, Particle Core/Photon, Energia, ARM mbed, etc. http://www.blynk.cc/
Dependents: Blynk_RBL_BLE_Nano Blynk_MicroBit Blynk_Serial Blynk_RBL_BLE_Nano
Diff: Blynk/BlynkHandlers.h
- Revision:
- 9:7369ec77a3ea
- Parent:
- 7:8879692d4e6c
- Child:
- 10:c241e4227173
--- a/Blynk/BlynkHandlers.h Wed Oct 12 10:38:37 2016 +0300 +++ b/Blynk/BlynkHandlers.h Thu Jan 05 14:55:36 2017 +0200 @@ -180,37 +180,30 @@ #define BLYNK_CONNECTED() void BlynkOnConnected() #define BLYNK_DISCONNECTED() void BlynkOnDisconnected() +#define BLYNK_APP_CONNECTED() void BlynkOnAppConnected() + // Advanced functions -class BlynkAttachWidgetHelper { -public: - template<typename T> - explicit BlynkAttachWidgetHelper(T& widget, uint8_t vPin) { - widget.setVPin(vPin); - } -}; - -// Could use __attribute__ ((constructor)), but hope for better portability -#define BLYNK_ATTACH_WIDGET(widget, pin) \ - BlynkAttachWidgetHelper BLYNK_CONCAT2(blnk_widget_helper_, __COUNTER__)((widget), (pin)); \ - BLYNK_WRITE(pin) { (widget).onWrite(request, param); } - -#define BLYNK_VAR_INT(name, pin) int name; \ +#define BLYNK_VAR_INT(name, pin) \ + int name; \ BLYNK_WRITE(pin) { name = param.asInt(); } \ BLYNK_READ(pin) { Blynk.virtualWrite(pin, name); } -#define BLYNK_VAR_LONG(name, pin) long name; \ +#define BLYNK_VAR_LONG(name, pin) \ + long name; \ BLYNK_WRITE(pin) { name = param.asLong(); } \ BLYNK_READ(pin) { Blynk.virtualWrite(pin, name); } #ifndef BLYNK_NO_FLOAT -#define BLYNK_VAR_DOUBLE(name, pin) double name; \ +#define BLYNK_VAR_DOUBLE(name, pin) \ + double name; \ BLYNK_WRITE(pin) { name = param.asDouble(); } \ BLYNK_READ(pin) { Blynk.virtualWrite(pin, name); } #endif #ifdef ARDUINO -#define BLYNK_VAR_STRING(name, pin) String name; \ +#define BLYNK_VAR_STRING(name, pin) \ + String name; \ BLYNK_WRITE(pin) { name = param.asStr(); } \ BLYNK_READ(pin) { Blynk.virtualWrite(pin, name); } #endif @@ -240,6 +233,8 @@ BLYNK_CONNECTED(); BLYNK_DISCONNECTED(); +BLYNK_APP_CONNECTED(); + BLYNK_READ_DEFAULT(); BLYNK_WRITE_DEFAULT();