Skip to content

Commit

Permalink
feat(registration): Add BME680 and soil moisture sensor with port sel…
Browse files Browse the repository at this point in the history
…ection
  • Loading branch information
felixerdy committed Dec 10, 2019
1 parent 16c225d commit fed2d7a
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 2 deletions.
7 changes: 7 additions & 0 deletions app/scripts/controllers/account.box.edit.script.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
vm.boxScript = '';
vm.showConfiguration = false;
vm.showSerialPort = false;
vm.soilDigitalPort = 'A';
vm.showSoilDigitalPort = false;
vm.compiling = false;
vm.wifi = {
ssid: '',
Expand All @@ -37,6 +39,10 @@
vm.showSerialPort = true;
}

if (boxData.sensorsArray.filter(s => s.sensorType === 'SMT50').length > 0) {
vm.showSoilDigitalPort = true;
}

return getScript();
}

Expand All @@ -49,6 +55,7 @@
function getScript () {
return AccountService.getScript(boxData._id, {
serialPort: vm.serialPort,
soilDigitalPort: vm.soilDigitalPort,
ssid: vm.wifi.ssid,
password: vm.wifi.password
})
Expand Down
70 changes: 68 additions & 2 deletions app/scripts/controllers/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@
temp: false,
pressure: false,
light: false,
pollution: false
pollution: false,
bme680: false,
},
serialPort: 'Serial1'
serialPort: 'Serial1',
soilDigitalPort: 'A',
bmePhenomenon: 'tempHumiPress'
};

vm.wifi = {
Expand Down Expand Up @@ -69,6 +72,14 @@
vm.extensions = {
feinstaub: {
id: ''
},
soilMoisture: {
id: '',
port: 'A'
},
soundLevelMeter: {
id: '',
port: 'B'
}
};

Expand Down Expand Up @@ -166,6 +177,7 @@
function getScript () {
return AccountService.getScript(vm.newSenseBox.id, {
serialPort: vm.newSenseBox.serialPort,
soilDigitalPort: vm.newSenseBox.soilDigitalPort,
ssid: vm.wifi.ssid,
password: vm.wifi.password
})
Expand Down Expand Up @@ -310,6 +322,7 @@
var data = {};
if (model.startsWith('homeV2')) {
data.serialPort = vm.newModel.serialPort;
data.soilDigitalPort = vm.newSenseBox.soilDigitalPort;
}
AccountService.getScript(boxId, data)
.then(function (data) {
Expand Down Expand Up @@ -365,6 +378,9 @@
vm.newSenseBox.sensorTemplates.push('veml6070');
vm.newSenseBox.sensorTemplates.push('tsl45315');
break;
case 'bme680':
vm.newSenseBox.sensorTemplates.push('bme680');
break;
}
}
}
Expand All @@ -373,6 +389,14 @@
vm.newSenseBox.sensorTemplates.push('sds 011');
vm.newSenseBox.serialPort = vm.newModel.serialPort;
}
if (vm.extensions.soilMoisture.id !== '') {
vm.newSenseBox.sensorTemplates.push('smt50');
vm.newSenseBox.soilDigitalPort = vm.extensions.soilMoisture.port;
}
if (vm.extensions.soundLevelMeter.id !== '') {
vm.newSenseBox.sensorTemplates.push('soundlevelmeter');
vm.newSenseBox.soundLevelMeterPort = vm.extensions.soundLevelMeter.port;
}
}

