mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 14:12:16 +03:00
Merge pull request #408 from DmitriyTychina/ver4dev
в modinfo модулей добавлен moduleDefines для условной компиляции upd: добавлена поддержка define во все проекты
This commit is contained in:
@@ -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']['moduleDefines']
|
||||
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" + "-D" + 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)
|
||||
|
||||
@@ -66,7 +66,9 @@
|
||||
*****************************************глобальные объекты классов***************************************************
|
||||
**********************************************************************************************************************/
|
||||
extern IoTGpio IoTgpio;
|
||||
#ifdef mod_RtcDriver
|
||||
extern IoTItem* rtcItem;
|
||||
#endif
|
||||
//extern IoTItem* camItem;
|
||||
extern IoTItem* tlgrmItem;
|
||||
extern IoTBench* benchLoadItem;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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>
|
||||
+<classes/*.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 =
|
||||
+<modules/exec/AnalogBtn>
|
||||
+<modules/exec/ButtonIn>
|
||||
+<modules/exec/ButtonOut>
|
||||
+<modules/exec/Buzzer>
|
||||
+<modules/exec/Enconder>
|
||||
+<modules/exec/Multitouch>
|
||||
+<modules/exec/Pwm32>
|
||||
+<modules/exec/TelegramLT>
|
||||
+<modules/exec/Thermostat>
|
||||
build_flags =
|
||||
-Dmod_RtcDriver
|
||||
-DhardRTC=1
|
||||
|
||||
[env:esp32cam_4mb_fromitems]
|
||||
lib_deps =
|
||||
|
||||
@@ -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<IoTItem*>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) {
|
||||
Serial.printf("Start delete iotitem %s \n", (*it)->getID().c_str());
|
||||
if (*it) delete *it;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
// сетевое общение====================================================================================================================================
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
"exampleURL": "https://iotmanager.org/wiki",
|
||||
"specialThanks": "",
|
||||
"moduleName": "RTC",
|
||||
"moduleDefines": ["mod_RtcDriver", "hardRTC=1"],
|
||||
"moduleVersion": "1.0",
|
||||
"usedRam": {
|
||||
"esp32_4mb": 15,
|
||||
|
||||
Reference in New Issue
Block a user