удаление часов реального времени

This commit is contained in:
Dmitry Borisenko
2022-08-12 22:13:50 +02:00
parent ca95a4528d
commit d22580aac9
17 changed files with 278 additions and 387 deletions

106
training/IarduinoRTC.cpp Normal file
View File

@@ -0,0 +1,106 @@
//#include "Global.h"
//#include "classes/IoTItem.h"
//
//#include <iarduino_RTC.h>
//#include "iarduino_RTC_DS1302.h" // Подключаем файл iarduino_RTC_DS1302.h
//#include "iarduino_RTC_DS1307.h" // Подключаем файл iarduino_RTC_DS1307.h
//#include "iarduino_RTC_DS3231.h" // Подключаем файл iarduino_RTC_DS3231.h
//#include "iarduino_RTC_RX8025.h"
//
// class IarduinoRTC : public IoTItem {
// private:
// int _chipNum, _rst, _clk, _dat, _ticker;
// String _defFormat;
// iarduino_RTC_BASE* RTCDriver;
//
// public:
// IarduinoRTC(String parameters) : IoTItem(parameters) {
// jsonRead(parameters, "chipNum", _chipNum);
// jsonRead(parameters, "rst", _rst);
// jsonRead(parameters, "clk", _clk);
// jsonRead(parameters, "dat", _dat);
// jsonRead(parameters, "defFormat", _defFormat);
// jsonRead(parameters, "ticker", _ticker);
//
// switch (_chipNum) {
// case 0:
// RTCDriver = new iarduino_RTC_NTP();
// break;
// case 1:
// RTCDriver = new iarduino_RTC_DS1302(_rst, _clk, _dat);
// break;
// case 2:
// RTCDriver = new iarduino_RTC_DS1307();
// break;
// case 3:
// RTCDriver = new iarduino_RTC_DS3231();
// break;
// case 4:
// RTCDriver = new iarduino_RTC_RX8025();
// break;
// }
// if (RTCDriver) RTCDriver->begin();
// }
//
// void doByInterval() {
// value.isDecimal = false;
// value.valS = watch->gettime(_defFormat.c_str());
// if (_ticker) regEvent(value.valS, "time ticker");
// }
//
// IoTValue execute(String command, std::vector<IoTValue>& param) {
// IoTValue tmpValue;
// if (command == "getTime") {
// if (param.size()) {
// tmpValue.isDecimal = false;
// tmpValue.valS = watch->gettime(param[0].valS.c_str());
// return tmpValue;
// }
// } else if (command == "saveSysTime") {
// tm localTimeVar;
// time_t timeNowVar;
// time(&timeNowVar);
// localTimeVar = *localtime(&timeNowVar);
// watch->settime(localTimeVar.tm_sec, localTimeVar.tm_min, localTimeVar.tm_hour, localTimeVar.tm_mday, localTimeVar.tm_mon + 1, localTimeVar.tm_year - 100, localTimeVar.tm_wday);
// } else if (command == "setTime") {
// if (param.size()) {
// watch->settime(param[0].valD, param[1].valD, param[2].valD, param[3].valD, param[4].valD, param[5].valD, param[6].valD);
// }
// } else if (command == "setUnixTime") {
// if (param.size()) {
// watch->settimeUnix(param[0].valD);
// }
// } else if (command == "getHours") {
// tmpValue.valD = watch->Hours; // Часы 0-23
// return tmpValue;
// } else if (command == "getMinutes") {
// tmpValue.valD = watch->minutes; // Минуты 0-59
// return tmpValue;
// } else if (command == "getSeconds") {
// tmpValue.valD = watch->seconds; // Секунды 0-59
// return tmpValue;
// } else if (command == "getMonth") {
// tmpValue.valD = watch->month; // Месяц 1-12
// return tmpValue;
// } else if (command == "getDay") {
// tmpValue.valD = watch->day; // День месяца 1-31
// return tmpValue;
// }
//
// return {};
// }
//
// iarduino_RTC_BASE* getRtcDriver() {
// return RTCDriver;
// }
//
// ~IarduinoRTC(){};
//};
//
// void* getAPI_IarduinoRTC(String subtype, String param) {
// if (subtype == F("IarduinoRTC")) {
// return new IarduinoRTC(param);
// } else {
// return nullptr;
// }
//}

45
training/IoTRTC.cpp Normal file
View File

@@ -0,0 +1,45 @@
//#include "classes/IoTRTC.h"
//
// IoTRTC::~IoTRTC() {
//
//}
//
//
// iarduino_RTC_NTP::iarduino_RTC_NTP() {
//
//}
//
// void iarduino_RTC_NTP::begin(void) {
//
//}
//
// uint8_t iarduino_RTC_NTP::funcReadTimeIndex(uint8_t i) {
// static tm localTimeVar;
// if (i == 0) {
// Serial.println(F("Read time from system."));
// time_t timeNowVar;
// time(&timeNowVar);
// localTimeVar = *localtime(&timeNowVar);
// }
//
// switch (i)
// {
// case 0: return funcConvertNumToCode(localTimeVar.tm_sec);
// case 1: return funcConvertNumToCode(localTimeVar.tm_min);
// case 2: return funcConvertNumToCode(localTimeVar.tm_hour);
// case 3: return funcConvertNumToCode(localTimeVar.tm_mday);
// case 4: return funcConvertNumToCode(localTimeVar.tm_mon+1);
// case 5: return funcConvertNumToCode(localTimeVar.tm_year-100);
// case 6: return funcConvertNumToCode(localTimeVar.tm_wday);
// }
//
// return 0;
//}
//
// void iarduino_RTC_NTP::funcWriteTimeIndex(uint8_t i, uint8_t j) {
//
//}
//
// iarduino_RTC_NTP::~iarduino_RTC_NTP() {
//
//}

22
training/IoTRTC.h Normal file
View File

@@ -0,0 +1,22 @@
//#pragma once
//#include <Arduino.h>
//#include <iarduino_RTC.h>
//
// class iarduino_RTC_NTP: public iarduino_RTC_BASE {
// public:
// iarduino_RTC_NTP();
// ~iarduino_RTC_NTP();
// void begin(void);
// uint8_t funcReadTimeIndex(uint8_t i);
// void funcWriteTimeIndex(uint8_t i, uint8_t j);
// uint8_t funcConvertNumToCode (uint8_t i) {return ((i/10) << 4) + (i%10);}
//};
//
// class IoTRTC : public iarduino_RTC {
// public:
// IoTRTC(uint8_t i, uint8_t j=SS, uint8_t k=SCK, uint8_t n=MOSI) : iarduino_RTC(i, j, k, n) {
// if (i == 0) objClass = new iarduino_RTC_NTP();
// };
//
// ~IoTRTC();
//};