Добавляем часам способность тикать каждые N секунд и создавать событие

This commit is contained in:
2022-04-26 21:52:32 +03:00
parent 878e71bb36
commit 900ff95429
3 changed files with 7 additions and 3 deletions

View File

@@ -20,7 +20,8 @@
"rst": 16,
"clk": 5,
"dat": 4,
"defFormat": "d-m-Y"
"defFormat": "d-m-Y",
"ticker": 0
},
{
"name": "2. Расширитель портов Mcp23017",

View File

@@ -13,7 +13,7 @@ extern IoTRTC *watch;
class IarduinoRTC : public IoTItem {
private:
int _chipNum, _rst, _clk, _dat;
int _chipNum, _rst, _clk, _dat, _ticker;
String _defFormat;
iarduino_RTC_BASE *RTCDriver;
@@ -25,6 +25,7 @@ class IarduinoRTC : public IoTItem {
jsonRead(parameters, "clk", _clk);
jsonRead(parameters, "dat", _dat);
jsonRead(parameters, "defFormat", _defFormat);
jsonRead(parameters, "ticker", _ticker);
_defFormat = _defFormat + " "; // костыль против обрезки последнего символа в библиотеке
switch (_chipNum) {
@@ -50,6 +51,7 @@ class IarduinoRTC : public IoTItem {
void doByInterval() {
value.isDecimal = false;
value.valS = watch->gettime(_defFormat);
if (_ticker) regEvent(value.valS, "time ticker");
}
IoTValue execute(String command, std::vector<IoTValue> &param) {

View File

@@ -14,6 +14,7 @@
"rst": 16,
"clk": 5,
"dat": 4,
"defFormat": "d-m-Y"
"defFormat": "d-m-Y",
"ticker": 0
}
]