@@ -164,7 +164,7 @@ var searchDeviceListByChipId = function (Id) {
164164 var i , duplicate , result ;
165165 do {
166166 for ( i = 0 ; i < iSpindelDevices . length ; i ++ ) {
167- if ( iSpindelDevices [ i ] . raw . chipId == Id ) {
167+ if ( iSpindelDevices [ i ] . chipId == Id ) {
168168 if ( result ) {
169169 duplicate = i ;
170170 duplicates += 1 ;
@@ -232,21 +232,41 @@ class Ispindel {
232232 }
233233
234234 set_contents ( state , tempScale ) {
235+ //console.log("set_contents() state: " + JSON.stringify(state));
235236
236237 this . temp = state . temperature ;
237- if ( tempScale == 'F' ) {
238- document . getElementById ( this . elementName + "_temp" ) . textContent = ( ( state . temperature * 9 / 5 ) + 32 ) . toFixed ( 2 ) ;
239- } else {
240- document . getElementById ( this . elementName + "_temp" ) . textContent = ( state . temperature ) . toFixed ( 2 ) ;
241- }
242238 this . grav = state . grav ;
243- document . getElementById ( this . elementName + "_grav" ) . textContent = ( state . grav ) . toFixed ( 2 ) ;
244239 this . tilt = state . tilt ;
245- //document.getElementById(this.elementName + "_tilt").textContent = (state.tilt).toFixed(2);
246240 this . batt = state . batt ;
247-
248241 this . stamp = state . stamp ;
249242
243+ //console.log("set_contents() elementName: " + this.elementName);
244+ var have_isp_temp = document . getElementById ( this . elementName + "_temp" ) ;
245+ if ( ! have_isp_temp ) {
246+ var isp_temp , isp_grav ;
247+
248+ isp_temp = document . createElement ( "DIV" ) ;
249+ isp_temp . id = this . elementName + "_temp" ;
250+ isp_temp . className = "isp_entry" ;
251+ document . getElementById ( this . elementName ) . appendChild ( isp_temp ) ;
252+
253+ isp_grav = document . createElement ( "DIV" ) ;
254+ isp_grav . id = this . elementName + "_grav" ;
255+ isp_grav . className = "isp_entry" ;
256+ document . getElementById ( this . elementName ) . appendChild ( isp_grav ) ;
257+ }
258+ try {
259+ if ( tempScale == 'F' ) {
260+ document . getElementById ( this . elementName + "_temp" ) . textContent = ( ( state . temperature * 9 / 5 ) + 32 ) . toFixed ( 2 ) ;
261+ } else {
262+ document . getElementById ( this . elementName + "_temp" ) . textContent = ( state . temperature ) . toFixed ( 2 ) ;
263+ }
264+ document . getElementById ( this . elementName + "_grav" ) . textContent = ( state . grav ) . toFixed ( 2 ) ;
265+ }
266+ catch ( err ) {
267+ console . log ( "set_contents() caught " + err ) ;
268+ }
269+
250270 }
251271
252272 setNewWaitTime ( val ) {
@@ -924,7 +944,13 @@ window.onload = function () {
924944 console . log ( "iSpindelDevices was: " + JSON . stringify ( iSpindelDevices ) ) ;
925945 asensor . className = 'isp_sensor_update' ;
926946
927- var device = searchDeviceListByChipId ( sensor_state [ i ] . chipId ) ;
947+ var device ;
948+ try {
949+ device = searchDeviceListByChipId ( sensor_state [ i ] . chipId ) ;
950+ }
951+ catch ( err ) {
952+ console . log ( "Couldn't searchDeviceListByChipId() for some reason; " + err ) ;
953+ }
928954 if ( device ) {
929955 console . log ( "Already have device: " + device . chipId ) ;
930956 } else {
0 commit comments