Added more stuff

This commit is contained in:
2018-11-14 22:40:11 -05:00
parent 8b42e2929b
commit af4abd85bc
11 changed files with 468 additions and 62 deletions

View File

@ -1,3 +1,8 @@
<p>
batterys works!
</p>
<h1>BATTERY LEVEL: <span class="text-muted">{{batteryService.charging == null ? 'UNKNOWN' : batteryService.average}}</span></h1>
<mat-card>
<h3>EMULATOR: <span class="text-muted">75%</span></h3>
<div>
<mat-icon style="font-size: 128px; height:128px; width:128px">{{batteryService.icon}}</mat-icon>
<i class="wi wi-fw wi-thermometer-exterior"></i> {{tempHist[tempHist.length - 1]}} °C
</div>
</mat-card>

View File

@ -1,14 +1,17 @@
import { Component, OnInit } from '@angular/core';
import {Component} from '@angular/core';
import {BatteryService} from './battery.service';
import {firebaseApp} from '../app.module';
@Component({
selector: 'app-batterys',
templateUrl: './battery.component.html'
selector: 'app-batterys',
templateUrl: './battery.component.html'
})
export class BatteryComponent implements OnInit {
constructor() { }
ngOnInit() {
}
export class BatteryComponent {
tempHist = [];
constructor(public batteryService: BatteryService) {
firebaseApp.firestore().collection('Battery').doc('TEMP').onSnapshot(snap => {
this.tempHist.push(Math.round(snap.get('temp') * 10) / 10);
})
}
}

View File

@ -5,7 +5,7 @@ import {Injectable} from '@angular/core';
})
export class BatteryService {
percentage: number[] = [0];
charging: boolean;
charging?: boolean;
get average() {
return this.percentage.reduce((acc, battery) => acc + battery, 0) / this.percentage.length;