diff --git a/PrepareProject.py b/PrepareProject.py index 2f8c1241..11eda3f5 100644 --- a/PrepareProject.py +++ b/PrepareProject.py @@ -182,7 +182,8 @@ with open("data_svelte/settings.json", "w", encoding='utf-8') as write_file: # параллельно собираем необходимые активным модулям библиотеки для включения в компиляцию для текущего типа устройства (esp8266_4m, esp32_4mb, esp8266_1m, esp8266_1m_ota) activeModulesName = [] # список имен активных модулей allLibs = "" # подборка всех библиотек необходимых модулям для дальнейшей записи в конфигурацию platformio -itemsCount = 1; +allDefs = "\n" # для каждого модуля создаем глобальный define +itemsCount = 1 includeDirs = "" # подборка путей ко всем модулям для дальнейшей записи в конфигурацию platformio itemsJson = json.loads('[{"name": "Выберите элемент", "num": 0}]') for section, modules in profJson['modules'].items(): @@ -191,6 +192,8 @@ for section, modules in profJson['modules'].items(): if module['active']: with open(module['path'] + "/modinfo.json", "r", encoding='utf-8') as read_file: moduleJson = json.load(read_file) + if 'moduleDefines' in moduleJson['about']: + allDefs = allDefs + "\n".join("-D" + d for d in moduleJson['about']['moduleDefines']) if deviceName in moduleJson['usedLibs']: # проверяем поддерживает ли модуль текущее устройство if not 'exclude' in moduleJson['usedLibs'][deviceName]: # смотрим не нужно ли исключить данный модуль из указанной платы deviceName activeModulesName.append(moduleJson['about']['moduleName']) # запоминаем имена для использования на след шагах @@ -250,7 +253,10 @@ config.clear() config.read("platformio.ini") config["env:" + deviceName + "_fromitems"]["lib_deps"] = allLibs config["env:" + deviceName + "_fromitems"]["build_src_filter"] = includeDirs +config["env:" + deviceName + "_fromitems"]["build_flags"] = allDefs config["platformio"]["default_envs"] = deviceName +if "${env:" + deviceName + "_fromitems.build_flags}" not in config["env:" + deviceName]["build_flags"]: + config["env:" + deviceName]["build_flags"] += "\n${env:" + deviceName + "_fromitems.build_flags}" # config["platformio"]["data_dir"] = profJson['projectProp']['platformio']['data_dir'] with open("platformio.ini", 'w') as configFile: config.write(configFile) @@ -284,4 +290,4 @@ else: # print(f"\x1b[1;32;41m Операция завершена. \x1b[0m") - \ No newline at end of file + diff --git a/include/Global.h b/include/Global.h index 278630f0..11c31daa 100644 --- a/include/Global.h +++ b/include/Global.h @@ -66,7 +66,9 @@ *****************************************глобальные объекты классов*************************************************** **********************************************************************************************************************/ extern IoTGpio IoTgpio; +#ifdef mod_RtcDriver extern IoTItem* rtcItem; +#endif //extern IoTItem* camItem; extern IoTItem* tlgrmItem; extern IoTBench* benchLoadItem; diff --git a/include/classes/IoTItem.h b/include/classes/IoTItem.h index 0c9be041..012c920d 100644 --- a/include/classes/IoTItem.h +++ b/include/classes/IoTItem.h @@ -55,7 +55,6 @@ class IoTItem { bool enableDoByInt = true; virtual IoTGpio* getGpioDriver(); - virtual IoTItem* getRtcDriver(); //virtual IoTItem* getCAMDriver(); virtual IoTItem* getTlgrmDriver(); //virtual IoTBench* getBenchmark(); @@ -63,8 +62,10 @@ class IoTItem { virtual IoTBench* getBenchmarkLoad(); virtual IoTDiscovery* getHADiscovery(); virtual IoTDiscovery* getHOMEdDiscovery(); +#ifdef mod_RtcDriver + virtual IoTItem* getRtcDriver(); virtual unsigned long getRtcUnixTime(); - +#endif // делаем доступным модулям отправку сообщений в телеграм virtual void sendTelegramMsg(bool often, String msg); virtual void sendFoto(uint8_t *buf, uint32_t length, const String &name); diff --git a/platformio.ini b/platformio.ini index 07ff82ef..a30c681f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -18,6 +18,7 @@ lib_deps = lib_ignore = LT_WebSockets build_flags = -Desp8266_1mb_ota="esp8266_1mb_ota" + ${env:esp8266_1mb_ota_fromitems.build_flags} framework = arduino board = nodemcuv2 board_build.ldscript = eagle.flash.1m64.ld @@ -41,6 +42,7 @@ lib_deps = lib_ignore = LT_WebSockets build_flags = -Desp8266_1mb="esp8266_1mb" + ${env:esp8266_1mb_fromitems.build_flags} framework = arduino board = nodemcuv2 board_build.ldscript = eagle.flash.1m256.ld @@ -64,6 +66,7 @@ lib_deps = lib_ignore = LT_WebSockets build_flags = -Desp8266_1mb_ota="esp8266_1mb_ota" + ${env:esp8285_1mb_ota_fromitems.build_flags} framework = arduino board = esp8285 board_build.ldscript = eagle.flash.1m64.ld @@ -87,6 +90,7 @@ lib_deps = lib_ignore = LT_WebSockets build_flags = -Desp8266_2mb="esp8266_2mb" + ${env:esp8266_2mb_fromitems.build_flags} framework = arduino board = d1_wroom_02 board_build.ldscript = eagle.flash.2m1m.ld @@ -110,6 +114,7 @@ lib_deps = lib_ignore = LT_WebSockets build_flags = -Desp8266_2mb_ota="esp8266_2mb_ota" + ${env:esp8266_2mb_ota_fromitems.build_flags} framework = arduino board = d1_wroom_02 board_build.ldscript = eagle.flash.2m256.ld @@ -133,6 +138,7 @@ lib_deps = lib_ignore = LT_WebSockets build_flags = -Desp8266_1mb="esp8266_1mb" + ${env:esp8285_1mb_fromitems.build_flags} framework = arduino board = esp8285 board_build.ldscript = eagle.flash.1m256.ld @@ -156,6 +162,7 @@ lib_deps = lib_ignore = LT_WebSockets build_flags = -Desp8266_4mb="esp8266_4mb" + ${env:esp8266_4mb_fromitems.build_flags} framework = arduino board = nodemcuv2 board_build.ldscript = eagle.flash.4m1m.ld @@ -180,6 +187,7 @@ lib_deps = lib_ignore = LT_WebSockets build_flags = -Desp8266_16mb="esp8266_16mb" + ${env:esp8266_16mb_fromitems.build_flags} framework = arduino board = nodemcuv2 platform = espressif8266 @4.0.1 @@ -204,6 +212,7 @@ lib_ignore = LT_WebSockets build_flags = -Desp32_4mb="esp32_4mb" -Wl,--wrap=esp_panic_handler + ${env:esp32_4mb_fromitems.build_flags} framework = arduino board = esp32dev platform = espressif32 @6.6.0 @@ -228,6 +237,7 @@ lib_ignore = LT_WebSockets build_flags = -Desp32_4mb3f="esp32_4mb3f" -Wl,--wrap=esp_panic_handler + ${env:esp32_4mb3f_fromitems.build_flags} framework = arduino board = esp32dev platform = espressif32 @6.6.0 @@ -255,6 +265,7 @@ build_flags = -DBOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -Wl,--wrap=esp_panic_handler + ${env:esp32cam_4mb_fromitems.build_flags} framework = arduino board = esp32cam platform = espressif32 @6.6.0 @@ -281,6 +292,7 @@ build_flags = -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=0 -Wl,--wrap=esp_panic_handler + ${env:esp32s2_4mb_fromitems.build_flags} framework = arduino board = lolin_s2_mini platform = espressif32 @6.6.0 @@ -305,6 +317,7 @@ lib_ignore = LT_WebSockets build_flags = -Desp32c3m_4mb="esp32c3m_4mb" -Wl,--wrap=esp_panic_handler + ${env:esp32c3m_4mb_fromitems.build_flags} framework = arduino board = lolin_c3_mini platform = espressif32 @6.6.0 @@ -330,6 +343,7 @@ lib_ignore = LT_WebSockets build_flags = -Desp32s3_16mb="esp32s3_16mb" -Wl,--wrap=esp_panic_handler + ${env:esp32s3_16mb_fromitems.build_flags} framework = arduino board = esp32-s3-devkitc-1 board_build.mcu = esp32s3 @@ -357,6 +371,7 @@ lib_ignore = LT_WebSockets build_flags = -Desp32_16mb="esp32_16mb" -Wl,--wrap=esp_panic_handler + ${env:esp32_16mb_fromitems.build_flags} framework = arduino board = esp32dev platform = espressif32 @6.6.0 @@ -383,6 +398,7 @@ lib_ignore = LT_WebSockets build_flags = -Desp32_wifirep="esp32_wifirep" -Wl,--wrap=esp_panic_handler + ${env:esp32_wifirep_fromitems.build_flags} framework = arduino board = esp32dev platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.5.3/platform-espressif32-2.0.5.3.zip @@ -410,6 +426,7 @@ build_flags = -DARDUINO_USB_CDC_ON_BOOT=0 -DARDUINO_USB_MODE=0 -Wl,--wrap=esp_panic_handler + ${env:esp32c6_4mb_fromitems.build_flags} framework = arduino board = esp32-c6-devkitm-1 platform = espressif32 @6.9.0 @@ -440,6 +457,7 @@ build_flags = -DARDUINO_USB_CDC_ON_BOOT=0 -DARDUINO_USB_MODE=0 -Wl,--wrap=esp_panic_handler + ${env:esp32c6_8mb_fromitems.build_flags} framework = arduino board = esp32-c6-devkitm-1 platform = espressif32 @6.9.0 @@ -488,6 +506,7 @@ build_flags = -DNODEBUG_WEBSOCKETS=1 -DLT_UART_DEFAULT_PORT=1 -DUPLOAD_PORT=auto + ${env:bk7231n_fromitems.build_flags} build_src_filter = +<*.cpp> + @@ -777,7 +796,7 @@ lib_deps = adafruit/Adafruit BME280 Library adafruit/Adafruit BMP280 Library beegee-tokyo/DHT sensor library for ESPx - https://github.com/milesburton/Arduino-Temperature-Control-Library + milesburton/DallasTemperature @ ^4.0.4 plerup/EspSoftwareSerial gyverlibs/EncButton @ ^2.0 build_src_filter = @@ -805,12 +824,14 @@ build_src_filter = + + + - + + + + + + +build_flags = + -Dmod_RtcDriver + -DhardRTC=1 [env:esp32cam_4mb_fromitems] lib_deps = diff --git a/src/ESPConfiguration.cpp b/src/ESPConfiguration.cpp index af81f47c..83984386 100644 --- a/src/ESPConfiguration.cpp +++ b/src/ESPConfiguration.cpp @@ -35,8 +35,10 @@ void configure(String path) { void* driver; // пробуем спросить драйвер GPIO if (driver = myIoTItem->getGpioDriver()) IoTgpio.regDriver((IoTGpio*)driver); +#ifdef mod_RtcDriver // пробуем спросить драйвер RTC if (driver = myIoTItem->getRtcDriver()) rtcItem = (IoTItem*)driver; +#endif // пробуем спросить драйвер CAM //if (driver = myIoTItem->getCAMDriver()) camItem = (IoTItem*)driver; // пробуем спросить драйвер Benchmark @@ -78,11 +80,12 @@ void configure(String path) { void clearConfigure() { Serial.printf("Start clearing config\n"); +#ifdef mod_RtcDriver rtcItem = nullptr; +#endif //camItem = nullptr; tlgrmItem = nullptr; IoTgpio.clearDrivers(); - for (std::list::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) { Serial.printf("Start delete iotitem %s \n", (*it)->getID().c_str()); if (*it) delete *it; diff --git a/src/Global.cpp b/src/Global.cpp index 9843a65d..f5b20197 100644 --- a/src/Global.cpp +++ b/src/Global.cpp @@ -34,7 +34,9 @@ WebSocketsServer standWebSocket = WebSocketsServer(81); ***********************************************глобальные переменные************************************************** **********************************************************************************************************************/ IoTGpio IoTgpio(0); +#ifdef mod_RtcDriver IoTItem* rtcItem = nullptr; +#endif //IoTItem* camItem = nullptr; IoTItem* tlgrmItem = nullptr; IoTBench* benchTaskItem = nullptr; diff --git a/src/NTP.cpp b/src/NTP.cpp index bac99e72..546e10eb 100644 --- a/src/NTP.cpp +++ b/src/NTP.cpp @@ -31,9 +31,13 @@ void ntpInit() { synchTime(); // проверяем присутствие RTC с батарейкой и получаем время при наличии +#ifdef mod_RtcDriver if (rtcItem) { unixTime = rtcItem->getRtcUnixTime(); - } else return; + } + else +#endif + return; // ToDo разобраться: если нет железных часов дальше ничего не делать ??? } unixTimeShort = unixTime - START_DATETIME; diff --git a/src/classes/IoTItem.cpp b/src/classes/IoTItem.cpp index f3ccfc10..6380aa62 100644 --- a/src/classes/IoTItem.cpp +++ b/src/classes/IoTItem.cpp @@ -238,9 +238,12 @@ IoTGpio* IoTItem::getGpioDriver() { return nullptr; } +#ifdef mod_RtcDriver IoTItem* IoTItem::getRtcDriver() { return nullptr; } +#endif + /* IoTItem* IoTItem::getCAMDriver() { return nullptr; @@ -266,10 +269,12 @@ IoTDiscovery *IoTItem::getHADiscovery() { return nullptr; } +#ifdef mod_RtcDriver unsigned long IoTItem::getRtcUnixTime() { return 0; } +#endif // сетевое общение==================================================================================================================================== diff --git a/src/classes/IoTScenario.cpp b/src/classes/IoTScenario.cpp index d920c77b..7b7ad05a 100644 --- a/src/classes/IoTScenario.cpp +++ b/src/classes/IoTScenario.cpp @@ -744,6 +744,8 @@ int IoTScenario::gettok() { IdentifierStr += '"'; } else if (LastChar == 'n') { IdentifierStr += '\n'; + } else if (LastChar == '\\') { + IdentifierStr += '\\'; } } else { IdentifierStr += (char)LastChar; diff --git a/src/modules/sensors/Ds18b20/modinfo.json b/src/modules/sensors/Ds18b20/modinfo.json index 39639737..77176e4e 100644 --- a/src/modules/sensors/Ds18b20/modinfo.json +++ b/src/modules/sensors/Ds18b20/modinfo.json @@ -40,7 +40,7 @@ "defActive": true, "usedLibs": { "esp32*": [ - "https://github.com/milesburton/Arduino-Temperature-Control-Library" + "milesburton/DallasTemperature @ ^4.0.4" ], "esp32c6_4mb": [ "https://github.com/pstolarz/Arduino-Temperature-Control-Library.git#OneWireNg" @@ -49,7 +49,7 @@ "https://github.com/pstolarz/Arduino-Temperature-Control-Library.git#OneWireNg" ], "esp82*": [ - "https://github.com/milesburton/Arduino-Temperature-Control-Library" + "milesburton/DallasTemperature @ ^4.0.4" ] } } \ No newline at end of file diff --git a/src/modules/sensors/RTC/modinfo.json b/src/modules/sensors/RTC/modinfo.json index 369d70c3..2eff1496 100644 --- a/src/modules/sensors/RTC/modinfo.json +++ b/src/modules/sensors/RTC/modinfo.json @@ -28,6 +28,7 @@ "exampleURL": "https://iotmanager.org/wiki", "specialThanks": "", "moduleName": "RTC", + "moduleDefines": ["mod_RtcDriver", "hardRTC=1"], "moduleVersion": "1.0", "usedRam": { "esp32_4mb": 15,