diff --git a/src/CHANGES.md b/src/CHANGES.md index c3ffee3b1..35fbc3cca 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -1,5 +1,9 @@ # Development Changes +## 0.8.113 - 2024-04-25 +* code cleanup +* fix ESP32-C3 compile + ## 0.8.112 - 2024-04-24 * improved wizard * converted ePaper and Ethernet to hal-SPI diff --git a/src/defines.h b/src/defines.h index 2a4d93067..36919b21b 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 112 +#define VERSION_PATCH 113 //------------------------------------- typedef struct { uint8_t ch; diff --git a/src/hm/hmInverter.h b/src/hm/hmInverter.h index 9ac1cacf6..9aa758787 100644 --- a/src/hm/hmInverter.h +++ b/src/hm/hmInverter.h @@ -84,7 +84,7 @@ struct record_t { byteAssign_t* assign = nullptr; // assignment of bytes in payload uint8_t length = 0; // length of the assignment list T *record = nullptr; // data pointer - uint32_t ts = 0; // timestamp of last received payload + uint32_t ts = 0; // Timestamp of last received payload uint8_t pyldLen = 0; // expected payload length for plausibility check MqttSentStatus mqttSentStatus = MqttSentStatus:: NEW_DATA; // indicates the current MqTT sent status }; @@ -146,7 +146,7 @@ class Inverter { statistics_t radioStatistics; // information about transmitted, failed, ... packets HeuristicInv heuristics; // heuristic information / logic uint8_t curCmtFreq = 0; // current used CMT frequency, used to check if freq. was changed during runtime - uint32_t tsMaxAcPower = 0; // holds the timestamp when the MaxAC power was seen + uint32_t tsMaxAcPower = 0; // holds the Timestamp when the MaxAC power was seen bool commEnabled = true; // 'pause night communication' sets this field to false public: @@ -189,7 +189,7 @@ class Inverter { cb(InverterDevInform_Simple, false); // get hardware version } else if((alarmLastId != alarmMesIndex) && (alarmMesIndex != 0)) { cb(AlarmData, false); // get last alarms - } else if((0 == mGridLen) && generalConfig->readGrid) { // read grid profile + } else if((0 == mGridLen) && GeneralConfig->readGrid) { // read grid profile cb(GridOnProFilePara, false); } else if (mGetLossInterval > AHOY_GET_LOSS_INTERVAL) { // get loss rate mGetLossInterval = 1; @@ -213,7 +213,7 @@ class Inverter { if (getChannelFieldValue(CH0, FLD_PART_NUM, rec) == 0) { cb(0x0f, false); // hard- and firmware version for missing HW part nr, delivered by frame 1 mIvRxCnt +=2; - } else if((getChannelFieldValue(CH0, FLD_GRID_PROFILE_CODE, rec) == 0) && generalConfig->readGrid) // read grid profile + } else if((getChannelFieldValue(CH0, FLD_GRID_PROFILE_CODE, rec) == 0) && GeneralConfig->readGrid) // read grid profile cb(0x10, false); // legacy GPF command } } @@ -270,16 +270,18 @@ class Inverter { if(InverterStatus::OFF != status) { mDevControlRequest = true; devControlCmd = cmd; - //assert(App); - //App->triggerTickSend(0); + assert(App); + App->triggerTickSend(id); + return true; } - return (InverterStatus::OFF != status); + return false; } bool setDevCommand(uint8_t cmd) { - if(InverterStatus::OFF != status) + bool retval = (InverterStatus::OFF != status); + if(retval) devControlCmd = cmd; - return (InverterStatus::OFF != status); + return retval; } void addValue(uint8_t pos, const uint8_t buf[], record_t<> *rec) { @@ -409,14 +411,14 @@ class Inverter { if(recordMeas.ts == 0) return false; - if(((*timestamp) - recordMeas.ts) < INVERTER_INACT_THRES_SEC) + if(((*Timestamp) - recordMeas.ts) < INVERTER_INACT_THRES_SEC) avail = true; if(avail) { if(status < InverterStatus::PRODUCING) status = InverterStatus::STARTING; } else { - if(((*timestamp) - recordMeas.ts) > INVERTER_OFF_THRES_SEC) { + if(((*Timestamp) - recordMeas.ts) > INVERTER_OFF_THRES_SEC) { if(status != InverterStatus::OFF) { status = InverterStatus::OFF; actPowerLimit = 0xffff; // power limit will be read once inverter becomes available @@ -817,8 +819,8 @@ class Inverter { } public: - static uint32_t *timestamp; // system timestamp - static cfgInst_t *generalConfig; // general inverter configuration from setup + static uint32_t *Timestamp; // system timestamp + static cfgInst_t *GeneralConfig; // general inverter configuration from setup static IApp *App; uint16_t mDtuRxCnt = 0; @@ -837,9 +839,9 @@ class Inverter { }; template -uint32_t *Inverter::timestamp {0}; +uint32_t *Inverter::Timestamp {0}; template -cfgInst_t *Inverter::generalConfig {0}; +cfgInst_t *Inverter::GeneralConfig {0}; template IApp *Inverter::App {nullptr}; @@ -948,7 +950,7 @@ T calcMaxPowerAcCh0(Inverter<> *iv, uint8_t arg0) { } } if(acPower > acMaxPower) { - iv->tsMaxAcPower = *iv->timestamp; + iv->tsMaxAcPower = *iv->Timestamp; return acPower; } } diff --git a/src/hm/hmSystem.h b/src/hm/hmSystem.h index 28c7905ac..0e86881d7 100644 --- a/src/hm/hmSystem.h +++ b/src/hm/hmSystem.h @@ -16,8 +16,8 @@ class HmSystem { HmSystem() {} void setup(uint32_t *timestamp, cfgInst_t *config, IApp *app) { - INVERTERTYPE::timestamp = timestamp; - INVERTERTYPE::generalConfig = config; + INVERTERTYPE::Timestamp = timestamp; + INVERTERTYPE::GeneralConfig = config; INVERTERTYPE::App = app; //mInverter[0].app = app; } @@ -26,7 +26,7 @@ class HmSystem { DPRINTLN(DBG_VERBOSE, F("hmSystem.h:addInverter")); INVERTERTYPE *iv = &mInverter[id]; iv->id = id; - iv->config = &mInverter[0].generalConfig->iv[id]; + iv->config = &INVERTERTYPE::GeneralConfig->iv[id]; DPRINT(DBG_VERBOSE, "SERIAL: " + String(iv->config->serial.b[5], HEX)); DPRINTLN(DBG_VERBOSE, " " + String(iv->config->serial.b[4], HEX)); if((iv->config->serial.b[5] == 0x11) || (iv->config->serial.b[5] == 0x10)) { diff --git a/src/hm/nrfHal.h b/src/hm/nrfHal.h index a92285438..a838f8bcd 100644 --- a/src/hm/nrfHal.h +++ b/src/hm/nrfHal.h @@ -42,7 +42,7 @@ class nrfHal: public RF24_hal, public SpiPatcherHandle { #if defined(CONFIG_IDF_TARGET_ESP32S3) mHostDevice = SPI2_HOST; #else - mHostDevice = (14 == sclk) ? SPI2_HOST : SPI3_HOST; + mHostDevice = (14 == sclk) ? SPI2_HOST : SPI_HOST_OTHER; #endif mSpiPatcher = SpiPatcher::getInstance(mHostDevice); diff --git a/src/hms/cmtHal.h b/src/hms/cmtHal.h index 13a14950e..8556a0434 100644 --- a/src/hms/cmtHal.h +++ b/src/hms/cmtHal.h @@ -40,7 +40,7 @@ class cmtHal : public SpiPatcherHandle { #if defined(CONFIG_IDF_TARGET_ESP32S3) mHostDevice = SPI2_HOST; #else - mHostDevice = (14 == clk) ? SPI2_HOST : SPI3_HOST; + mHostDevice = (14 == clk) ? SPI2_HOST : SPI_HOST_OTHER; #endif mSpiPatcher = SpiPatcher::getInstance(mHostDevice); diff --git a/src/plugins/Display/epdHal.h b/src/plugins/Display/epdHal.h index e998a8855..1718b8385 100644 --- a/src/plugins/Display/epdHal.h +++ b/src/plugins/Display/epdHal.h @@ -11,6 +11,7 @@ #include #include + #define EPD_DEFAULT_SPI_SPEED 4000000 // 4 MHz class epdHal: public GxEPD2_HalInterface, public SpiPatcherHandle { @@ -41,7 +42,7 @@ class epdHal: public GxEPD2_HalInterface, public SpiPatcherHandle { #if defined(CONFIG_IDF_TARGET_ESP32S3) mHostDevice = SPI3_HOST; #else - mHostDevice = (14 == sclk) ? SPI2_HOST : SPI3_HOST; + mHostDevice = (14 == sclk) ? SPI2_HOST : SPI_HOST_OTHER; #endif mSpiPatcher = SpiPatcher::getInstance(mHostDevice); diff --git a/src/utils/spiPatcher.h b/src/utils/spiPatcher.h index bb14a1659..c8f0ba3cb 100644 --- a/src/utils/spiPatcher.h +++ b/src/utils/spiPatcher.h @@ -15,6 +15,12 @@ #include #include +#if (SOC_SPI_PERIPH_NUM > 2) + #define SPI_HOST_OTHER SPI3_HOST +#else + #define SPI_HOST_OTHER SPI2_HOST +#endif + class SpiPatcher { protected: explicit SpiPatcher(spi_host_device_t dev) : @@ -74,8 +80,10 @@ class SpiPatcher { assert(mBusState == ESP_OK); if(SPI2_HOST == host_id) mHost2Cnt++; + #if (SOC_SPI_PERIPH_NUM > 2) if(SPI3_HOST == host_id) mHost3Cnt++; + #endif if((mHost2Cnt > 3) || (mHost3Cnt > 3)) DPRINTLN(DBG_ERROR, F("maximum number of SPI devices reached (3)")); @@ -112,7 +120,7 @@ class SpiPatcher { SemaphoreHandle_t mutex; StaticSemaphore_t mutex_buffer; uint8_t mHost2Cnt = 0, mHost3Cnt = 0; - spi_host_device_t mDev = SPI3_HOST; + spi_host_device_t mDev = SPI2_HOST; esp_err_t mBusState = ESP_FAIL; spi_bus_config_t mBusConfig; }; diff --git a/src/web/RestApi.h b/src/web/RestApi.h index 188afe233..ed1aac756 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -1014,8 +1014,6 @@ class RestApi { iv->powerLimit[1] = AbsolutNonPersistent; accepted = iv->setDevControlRequest(ActivePowerContr); - if(accepted) - mApp->triggerTickSend(iv->id); } else if(F("dev") == jsonIn[F("cmd")]) { DPRINTLN(DBG_INFO, F("dev cmd")); iv->setDevCommand(jsonIn[F("val")].as());