diff --git a/src/MyESP.cpp b/src/MyESP.cpp index 87935eac4..b2d031bd1 100644 --- a/src/MyESP.cpp +++ b/src/MyESP.cpp @@ -1228,7 +1228,7 @@ void MyESP::showSystemStats() { } if (_ntp_enabled) { - myDebug_P(PSTR(" [NTP] Time in UTC is %02d:%02d:%02d"), hour(now()), minute(now()), second(now())); + myDebug_P(PSTR(" [NTP] Time in UTC is %02d:%02d:%02d"), to_hour(now()), to_minute(now()), to_second(now())); } #ifdef CRASH @@ -1590,12 +1590,11 @@ bool MyESP::_fs_validateLogFile(const char * filename) { uint16_t char_count = 0; bool abort = false; char char_buffer[MYESP_JSON_LOG_MAXSIZE]; - char c; StaticJsonDocument doc; // eventlog.seek(0); while (eventlog.available() && !abort) { - c = eventlog.read(); // read a char + char c = eventlog.read(); // read a char // see if we have reached the end of the string if (c == '\0' || c == '\n') { @@ -1700,7 +1699,7 @@ bool MyESP::_fs_loadConfig() { // returns true if successful bool MyESP::fs_setSettingValue(char ** setting, const char * value, const char * value_default) { if (*setting == nullptr) { - free(setting); // first free any allocated memory + free(*setting); // first free any allocated memory } if (_hasValue(value)) { @@ -2244,12 +2243,11 @@ void MyESP::_sendEventLog(uint8_t page) { uint8_t line_count = 0; bool abort = false; char char_buffer[MYESP_JSON_LOG_MAXSIZE]; - char c; float pages; // start at top and read until we find the page we want (sets of 10) while (eventlog.available() && !abort) { - c = eventlog.read(); + char c = eventlog.read(); // see if we have reached the end of the string if (c == '\0' || c == '\n') { diff --git a/src/TelnetSpy.cpp b/src/TelnetSpy.cpp index 274749d9d..07b625c7d 100644 --- a/src/TelnetSpy.cpp +++ b/src/TelnetSpy.cpp @@ -242,9 +242,8 @@ size_t TelnetSpy::write(uint8_t data) { sendBlock(); } if (bufUsed == bufLen) { - char c; while (bufUsed > 0) { - c = pullTelnetBuf(); + char c = pullTelnetBuf(); if (c == '\n') { addTelnetBuf('\r'); break; @@ -573,7 +572,7 @@ void TelnetSpy::handle() { return; } if (!listening) { - if ((WiFi.status() == WL_DISCONNECTED) && (WiFi.getMode() & WIFI_AP)) { + if ((WiFi.status() == WL_DISCONNECTED) && (WiFi.getMode() & WIFI_AP)) { if (usedSer) { usedSer->println("[TELNET] in AP mode"); // added by Proddy } diff --git a/src/TimeLib.cpp b/src/TimeLib.cpp index 62da04d5b..e59b24dc2 100644 --- a/src/TimeLib.cpp +++ b/src/TimeLib.cpp @@ -73,7 +73,6 @@ void breakTime(time_t timeInput, tmElements_t & tm) { days -= LEAP_YEAR(year) ? 366 : 365; time -= days; // now it is days in this year, starting at 0 - days = 0; month = 0; monthLength = 0; for (month = 0; month < 12; month++) { @@ -104,36 +103,21 @@ void refreshCache(time_t t) { } } -int day(time_t t) { // the day for the given time (0-6) - refreshCache(t); - return tm.Day; -} - -int month(time_t t) { // the month for the given time - refreshCache(t); - return tm.Month; -} - -int second(time_t t) { // the second for the given time +uint8_t to_second(time_t t) { // the second for the given time refreshCache(t); return tm.Second; } -int minute(time_t t) { // the minute for the given time +uint8_t to_minute(time_t t) { // the minute for the given time refreshCache(t); return tm.Minute; } -int hour(time_t t) { // the hour for the given time +uint8_t to_hour(time_t t) { // the hour for the given time refreshCache(t); return tm.Hour; } -int year(time_t t) { // the year for the given time - refreshCache(t); - return tmYearToCalendar(tm.Year); -} - void setTime(time_t t) { sysTime = (uint32_t)t; nextSyncTime = (uint32_t)t + syncInterval; diff --git a/src/TimeLib.h b/src/TimeLib.h index a827e38f0..0531e270a 100644 --- a/src/TimeLib.h +++ b/src/TimeLib.h @@ -1,5 +1,5 @@ -#ifndef _Time_h -#define _Time_h +#ifndef _TimeLib_h +#define _TimeLib_h #include @@ -27,7 +27,7 @@ typedef struct { uint8_t Day; uint8_t Month; uint8_t Year; // offset from 1970; -} tmElements_t, TimeElements, *tmElementsPtr_t; +} tmElements_t; typedef time_t (*getExternalTime)(); @@ -38,12 +38,8 @@ void setSyncProvider(getExternalTime getTimeFunction); // identify the e void setSyncInterval(time_t interval); // set the number of seconds between re-sync time_t makeTime(const tmElements_t & tm); // convert time elements into time_t -int hour(time_t t); // the hour for the given time -int minute(time_t t); // the minute for the given time -int second(time_t t); // the second for the given time -int day(time_t t); // the day for the given time -int month(time_t t); // the month for the given time -int weekday(time_t t); // the weekday for the given time -int year(time_t t); // the year for the given time +uint8_t to_hour(time_t t); // the hour for the given time +uint8_t to_minute(time_t t); // the minute for the given time +uint8_t to_second(time_t t); // the second for the given time } #endif diff --git a/src/ds18.cpp b/src/ds18.cpp index 0c1ba4985..02d9d7139 100644 --- a/src/ds18.cpp +++ b/src/ds18.cpp @@ -97,8 +97,6 @@ void DS18::loop() { char * DS18::getDeviceString(char * buffer, unsigned char index) { uint8_t size = 128; if (index < _count) { - uint8_t * address = _devices[index].address; - unsigned char chip_id = chip(index); if (chip_id == DS18_CHIP_DS18S20) { strlcpy(buffer, "DS18S20", size); @@ -112,7 +110,8 @@ char * DS18::getDeviceString(char * buffer, unsigned char index) { strlcpy(buffer, "Unknown", size); } -/* + /* + uint8_t * address = _devices[index].address; char a[30] = {0}; snprintf(a, sizeof(a), diff --git a/src/emsuart.cpp b/src/emsuart.cpp index a22c190e3..f40268f71 100644 --- a/src/emsuart.cpp +++ b/src/emsuart.cpp @@ -220,7 +220,7 @@ _EMS_TX_STATUS ICACHE_FLASH_ATTR emsuart_tx_buffer(uint8_t * buf, uint8_t len) { USF(EMSUART_UART) = buf[i]; delayMicroseconds(EMSUART_TX_BRK_WAIT); // https://github.com/proddy/EMS-ESP/issues/23# } - emsuart_tx_brk(); // send + emsuart_tx_brk(); // send } else if (EMS_Sys_Status.emsTxMode == EMS_TXMODE_HT3) { // Junkers logic by @philrich for (uint8_t i = 0; i < len; i++) { TX_PULSE(EMSUART_BIT_TIME / 4);