Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Blynk_Example_WIZwiki-W7500
Fork of Blynk by
WidgetBridge.h
00001 /** 00002 * @file WidgetBridge.h 00003 * @author Volodymyr Shymanskyy 00004 * @license This project is released under the MIT License (MIT) 00005 * @copyright Copyright (c) 2015 Volodymyr Shymanskyy 00006 * @date Apr 2015 00007 * @brief 00008 * 00009 */ 00010 00011 #ifndef WidgetBridge_h 00012 #define WidgetBridge_h 00013 00014 #include <Blynk/BlynkWidgetBase.h > 00015 00016 class WidgetBridge 00017 : private BlynkWidgetBase 00018 { 00019 public: 00020 WidgetBridge(uint8_t vPin) 00021 : BlynkWidgetBase(vPin) 00022 {} 00023 00024 void setAuthToken(const char* token) { 00025 char mem[BLYNK_MAX_SENDBYTES]; 00026 BlynkParam cmd(mem, 0, sizeof(mem)); 00027 cmd.add(mPin); 00028 cmd.add("i"); 00029 cmd.add(token); 00030 Blynk.sendCmd(BLYNK_CMD_BRIDGE, 0, cmd.getBuffer(), cmd.getLength()-1); 00031 } 00032 00033 template <typename T> 00034 void digitalWrite(const T& pin, int val) { 00035 char mem[BLYNK_MAX_SENDBYTES]; 00036 BlynkParam cmd(mem, 0, sizeof(mem)); 00037 cmd.add(mPin); 00038 cmd.add("dw"); 00039 cmd.add(pin); 00040 cmd.add(val); 00041 Blynk.sendCmd(BLYNK_CMD_BRIDGE, 0, cmd.getBuffer(), cmd.getLength()-1); 00042 } 00043 00044 template <typename T> 00045 void analogWrite(const T& pin, int val) { 00046 char mem[BLYNK_MAX_SENDBYTES]; 00047 BlynkParam cmd(mem, 0, sizeof(mem)); 00048 cmd.add(mPin); 00049 cmd.add("aw"); 00050 cmd.add(pin); 00051 cmd.add(val); 00052 Blynk.sendCmd(BLYNK_CMD_BRIDGE, 0, cmd.getBuffer(), cmd.getLength()-1); 00053 } 00054 00055 template <typename... Args> 00056 void virtualWrite(int pin, Args... values) { 00057 char mem[BLYNK_MAX_SENDBYTES]; 00058 BlynkParam cmd(mem, 0, sizeof(mem)); 00059 cmd.add(mPin); 00060 cmd.add("vw"); 00061 cmd.add(pin); 00062 cmd.add_multi(values...); 00063 Blynk.sendCmd(BLYNK_CMD_BRIDGE, 0, cmd.getBuffer(), cmd.getLength()-1); 00064 } 00065 00066 void virtualWriteBinary(int pin, const void* buff, size_t len) { 00067 char mem[8]; 00068 BlynkParam cmd(mem, 0, sizeof(mem)); 00069 cmd.add(mPin); 00070 cmd.add("vw"); 00071 cmd.add(pin); 00072 Blynk.sendCmd(BLYNK_CMD_BRIDGE, 0, cmd.getBuffer(), cmd.getLength(), buff, len); 00073 } 00074 00075 void virtualWrite(int pin, const BlynkParam& param) { 00076 virtualWriteBinary(pin, param.getBuffer(), param.getLength()-1); 00077 } 00078 00079 }; 00080 00081 #endif
Generated on Tue Jul 12 2022 17:30:45 by
 1.7.2
 1.7.2 
    