diff --git a/js/flightlog.js b/js/flightlog.js index 7d3c3887..a4f3375e 100644 --- a/js/flightlog.js +++ b/js/flightlog.js @@ -1146,8 +1146,8 @@ FlightLog.prototype.rcCommandRawToThrottle = function(value) { }; FlightLog.prototype.rcMotorRawToPct = function(value) { - // Motor displayed as percentage - return Math.min(Math.max(((value - this.getSysConfig().motorOutput[0]) / (this.getSysConfig().motorOutput[1] - this.getSysConfig().motorOutput[0])) * 100.0, 0.0),100.0); + // Motor displayed as percentage + return ((value - DSHOT_MIN_VALUE) / DSHOT_RANGE) * 100; }; FlightLog.prototype.getPIDPercentage = function(value) { diff --git a/js/flightlog_fielddefs.js b/js/flightlog_fielddefs.js index a7d05990..1bf06642 100644 --- a/js/flightlog_fielddefs.js +++ b/js/flightlog_fielddefs.js @@ -10,6 +10,12 @@ function makeReadOnly(x) { return x; } +// Some constants used at different places +const DSHOT_MIN_VALUE = 48; +const DSHOT_MAX_VALUE = 2047; +const DSHOT_RANGE = DSHOT_MAX_VALUE - DSHOT_MIN_VALUE; + +// Fields definitions for lists var FlightLogEvent = makeReadOnly({ SYNC_BEEP: 0, diff --git a/js/graph_config.js b/js/graph_config.js index def6cd8b..c440a30c 100644 --- a/js/graph_config.js +++ b/js/graph_config.js @@ -261,9 +261,9 @@ GraphConfig.load = function(config) { try { if (fieldName.match(/^motor\[/)) { return { - offset: -(sysConfig.motorOutput[1] + sysConfig.motorOutput[0]) / 2, + offset: -(DSHOT_MIN_VALUE + (DSHOT_RANGE / 2)), power: 1.0, - inputRange: (sysConfig.motorOutput[1] - sysConfig.motorOutput[0]) / 2, + inputRange: DSHOT_RANGE / 2, outputRange: 1.0 }; } else if (fieldName.match(/^servo\[/)) {