if (vm.newModel.connection) {
Expand Down Expand Up @@ -476,6 +500,30 @@
unit = 'μW/cm²';
sensorType = 'VEML6070';
break;
case 'BME680_TEMPERATURE':
icon = 'osem-thermometer';
title = 'Temperatur';
unit = '°C';
sensorType = 'BME680';
break;
case 'BME680_HUMIDITY':
icon = 'osem-humidity';
title = 'rel. Luftfeuchte';
unit = '%';
sensorType = 'BME680';
break;
case 'BME680_PRESSURE':
icon = 'osem-barometer';
title = 'Luftdruck';
unit = 'hPa';
sensorType = 'BME680';
break;
case 'BME680_VOC':
icon = 'osem-barometer';
title = 'VOC';
unit = 'kΩ';
sensorType = 'BME680';
break;
case 'PM25':
icon = 'osem-cloud';
title = 'PM2.5';
Expand All @@ -488,6 +536,24 @@
unit = 'µg/m³';
sensorType = 'SDS 011';
break;
case 'smt50_soilmoisture':
icon = 'osem-humidity';
title = 'Bodenfeuchte';
unit = '%';
sensorType = 'SMT50';
break;
case 'smt50_soiltemperature':
icon = 'osem-thermometer';
title = 'Bodentemperatur';
unit = '°C';
sensorType = 'SMT50';
break;
case 'soundlevelmeter':
icon = 'osem-microphone';
title = 'Lautstärke';
unit = 'dB';
sensorType = 'soundlevelmeter';
break;
}
add(icon, title, unit, sensorType);
}
Expand Down
14 changes: 14 additions & 0 deletions app/views/account.box.edit.script.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ <h3>{{'CONFIGURATION'|translate}}</h3>
</div>
</div>
</div>
<div class="form-group" ng-if="script.showSoilDigitalPort">
<label for="soilDigitalPort">{{'SOIL_MOISTURE'|translate}}<br/>{{'DIGITAL_PORT'|translate}}</label>
<div class="input-group">
<select type="text" class="form-control" id="soilDigitalPort" ng-model="script.soilDigitalPort"
ng-change="script.generateScript()">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<div class="input-group-addon">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
</div>
</div>
</div>
<div class="form-group">
<label for="ssid">WiFi SSID</label>
<div class="input-group" uib-tooltip="{{'DATA_NOT_STORED'|translate}}" tooltip-placement="top"
Expand Down
107 changes: 107 additions & 0 deletions app/views/account.box.register.html
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,36 @@ <h3>{{'SENSORS' | translate}}</h3>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-8 col-xs-6"
style="border-right: 1px solid #e1e4e8;">
<div style="text-align: left;">
<div class="checkbox checkbox-success checkbox-inline"
style="vertical-align: middle;">
<input type="checkbox" id="bmeSensor" ng-true-value="'BME680'"
ng-false-value="''" ng-model="register.newModel.sensors.bme680">
<label for="bmeSensor"> </label>
</div>
<img
src="https://sensebox.kaufen/api//public/uploads/thumbs/thumb--1559804795021-bme_v2_top.png"
style="vertical-align: middle; height: 90px; width: 90px;" />
<span style="vertical-align: middle;">BME680</span>
</div>
</div>
<!-- <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4"
style="height: 90px; text-align: left; margin-top: 15px;">
<div class="form-group">
<label for="groupTagBME">{{'PHENOMENON' | translate}}</label>
<div class="input-group xxxl">
<select id="groupTagBME" class="form-control" style="border-radius: 4px;"
ng-model="register.newModel.bmePhenomenon">
<option value="tempHumiPress">{{'TEMPERATURE_HUMIDITY_PRESSURE' | translate}}</option>
<option value="voc">VOC</option>
</select>
</div>
</div>
</div> -->
</div>
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-8 col-xs-6"
style="border-right: 1px solid #e1e4e8;">
Expand Down Expand Up @@ -357,6 +387,69 @@ <h3>{{'SENSORS' | translate}}</h3>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-8 col-xs-6"
style="border-right: 1px solid #e1e4e8;">
<div style="text-align: left;">
<div class="checkbox checkbox-success checkbox-inline"
style="vertical-align: middle;">
<input type="checkbox" id="soilMoistureSensor" ng-true-value="'Bodenfeuchte'"
ng-false-value="''" ng-model="register.extensions.soilMoisture.id">
<label for="soilMoistureSensor"> </label>
</div>
<img
src="https://sensebox.kaufen/api/public/uploads/1572259222502-SMT50_freigestellt_02.png"
style="vertical-align: middle; height: 90px; width: 90px;" />
<span style="vertical-align: middle;">{{'SOIL_MOISTURE' | translate}}</span>
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4"
style="height: 90px; text-align: left; margin-top: 15px;">
<div class="form-group">
<label for="groupTagSoilMoisture">{{'DIGITAL_PORT' | translate}}</label>
<div class="input-group xxxl">
<select id="groupTagSoilMoisture" class="form-control" style="border-radius: 4px;"
ng-model="register.extensions.soilMoisture.port">
<!---->
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
</div>
</div>
</div>
</div>
<!-- <div class="row">
<div class="col-lg-8 col-md-8 col-sm-8 col-xs-6"
style="border-right: 1px solid #e1e4e8;">
<div style="text-align: left;">
<div class="checkbox checkbox-success checkbox-inline"
style="vertical-align: middle;">
<input type="checkbox" id="soundLevelMeter" ng-true-value="'Lautstärke'"
ng-false-value="''" ng-model="register.extensions.soundLevelMeter.id">
<label for="soundLevelMeter"> </label>
</div>
<img
src="https://sensebox.kaufen/api/public/uploads/1572259222502-SMT50_freigestellt_02.png"
style="vertical-align: middle; height: 90px; width: 90px;" />
<span style="vertical-align: middle;">Lautstärke</span>
</div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4"
style="height: 90px; text-align: left; margin-top: 15px;">
<div class="form-group">
<label for="groupTagSoundLevelMeter">Digitaler Port</label>
<div class="input-group xxxl">
<select id="groupTagSoundLevelMeter" class="form-control" style="border-radius: 4px;"
ng-model="register.extensions.soundLevelMeter.port">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
</div>
</div>
</div>
</div> -->
</div>
</div>
</li>
Expand Down Expand Up @@ -1151,6 +1244,20 @@ <h5 ng-bind-html="'COMPILE_SKETCH'|translate"></h5>
</div>
</div>
</div>
<div class="form-group">
<label for="soilDigitalPort">{{'SOIL_MOISTURE'|translate}} {{'DIGITAL_PORT'|translate}}</label>
<div class="input-group">
<select type="text" class="form-control" id="soilDigitalPort" ng-model="register.newSenseBox.soilDigitalPort"
ng-change="register.generateScript()">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<div class="input-group-addon">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
</div>
</div>
</div>
<div class="form-group">
<label for="ssid">WiFi SSID</label>
<div class="input-group" uib-tooltip="{{'DATA_NOT_STORED'|translate}}" tooltip-placement="top"
Expand Down

0 comments on commit fed2d7a

Please sign in to comment.