mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Позволяем читать объект RTC как переменную с датой и временем по формату из настройки
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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> ¶m) {
|
||||
if (command == "getTime") {
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
"page": "",
|
||||
"descr": "",
|
||||
|
||||
"int": "0",
|
||||
"int": "1",
|
||||
"chipNum": 1,
|
||||
"rst": 16,
|
||||
"clk": 5,
|
||||
"dat": 4
|
||||
"dat": 4,
|
||||
"defFormat": "d-m-Y"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user