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.
WidgetLED.h
00001 /** 00002 * @file WidgetLED.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 #ifndef WidgetLED_h 00011 #define WidgetLED_h 00012 00013 #include <Blynk/BlynkApi.h> 00014 00015 class WidgetLED 00016 { 00017 public: 00018 WidgetLED(uint8_t pin) : mPin(pin) {} 00019 void setVPin(int vPin) { mPin = vPin; } 00020 00021 #ifdef BLYNK_EXPERIMENTAL 00022 00023 void setRGB(uint8_t r, uint8_t g, uint8_t b) { 00024 char mem[64] = ""; 00025 BlynkParam cmd(mem, 0, sizeof(mem)); 00026 cmd.add("rgb"); 00027 cmd.add(r); 00028 cmd.add(g); 00029 cmd.add(b); 00030 Blynk.virtualWrite(mPin, cmd); 00031 } 00032 00033 void setHSV(uint8_t h, uint8_t s, uint8_t v) { 00034 char mem[64] = ""; 00035 BlynkParam cmd(mem, 0, sizeof(mem)); 00036 cmd.add("hsv"); 00037 cmd.add(h); 00038 cmd.add(s); 00039 cmd.add(v); 00040 Blynk.virtualWrite(mPin, cmd); 00041 } 00042 00043 #endif 00044 00045 uint8_t getValue() const { 00046 return mValue; 00047 } 00048 00049 void setValue(uint8_t value) { 00050 mValue = value; 00051 Blynk.virtualWrite(mPin, value); 00052 } 00053 00054 void on() { 00055 setValue(255); 00056 } 00057 00058 void off() { 00059 setValue(0); 00060 } 00061 00062 private: 00063 uint8_t mPin; 00064 uint8_t mValue; 00065 }; 00066 00067 #endif 00068
Generated on Tue Jul 12 2022 13:01:30 by
1.7.2