File tree 4 files changed +16
-8
lines changed
4 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -924,8 +924,14 @@ export class Feed {
924
924
constructor ( feed : DeviceFeed ) {
925
925
this . server = connBroker . findServer ( feed . connectionId ) ;
926
926
this . feed = feed ;
927
- if ( typeof feed . payloadExpression !== 'undefined' && feed . payloadExpression . length > 0 )
928
- this . translatePayload = new Function ( 'feed' , 'value' , feed . payloadExpression ) ;
927
+ if ( typeof feed . payloadExpression !== 'undefined' && feed . payloadExpression . length > 0 ) {
928
+ try {
929
+ this . translatePayload = new Function ( 'feed' , 'value' , feed . payloadExpression ) ;
930
+ } catch ( err ) {
931
+ logger . error ( `Script error processing payload expression ${ err . message } :\n` ) ;
932
+ console . log ( feed . payloadExpression ) ;
933
+ }
934
+ }
929
935
}
930
936
public async send ( dev : any ) {
931
937
try {
Original file line number Diff line number Diff line change @@ -33,9 +33,9 @@ export class GpioController {
33
33
return this ;
34
34
} catch ( err ) { logger . error ( `Error stopping GPIO controller :${ err . message } ` ) ; }
35
35
}
36
- public reset ( ) {
37
- this . stopAsync ( ) ;
38
- this . init ( ) ;
36
+ public async reset ( ) {
37
+ await this . stopAsync ( ) ;
38
+ await this . init ( ) ;
39
39
}
40
40
private translateState ( direction : string , state : string ) {
41
41
switch ( state ) {
Original file line number Diff line number Diff line change @@ -314,7 +314,7 @@ export class ads1x15 extends i2cDeviceBase {
314
314
// 65355 = max
315
315
// 4.096 = pga
316
316
// 21,265 / 32,767 * 4.096
317
- let voltage = this . getVoltageFromValue ( value , channels [ i ] . pga ) ;
317
+ let voltage = this . getVoltageFromValue ( value , channels [ i ] . pga , channels [ i ] . reverseBias ) ;
318
318
let valElem = this . device . values . channels . find ( elem => { return elem . id === channels [ i ] . id } ) ;
319
319
if ( typeof valElem !== 'undefined' ) {
320
320
valElem . value = value ;
@@ -367,12 +367,13 @@ export class ads1x15 extends i2cDeviceBase {
367
367
// return value;
368
368
//}
369
369
}
370
- private getVoltageFromValue ( value , pga ) {
370
+ private getVoltageFromValue ( value , pga , reverseBias ) {
371
371
let max = ads1x15 . thresholdValues [ this . device . options . adcType ] ;
372
372
// positive values must be 1 less than max range value (e.g. full scale of 12 bit ADC => 2^(12-1)-1 => -2048 to 2047)
373
373
max = value > 0 ? max - 1 : max ;
374
374
logger . silly ( `${ this . options . name } Convert Voltage ${ value } / ${ max } * ${ pga } = ${ value / max * pga } ` ) ;
375
- return value / max * pga ; // value / mx = % of scale, scale * pga = Volts
375
+ let volts = value / max * pga ; // value / mx = % of scale, scale * pga = Volts
376
+ return reverseBias ? pga - volts : volts ;
376
377
}
377
378
378
379
public async setOptions ( opts ) : Promise < any > {
Original file line number Diff line number Diff line change @@ -4099,6 +4099,7 @@ $.ui.position.fieldTip = {
4099
4099
inputAttrs : { style : { width : "5rem" } }
4100
4100
} )
4101
4101
line = $ ( '<div></div>' ) . appendTo ( dlg ) ;
4102
+ $ ( '<div></div>' ) . appendTo ( dlg ) . checkbox ( { labelText : 'Reverse Bias' , binding : 'reverseBias' } ) ;
4102
4103
dataBinder . bind ( dlg , channel ) ;
4103
4104
dlg . css ( { overflow : 'visible' } ) ;
4104
4105
} ,
You can’t perform that action at this time.
0 commit comments