add multiple i2c buses to build config
This commit is contained in:
parent
adf55fcade
commit
e815cd19da
|
@ -345,9 +345,9 @@ types:
|
||||||
|
|
||||||
- &iicsensors
|
- &iicsensors
|
||||||
type: checkbox
|
type: checkbox
|
||||||
label: I2C
|
label: "I2C #busname#"
|
||||||
key: i2c
|
key: "i2c#busname#"
|
||||||
description: 'I2C Bus #1'
|
description: "I2C Bus #busname#"
|
||||||
values:
|
values:
|
||||||
- key: true
|
- key: true
|
||||||
children:
|
children:
|
||||||
|
@ -355,67 +355,60 @@ types:
|
||||||
label: SDA
|
label: SDA
|
||||||
key: sda
|
key: sda
|
||||||
mandatory: true
|
mandatory: true
|
||||||
target: "define:GWIIC_SDA"
|
target: "define:GWIIC_SDA#bus#"
|
||||||
- <<: *gpiopin
|
- <<: *gpiopin
|
||||||
label: SCL
|
label: SCL
|
||||||
key: scl
|
key: scl
|
||||||
mandatory: true
|
mandatory: true
|
||||||
target: "define:GWIIC_SCL"
|
target: "define:GWIIC_SCL#bus#"
|
||||||
- type: checkbox
|
- type: checkbox
|
||||||
label: SHT3X
|
label: SHT3X-#busname#-1
|
||||||
description: "SHT30 temperature and humidity sensor"
|
description: "SHT30 temperature and humidity sensor 0x44"
|
||||||
key: sht3x
|
key: sht3x1
|
||||||
|
target: define
|
||||||
values:
|
values:
|
||||||
- key: true
|
- key: true
|
||||||
children:
|
value: GWSHT3X#busname#1
|
||||||
- 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
|
|
||||||
- type: checkbox
|
- type: checkbox
|
||||||
label: QMP6988
|
label: SHT3X-#busname#-1
|
||||||
description: "QMP6988 pressure sensor"
|
description: "SHT30 temperature and humidity sensor 0x45"
|
||||||
key: qmp6988
|
key: sht3x2
|
||||||
|
target: define
|
||||||
values:
|
values:
|
||||||
- key: true
|
- key: true
|
||||||
children:
|
value: GWSHT3X#busname#2
|
||||||
- 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
|
|
||||||
|
|
||||||
- type: checkbox
|
- 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"
|
description: "BME280 temperature/humidity/pressure sensor"
|
||||||
key: bme280
|
key: bme2801
|
||||||
|
target: define
|
||||||
values:
|
values:
|
||||||
- key: true
|
- key: true
|
||||||
children:
|
value: GWBME280#busname#1
|
||||||
- type: select
|
- type: checkbox
|
||||||
label: address
|
label: BME280-#busname#-2
|
||||||
key: address
|
description: "BME280 temperature/humidity/pressure sensor"
|
||||||
target: "define:GWBME280"
|
key: bme2802
|
||||||
mandatory: true
|
target: define
|
||||||
default: 118
|
|
||||||
values:
|
values:
|
||||||
- label: "default(0x76 - L)"
|
- key: true
|
||||||
value: 118
|
value: GWBME280#busname#2
|
||||||
- label: "opt(0x77 - nc)"
|
|
||||||
value: 119
|
|
||||||
|
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
|
@ -468,4 +461,11 @@ config:
|
||||||
- *can
|
- *can
|
||||||
- *resetButton
|
- *resetButton
|
||||||
- *led
|
- *led
|
||||||
- *iicsensors
|
- <<: *iicsensors
|
||||||
|
base:
|
||||||
|
busname: "1"
|
||||||
|
bus: ""
|
||||||
|
- <<: *iicsensors
|
||||||
|
base:
|
||||||
|
busname: "2"
|
||||||
|
bus: "2"
|
|
@ -530,6 +530,8 @@ class PipelineInfo{
|
||||||
frame.setAttribute(PATH_ATTR,prefix);
|
frame.setAttribute(PATH_ATTR,prefix);
|
||||||
let expandedList=expandList(configList);
|
let expandedList=expandList(configList);
|
||||||
expandedList.forEach((cfg)=>{
|
expandedList.forEach((cfg)=>{
|
||||||
|
let currentBase=Object.assign({},base,cfg.base);
|
||||||
|
cfg=replaceValues(cfg,currentBase);
|
||||||
if (cfg.key === undefined){
|
if (cfg.key === undefined){
|
||||||
if (cfg.type !== undefined && cfg.type !== 'frame'){
|
if (cfg.type !== undefined && cfg.type !== 'frame'){
|
||||||
console.log("config without key",cfg);
|
console.log("config without key",cfg);
|
||||||
|
@ -546,7 +548,6 @@ class PipelineInfo{
|
||||||
name=cfg.key;
|
name=cfg.key;
|
||||||
}
|
}
|
||||||
let current=config[name];
|
let current=config[name];
|
||||||
let currentBase=Object.assign({},base,cfg.base);
|
|
||||||
let childFrame=buildSelector(frame,cfg,name,current,
|
let childFrame=buildSelector(frame,cfg,name,current,
|
||||||
(child,initial,opt_frame)=>{
|
(child,initial,opt_frame)=>{
|
||||||
if(cfg.key !== undefined) removeSelectors(name,!initial);
|
if(cfg.key !== undefined) removeSelectors(name,!initial);
|
||||||
|
@ -558,12 +559,30 @@ class PipelineInfo{
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const replaceValues=(str,base)=>{
|
const replaceValues=(str,base)=>{
|
||||||
|
if (! base) return str;
|
||||||
|
if (typeof(str) === 'string'){
|
||||||
for (let k in base){
|
for (let k in base){
|
||||||
let r=new RegExp("#"+k+"#","g");
|
let r=new RegExp("#"+k+"#","g");
|
||||||
str=str.replace(r,base[k]);
|
str=str.replace(r,base[k]);
|
||||||
}
|
}
|
||||||
return str;
|
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;
|
||||||
|
}
|
||||||
const ROOT_PATH='root';
|
const ROOT_PATH='root';
|
||||||
const buildValues=(initial)=>{
|
const buildValues=(initial)=>{
|
||||||
let environment;
|
let environment;
|
||||||
|
|
Loading…
Reference in New Issue