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
BlynkWidgetBase.h
00001 /** 00002 * @file BlynkWidgetBase.h 00003 * @author Volodymyr Shymanskyy 00004 * @license This project is released under the MIT License (MIT) 00005 * @copyright Copyright (c) 2016 Volodymyr Shymanskyy 00006 * @date Nov 2016 00007 * @brief 00008 */ 00009 00010 #ifndef BlynkWidgetBase_h 00011 #define BlynkWidgetBase_h 00012 00013 #include <Blynk/BlynkApi.h> 00014 00015 class BlynkWidgetBase 00016 { 00017 public: 00018 BlynkWidgetBase(uint8_t vPin) : mPin(vPin) {} 00019 void setVPin(uint8_t vPin) { mPin = vPin; } 00020 00021 void onWrite(BlynkReq BLYNK_UNUSED &request, const BlynkParam BLYNK_UNUSED ¶m) { 00022 BLYNK_LOG1(BLYNK_F("BlynkWidgetBase::onWrite should not be called")); 00023 } 00024 00025 template<typename... Args> 00026 void setLabel(Args... args) { 00027 Blynk.setProperty(mPin, "label", args...); 00028 } 00029 00030 template<typename... Args> 00031 void setColor(Args... args) { 00032 Blynk.setProperty(mPin, "color", args...); 00033 } 00034 00035 protected: 00036 uint8_t mPin; 00037 }; 00038 00039 class BlynkAttachWidgetHelper { 00040 public: 00041 template<typename T> 00042 explicit BlynkAttachWidgetHelper(T& widget, uint8_t vPin) { 00043 widget.setVPin(vPin); 00044 } 00045 }; 00046 00047 // Could use __attribute__ ((constructor)), but hope for better portability 00048 #define BLYNK_ATTACH_WIDGET(widget, pin) \ 00049 BlynkAttachWidgetHelper BLYNK_CONCAT2(blnk_widget_helper_, __COUNTER__)((widget), (pin)); \ 00050 BLYNK_WRITE(pin) { (widget).onWrite(request, param); } 00051 00052 #endif
Generated on Tue Jul 12 2022 15:11:12 by 1.7.2