From f472a8733d19cc6e2fd7bb52fb8a9286eb9a358d Mon Sep 17 00:00:00 2001 From: Thiemann96 Date: Mon, 17 Feb 2020 15:21:08 +0100 Subject: [PATCH] add defines on input --- src/assets/templates/homev2Wifi.tpl | 2 +- src/pages/configuration/configuration.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/assets/templates/homev2Wifi.tpl b/src/assets/templates/homev2Wifi.tpl index 1baacf3..152a94b 100644 --- a/src/assets/templates/homev2Wifi.tpl +++ b/src/assets/templates/homev2Wifi.tpl @@ -62,7 +62,7 @@ const char SENSEBOX_ID[] PROGMEM = "@{SENSEBOX_ID}@"; static const uint8_t NUM_SENSORS = @{NUM_SENSORS}@; // Connected sensors -@{SENSORS|toDefineWithSuffixPrefixAndKey~,_CONNECTED,sensorType}@ +@{defineSensors}@ // Sensor SENSOR_IDs // Temperatur diff --git a/src/pages/configuration/configuration.ts b/src/pages/configuration/configuration.ts index 05f44d9..206ae01 100644 --- a/src/pages/configuration/configuration.ts +++ b/src/pages/configuration/configuration.ts @@ -52,6 +52,7 @@ export class ConfigurationPage { PASSWORD:this.pw, INGRESS_DOMAIN:"ingress.opensensemap.org", SENSEBOX_ID:this.senseboxid, + defineSensors:this.buildDefines(), NUM_SENSORS:this.sensors.length, TEMPERSENSOR_ID:this.temp, RELLUFSENSOR_ID:this.humi, @@ -61,13 +62,21 @@ export class ConfigurationPage { REGENMSENSOR_ID:this.rain, PM10SENSOR_ID:this.pm10, PM25SENSOR_ID:this.pm25 + }; this.http.get("assets/templates/homev2Wifi.tpl",{responseType:"text"}).subscribe(data=>{ let sketch = this.applyTemplate(data,values); + console.log(sketch) this.navCtrl.push(OtaWizardPage, { sketch }) }) } - + buildDefines(){ + let defineString ="" + this.sensors.map((sensor)=>{ + defineString+="#define "+sensor.type+"_CONNECTED\n" + }) + return defineString; + } addSensor(){ let addModal = this.modalCtrl.create(AddItemPage);