From e815cd19dac0e6123aab0970f1c372bd1334e8e3 Mon Sep 17 00:00:00 2001 From: andreas Date: Fri, 3 Nov 2023 20:00:38 +0100 Subject: [PATCH] add multiple i2c buses to build config --- webinstall/build.yaml | 104 +++++++++++++++++++++--------------------- webinstall/cibuild.js | 27 +++++++++-- 2 files changed, 75 insertions(+), 56 deletions(-) diff --git a/webinstall/build.yaml b/webinstall/build.yaml index f0575f9..fbcab06 100644 --- a/webinstall/build.yaml +++ b/webinstall/build.yaml @@ -345,9 +345,9 @@ types: - &iicsensors type: checkbox - label: I2C - key: i2c - description: 'I2C Bus #1' + label: "I2C #busname#" + key: "i2c#busname#" + description: "I2C Bus #busname#" values: - key: true children: @@ -355,68 +355,61 @@ types: label: SDA key: sda mandatory: true - target: "define:GWIIC_SDA" + target: "define:GWIIC_SDA#bus#" - <<: *gpiopin label: SCL key: scl mandatory: true - target: "define:GWIIC_SCL" + target: "define:GWIIC_SCL#bus#" - type: checkbox - label: SHT3X - description: "SHT30 temperature and humidity sensor" - key: sht3x + label: SHT3X-#busname#-1 + description: "SHT30 temperature and humidity sensor 0x44" + key: sht3x1 + target: define values: - key: true - children: - - type: select - label: address - key: address - target: "define:GWSHT3X" - mandatory: true - default: 68 - values: - - label: "default(0x44 - L)" - value: 68 - - label: "opt(0x45 - H)" - value: 69 + value: GWSHT3X#busname#1 - type: checkbox - label: QMP6988 - description: "QMP6988 pressure sensor" - key: qmp6988 + label: SHT3X-#busname#-1 + description: "SHT30 temperature and humidity sensor 0x45" + key: sht3x2 + target: define values: - key: true - children: - - type: select - label: address - key: address - target: "define:GWQMP6988" - mandatory: true - default: 86 - values: - - label: "default(0x56 - H)" - value: 86 - - label: "opt(0x70 - L)" - value: 112 - + value: GWSHT3X#busname#2 - type: checkbox - label: BME280 + label: QMP6988-#busname#-1 + description: "QMP6988 pressure sensor addr 86" + key: qmp69881 + target: define + values: + - key: true + value: GWQMP6988#busname#1 + - type: checkbox + label: QMP6988-#busname#-2 + description: "QMP6988 pressure sensor addr 112" + key: qmp69882 + target: define + values: + - key: true + value: GWQMP6988#busname#2 + - type: checkbox + label: BME280-#busname#-1 description: "BME280 temperature/humidity/pressure sensor" - key: bme280 + key: bme2801 + target: define values: - key: true - children: - - type: select - label: address - key: address - target: "define:GWBME280" - mandatory: true - default: 118 - values: - - label: "default(0x76 - L)" - value: 118 - - label: "opt(0x77 - nc)" - value: 119 - + value: GWBME280#busname#1 + - type: checkbox + label: BME280-#busname#-2 + description: "BME280 temperature/humidity/pressure sensor" + key: bme2802 + target: define + values: + - key: true + value: GWBME280#busname#2 + resources: default: &esp32default @@ -468,4 +461,11 @@ config: - *can - *resetButton - *led - - *iicsensors \ No newline at end of file + - <<: *iicsensors + base: + busname: "1" + bus: "" + - <<: *iicsensors + base: + busname: "2" + bus: "2" \ No newline at end of file diff --git a/webinstall/cibuild.js b/webinstall/cibuild.js index 94a8fcc..5035c56 100644 --- a/webinstall/cibuild.js +++ b/webinstall/cibuild.js @@ -530,6 +530,8 @@ class PipelineInfo{ frame.setAttribute(PATH_ATTR,prefix); let expandedList=expandList(configList); expandedList.forEach((cfg)=>{ + let currentBase=Object.assign({},base,cfg.base); + cfg=replaceValues(cfg,currentBase); if (cfg.key === undefined){ if (cfg.type !== undefined && cfg.type !== 'frame'){ console.log("config without key",cfg); @@ -546,7 +548,6 @@ class PipelineInfo{ name=cfg.key; } let current=config[name]; - let currentBase=Object.assign({},base,cfg.base); let childFrame=buildSelector(frame,cfg,name,current, (child,initial,opt_frame)=>{ if(cfg.key !== undefined) removeSelectors(name,!initial); @@ -558,9 +559,27 @@ class PipelineInfo{ }) } const replaceValues=(str,base)=>{ - for (let k in base){ - let r=new RegExp("#"+k+"#","g"); - str=str.replace(r,base[k]); + if (! base) return str; + if (typeof(str) === 'string'){ + for (let k in base){ + let r=new RegExp("#"+k+"#","g"); + str=str.replace(r,base[k]); + } + return str; + } + if (str instanceof Array){ + let rt=[]; + str.forEach((el)=>{ + rt.push(replaceValues(el,base)); + }) + return rt; + } + if (str instanceof Object){ + let rt={}; + for (let k in str){ + rt[k]=replaceValues(str[k],base); + } + return rt; } return str; }