Merge pull request #29 from bradanlane/master

webUI update for time and temp
pull/30/head
cyoung 2015-09-03 23:46:50 -04:00
commit 3664401e25
3 zmienionych plików z 21 dodań i 8 usunięć

Wyświetl plik

@ -16,7 +16,7 @@ import (
// http://www.faa.gov/nextgen/programs/adsb/wsa/media/GDL90_Public_ICD_RevA.PDF
const (
stratuxVersion = "v0.2"
stratuxVersion = "v0.2pre+"
configLocation = "/etc/stratux.conf"
managementAddr = ":80"
maxDatagramSize = 8192
@ -315,8 +315,8 @@ func updateStatus() {
globalStatus.GPS_satellites_locked = mySituation.satellites
}
// Update Uptime.
globalStatus.Uptime = time.Since(timeStarted).String()
// Update Uptime value
globalStatus.Uptime = uint(time.Since(timeStarted)/time.Millisecond)
// Update CPUTemp.
temp, err := ioutil.ReadFile("/sys/class/thermal/thermal_zone0/temp")
@ -399,7 +399,7 @@ type status struct {
GPS_satellites_locked uint16
GPS_connected bool
RY835AI_connected bool
Uptime string
Uptime uint
CPUTemp float32
}

Wyświetl plik

@ -81,6 +81,10 @@
<label class="col-xs-6">Uptime:</label>
<span id="Uptime" class="col-xs-6">--</span>
</div>
<div class="row">
<label class="col-xs-6">CPU Temp:</label>
<span id="CPUTemp" class="col-xs-6">--</span>
</div>
</div>
</div>
</div>

Wyświetl plik

@ -57,11 +57,20 @@ function connect() {
/* the formatting code could move to the other end of the socket */
var uptime = status.Uptime;
if (uptime != undefined) {
var time_parts = uptime.match(/([0-9]*)h([0-9]*)m([0-9\.]*)s/);
$('#Uptime').text(time_parts[1] + "h" + time_parts[2] + "m" + Math.round(parseFloat(time_parts[3])) + "s");
var up_s = parseInt((uptime/1000)%60),
up_m = parseInt((uptime/(1000*60))%60),
up_h = parseInt((uptime/(1000*60*60))%24);
$('#Uptime').text(((up_h<10)?"0"+up_h:up_h) + "h" + ((up_m<10)?"0"+up_m:up_m) + "m" + ((up_s<10)?"0"+up_s:up_s) + "s");
} else {
// $('#Uptime').text('unavailable');
}
var boardtemp = status.CPUTemp;
if (boardtemp != undefined) {
/* boardtemp is celcius to tenths */
$('#CPUTemp').text(boardtemp.toFixed(1) + 'C / ' + ((boardtemp*9/5)+32.0).toFixed(1) + 'F');
} else {
// $('#CPUTemp').text('unavailable');
}
// not yet implemented - showing the raspberry pi board temperature will be helpful when Stratux is contained in a case
/* $('#PI_Temperature').text(status.Pi_Temperature); */
// Update Settings
$('input[name=UAT_Enabled]').prop('checked', status.UAT_Enabled);