Browse Source

Fixed: throttle value mismatched causing over 2000 and also cleaned up the code.

master
Englebert 1 year ago
parent
commit
cc1b1d62d9
  1. BIN
      src/.main.cpp.swp
  2. 109
      src/main.cpp

BIN
src/.main.cpp.swp

109
src/main.cpp

@ -576,84 +576,47 @@ void taskButton(void *pvParameters) {
sbusData.ch17 = true;
sbusData.ch18 = false;
//// sbus.rcCommand[THROTTLE] = incomingReadings.throttle;
if(throttle_steps > max_throttle) {
max_throttle = throttle_steps;
} else if(throttle_steps < min_throttle) {
min_throttle = throttle_steps;
}
throttle_val = map(throttle_steps, min_throttle, max_throttle, 1000, 2000) - trim_throttle;
/**
throttle_val_tmp = map(throttle_steps, min_throttle, max_throttle, 1000, 2000);
if(throttle_val - throttle_val_tmp > RC_DEADBAND) {
throttle_val = throttle_val_tmp;
} else {
if(throttle_val_tmp - throttle_val > RC_DEADBAND) {
throttle_val = throttle_val_tmp;
}
}
**/
sbusData.ch[1] = throttle_val;
//// sbus.rcCommand[YAW] = incomingReadings.yaw;
if(yaw_steps > max_yaw) {
max_yaw = yaw_steps;
} else if(yaw_steps < min_yaw) {
min_yaw = yaw_steps;
}
yaw_val = map(yaw_steps, min_yaw, max_yaw, 1000, 2000) + trim_yaw;
/**
yaw_val_tmp = map(yaw_steps, min_yaw, max_yaw, 1000, 2000);
if(yaw_val - yaw_val_tmp > RC_DEADBAND) {
yaw_val = yaw_val_tmp;
} else {
if(yaw_val_tmp - yaw_val > RC_DEADBAND) {
yaw_val = yaw_val_tmp;
pitch_val = map(pitch_steps, min_pitch, max_pitch, 1000, 2000) - trim_pitch;
roll_val = map(roll_steps, min_roll, max_roll, 1000, 2000) + trim_roll;
// Only process this when is at the trimming screen
// SCREEN_GIMBALTRIM_THROTTLEYAW and SCREEN_GIMBALTRIM_PITCHROLL
if(
current_screen == SCREEN_GIMBALTRIM_THROTTLEYAW ||
current_screen == SCREEN_GIMBALTRIM_PITCHROLL
) {
if(throttle_steps > max_throttle) {
max_throttle = throttle_steps;
} else if(throttle_steps < min_throttle) {
min_throttle = throttle_steps;
}
}
**/
sbusData.ch[0] = yaw_val;
//// sbus.rcCommand[PITCH] = incomingReadings.pitch;
if(pitch_steps > max_pitch) {
max_pitch = pitch_steps;
} else if(pitch_steps < min_pitch) {
min_pitch = pitch_steps;
}
pitch_val = map(pitch_steps, min_pitch, max_pitch, 1000, 2000) + trim_pitch;
/**
pitch_val_tmp = map(pitch_steps, min_pitch, max_pitch, 1000, 2000);
if(pitch_val - pitch_val_tmp > RC_DEADBAND) {
pitch_val = pitch_val_tmp;
} else {
if(pitch_val_tmp - pitch_val > RC_DEADBAND) {
pitch_val = pitch_val_tmp;
if(yaw_steps > max_yaw) {
max_yaw = yaw_steps;
} else if(yaw_steps < min_yaw) {
min_yaw = yaw_steps;
}
}
**/
sbusData.ch[2] = pitch_val;
//// sbus.rcCommand[ROLL] = incomingReadings.roll;
if(roll_steps > max_roll) {
max_roll = roll_steps;
} else if(roll_steps < min_roll) {
min_roll = roll_steps;
}
roll_val = map(roll_steps, min_roll, max_roll, 1000, 2000) + trim_roll;
/**
roll_val_tmp = map(roll_steps, min_roll, max_roll, 1000, 2000);
if(roll_val - roll_val_tmp > RC_DEADBAND) {
roll_val = roll_val_tmp;
} else {
if(roll_val_tmp - roll_val > RC_DEADBAND) {
roll_val = roll_val_tmp;
if(pitch_steps > max_pitch) {
max_pitch = pitch_steps;
} else if(pitch_steps < min_pitch) {
min_pitch = pitch_steps;
}
if(roll_steps > max_roll) {
max_roll = roll_steps;
} else if(roll_steps < min_roll) {
min_roll = roll_steps;
}
}
**/
// Some values are sent in negative to sync the graphical position
sbusData.ch[1] = map(throttle_val, 1000, 2000, 2000, 1000);
sbusData.ch[0] = yaw_val;
sbusData.ch[2] = map(pitch_val, 1000, 2000, 2000, 1000);
sbusData.ch[3] = roll_val;
sbusData.ch[4] = (toggle_buttons[TOGGLE_A] & 0x01) ? 2000 : 1000; // Toggle A
@ -1434,6 +1397,7 @@ void screenGimbalTrimThrottleYaw(void) {
show_gimbal_left();
show_gimbal_left_toggles();
display.setColor(WHITE);
// Show the bars - 45 clicks, 23 = 0, less than 23 are negative and more than 23 are positive
display.drawRect(66, 16, 45, 16);
display.drawRect(66, 32, 45, 16);
@ -1485,6 +1449,7 @@ void screenGimbalTrimPitchRoll(void) {
show_gimbal_right_toggles();
// Show the bars - 45 clicks, 23 = 0, less than 23 are negative and more than 23 are positive
display.setColor(WHITE);
display.drawRect(17, 16, 45, 16);
display.drawRect(17, 32, 45, 16);

Loading…
Cancel
Save