Updated battery config

This commit is contained in:
Zakary Timson 2018-12-20 18:37:01 -05:00
parent 611ec4c814
commit 0869970839
3 changed files with 8 additions and 6 deletions

View File

@ -11,7 +11,7 @@
[scheme]="scheme"
[yAxis]="true"
[yScaleMin]="0"
[yScaleMax]="100"
[yScaleMax]="25"
[yAxisTickFormatting]="percentFormat"
legendTitle="Charge"
[legend]="!app.mobile"

View File

@ -28,7 +28,7 @@ export class BatteryComponent implements OnInit {
}
percentFormat(val) {
return `${val} %`
return `${val} V`
}
tempFormat(val) {

View File

@ -44,13 +44,15 @@ export class BatteryService {
constructor() {
this.firestore = firebaseApp.firestore();
this.firestore.settings({timestampsInSnapshots: true});
this.firestore.collection('Battery').doc('TEMP').onSnapshot(snap => {
this.firestore.collection('Battery').doc('170724D').onSnapshot(snap => {
this.last = new Date();
let data = snap.data();
this.batteries = Object.keys(data).map(key => ({name: key, history: data[key]}));
this.average = this.batteries.reduce((acc, battery) => acc + battery.history[0].percentage, 0) / this.batteries.length;
this.percentageData = this.batteries.map(battery => ({name: battery.name, series: battery.history.map((history, i) => ({name: i, value: history.percentage * 100}))}));
console.log(data);
this.batteries = Object.keys(data.modules).map(key => ({name: key, history: data.modules[key]}));
this.average = this.batteries.reduce((acc, battery) => acc + battery.history[0].charge, 0) / this.batteries.length;
this.percentageData = this.batteries.map(battery => ({name: battery.name, series: battery.history.map((history, i) => ({name: i, value: history.charge}))}));
this.temperatureData = this.batteries.map(battery => ({name: battery.name, series: battery.history.map((history, i) => ({name: i, value: Math.round(history.temp * 10) / 10}))}));
});
}