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.
Fork of WIZwiki-7500_Blynk by
WidgetTable.h
00001 /** 00002 * @file WidgetTable.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 Sep 2016 00007 * @brief 00008 * 00009 */ 00010 00011 #ifndef WidgetTable_h 00012 #define WidgetTable_h 00013 00014 #include <Blynk/BlynkWidgetBase.h > 00015 00016 class WidgetTable 00017 : public BlynkWidgetBase 00018 { 00019 public: 00020 typedef void (*ItemSelectChange)(int index, bool selected); 00021 typedef void (*ItemOrderChange)(int indexFrom, int indexTo); 00022 00023 public: 00024 WidgetTable(uint8_t vPin = -1) 00025 : BlynkWidgetBase(vPin) 00026 , mOnOrderChange(NULL) 00027 , mOnSelectChange(NULL) 00028 {} 00029 00030 void onWrite(BlynkReq BLYNK_UNUSED &request, const BlynkParam& param) { 00031 if (mOnOrderChange && 0 == strcmp(param[0].asStr(), "order")) { 00032 mOnOrderChange(param[1].asInt(), param[2].asInt()); 00033 } else if (mOnSelectChange && 0 == strcmp(param[0].asStr(), "select")) { 00034 mOnSelectChange(param[1].asInt(), true); 00035 } else if (mOnSelectChange && 0 == strcmp(param[0].asStr(), "deselect")) { 00036 mOnSelectChange(param[1].asInt(), false); 00037 } 00038 } 00039 00040 void onOrderChange(ItemOrderChange cbk) { mOnOrderChange = cbk; } 00041 void onSelectChange(ItemSelectChange cbk) { mOnSelectChange = cbk; } 00042 00043 void clear() { 00044 Blynk.virtualWrite(mPin, "clr"); 00045 } 00046 00047 template <typename T1, typename T2> 00048 void addRow(int index, const T1& name, const T2& value) { 00049 Blynk.virtualWrite(mPin, "add", index, name, value); 00050 } 00051 00052 template <typename T1, typename T2> 00053 void updateRow(int index, const T1& name, const T2& value) { 00054 Blynk.virtualWrite(mPin, "update", index, name, value); 00055 } 00056 00057 void pickRow(int index) { 00058 Blynk.virtualWrite(mPin, "pick", index); 00059 } 00060 00061 private: 00062 ItemOrderChange mOnOrderChange; 00063 ItemSelectChange mOnSelectChange; 00064 00065 }; 00066 00067 #endif
Generated on Thu Jul 14 2022 00:21:50 by
1.7.2
