Позволяем читать объект RTC как переменную с датой и временем по формату из настройки

This commit is contained in:
2022-04-25 23:11:10 +03:00
parent ba824456d4
commit 934173f8cc
3 changed files with 13 additions and 5 deletions

View File

@@ -15,11 +15,12 @@
"widget": "",
"page": "",
"descr": "",
"int": "0",
"int": "1",
"chipNum": 1,
"rst": 16,
"clk": 5,
"dat": 4
"dat": 4,
"defFormat": "d-m-Y"
},
{
"name": "2. Расширитель портов Mcp23017",

View File

@@ -14,6 +14,7 @@ extern IoTRTC *watch;
class IarduinoRTC : public IoTItem {
private:
int _chipNum, _rst, _clk, _dat;
String _defFormat;
iarduino_RTC_BASE *RTCDriver;
public:
@@ -23,6 +24,8 @@ class IarduinoRTC : public IoTItem {
jsonRead(parameters, "rst", _rst);
jsonRead(parameters, "clk", _clk);
jsonRead(parameters, "dat", _dat);
jsonRead(parameters, "defFormat", _defFormat);
_defFormat = _defFormat + " "; // костыль против обрезки последнего символа в библиотеке
switch (_chipNum) {
case 1:
@@ -41,7 +44,10 @@ class IarduinoRTC : public IoTItem {
if (RTCDriver) RTCDriver->begin();
}
void doByInterval() { }
void doByInterval() {
value.isDecimal = false;
value.valS = watch->gettime(_defFormat);
}
IoTValue execute(String command, std::vector<IoTValue> &param) {
if (command == "getTime") {

View File

@@ -9,10 +9,11 @@
"page": "",
"descr": "",
"int": "0",
"int": "1",
"chipNum": 1,
"rst": 16,
"clk": 5,
"dat": 4
"dat": 4,
"defFormat": "d-m-Y"
}
]