@@ -94,6 +94,8 @@ export class DP100Element extends DP100(LitElement) {
9494 vMax : { type : Number , attribute : false , reflect : true } ,
9595 iMax : { type : Number , attribute : false , reflect : true } ,
9696 pMax : { type : Number , attribute : false , reflect : true } ,
97+ vRange : { type : Number , attribute : false , reflect : true } ,
98+ iRange : { type : Number , attribute : false , reflect : true } ,
9799 }
98100 static styles = css `
99101 :host {
@@ -262,6 +264,8 @@ export class DP100Element extends DP100(LitElement) {
262264 this . pMax = 0
263265 this . energy = 0
264266 this . timer = Date . now ( )
267+ this . vRange = 30
268+ this . iRange = 5
265269 }
266270
267271 render ( ) {
@@ -302,6 +306,11 @@ export class DP100Element extends DP100(LitElement) {
302306 } ) }
303307 V
304308 </ div >
309+ < div class ="value ">
310+ < em > V</ em > < sub > scale</ sub >
311+ < input type ="number " @change =${ this . changeVoltageScale . bind ( this ) }
312+ .value =${ this . vRange } min="0.1" max="30" step="0.5" data-graph-scale aria-label="Voltage scale"> V
313+ </ div >
305314 </ div >
306315 < div id ="iOut ">
307316 < div class ="group group--big ">
@@ -337,6 +346,11 @@ export class DP100Element extends DP100(LitElement) {
337346 } ) }
338347 A
339348 </ div >
349+ < div class ="value ">
350+ < em > I</ em > < sub > scale</ sub >
351+ < input type ="number " @change =${ this . changeCurrentScale . bind ( this ) }
352+ .value =${ this . iRange } min="0.1" max="5" step="0.1" data-graph-scale aria-label="Current scale"> A
353+ </ div >
340354 </ div >
341355 < div id ="pOut ">
342356 < div class ="value ">
@@ -445,7 +459,7 @@ export class DP100Element extends DP100(LitElement) {
445459 }
446460
447461 updated ( ) {
448- this . shadowRoot . querySelectorAll ( 'input' ) . forEach ( input => {
462+ this . shadowRoot . querySelectorAll ( 'input:not([data-graph-scale]) ' ) . forEach ( input => {
449463 input . disabled = ! this . device
450464 } )
451465 }
@@ -470,6 +484,22 @@ export class DP100Element extends DP100(LitElement) {
470484 this . setBasicSettings ( { ocp_set : event . target . value } )
471485 }
472486
487+ changeVoltageScale ( event ) {
488+ const value = parseFloat ( event . target . value )
489+ if ( ! this . graph || ! ( value > 0 ) ) return
490+ this . vRange = value
491+ this . graph . setScale ( 'V' , { min : 0 , max : value } )
492+ this . graph . setScale ( 'W' , { min : 0 , max : value * this . iRange } )
493+ }
494+
495+ changeCurrentScale ( event ) {
496+ const value = parseFloat ( event . target . value )
497+ if ( ! this . graph || ! ( value > 0 ) ) return
498+ this . iRange = value
499+ this . graph . setScale ( 'A' , { min : 0 , max : value } )
500+ this . graph . setScale ( 'W' , { min : 0 , max : this . vRange * value } )
501+ }
502+
473503 reset ( ) {
474504 this . energy = 0
475505 this . timer = Date . now ( )
0 commit comments