Skip to content

Commit

Permalink
Show the limit in motors graph
Browse files Browse the repository at this point in the history
  • Loading branch information
McGiverGim committed Sep 23, 2020
1 parent a063ae5 commit e0de249
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions js/flightlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions js/flightlog_fielddefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions js/graph_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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\[/)) {
Expand Down

0 comments on commit e0de249

Please sign in to comment.