From f46e75786a6db4b0154b79d3858c208bdf67d2a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= <83164375+DmitriyTychina@users.noreply.github.com> Date: Fri, 19 Sep 2025 18:19:40 +0300 Subject: [PATCH 1/3] =?UTF-8?q?=D0=B2=20modinfo=20=D0=BC=D0=BE=D0=B4=D1=83?= =?UTF-8?q?=D0=BB=D0=B5=D0=B9=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20moduleDefines=20=D0=B4=D0=BB=D1=8F=20=D1=83=D1=81?= =?UTF-8?q?=D0=BB=D0=BE=D0=B2=D0=BD=D0=BE=D0=B9=20=D0=BA=D0=BE=D0=BC=D0=BF?= =?UTF-8?q?=D0=B8=D0=BB=D1=8F=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PrepareProject.py | 8 +++++++- include/Global.h | 2 ++ include/classes/IoTItem.h | 5 +++-- platformio.ini | 7 +++++-- src/ESPConfiguration.cpp | 5 ++++- src/Global.cpp | 2 ++ src/NTP.cpp | 6 +++++- src/classes/IoTItem.cpp | 5 +++++ src/modules/sensors/RTC/modinfo.json | 1 + 9 files changed, 34 insertions(+), 7 deletions(-) diff --git a/PrepareProject.py b/PrepareProject.py index 2f8c1241..2451cc0c 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 = "" # для каждого модуля создаем глобальный define "-D" + moduleJson['about']['moduleType'] +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 'moduleType' in moduleJson['about']: + allDefs = allDefs + "\n" + "-D" + moduleJson['about']['moduleType'] 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) 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..e0dff157 100644 --- a/platformio.ini +++ b/platformio.ini @@ -228,6 +228,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 @@ -777,7 +778,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 +806,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/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, From a71e6088ca43c1e6531d630512c418f01ae0e8d8 Mon Sep 17 00:00:00 2001 From: Mit4el Date: Tue, 23 Sep 2025 10:28:44 +0300 Subject: [PATCH 2/3] Update PrepareProject.py rename moduleType to moduleDefines --- PrepareProject.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PrepareProject.py b/PrepareProject.py index 2451cc0c..e71c6fc5 100644 --- a/PrepareProject.py +++ b/PrepareProject.py @@ -182,7 +182,7 @@ 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 -allDefs = "" # для каждого модуля создаем глобальный define "-D" + moduleJson['about']['moduleType'] +allDefs = "" # для каждого модуля создаем глобальный define "-D" + moduleJson['about']['moduleDefines'] itemsCount = 1 includeDirs = "" # подборка путей ко всем модулям для дальнейшей записи в конфигурацию platformio itemsJson = json.loads('[{"name": "Выберите элемент", "num": 0}]') @@ -192,8 +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 'moduleType' in moduleJson['about']: - allDefs = allDefs + "\n" + "-D" + moduleJson['about']['moduleType'] + if 'moduleDefines' in moduleJson['about']: + allDefs = allDefs + "\n" + "-D" + moduleJson['about']['moduleDefines'] if deviceName in moduleJson['usedLibs']: # проверяем поддерживает ли модуль текущее устройство if not 'exclude' in moduleJson['usedLibs'][deviceName]: # смотрим не нужно ли исключить данный модуль из указанной платы deviceName activeModulesName.append(moduleJson['about']['moduleName']) # запоминаем имена для использования на след шагах @@ -290,4 +290,4 @@ else: # print(f"\x1b[1;32;41m Операция завершена. \x1b[0m") - \ No newline at end of file + From e3121a24671f8e20df7de91eca976a8dc7c2bab6 Mon Sep 17 00:00:00 2001 From: Mit4el Date: Tue, 23 Sep 2025 10:39:56 +0300 Subject: [PATCH 3/3] Update platformio.ini Add build_flag all project --- platformio.ini | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/platformio.ini b/platformio.ini index e0dff157..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 @@ -256,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 @@ -282,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 @@ -306,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 @@ -331,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 @@ -358,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 @@ -384,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 @@ -411,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 @@ -441,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 @@ -489,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> +