diff --git a/src/config/config.h b/src/config/config.h index 6c0ebe355..b50899f1f 100644 --- a/src/config/config.h +++ b/src/config/config.h @@ -257,13 +257,6 @@ // *************0- 15 range #define LED_BRIGHTNESS 15 -// *************Comment out to disable pid tuning gestures - originally created by SilverAG -#define PID_GESTURE_TUNING -// *************Comment out to adjust each axis individually - otherwise they move at the same time -#define COMBINE_PITCH_ROLL_PID_TUNING -// *************Feel free to change 1.0 value to your liking -#define PID_TUNING_ADJUST_AMOUNT 1.0 // fixed inc/dec values for PID tuning - // x (micro)seconds after loss of tx or low bat before buzzer starts #define BUZZER_DELAY 30e6 diff --git a/src/flight/gesture_detect.c b/src/flight/gesture_detect.c index a546d98fc..98a22d8f8 100644 --- a/src/flight/gesture_detect.c +++ b/src/flight/gesture_detect.c @@ -53,13 +53,6 @@ static const uint8_t commands[GESTURE_MAX][GSIZE] = { [GESTURE_RRR] = {GESTURE_CENTER_IDLE, GESTURE_RIGHT, GESTURE_CENTER, GESTURE_RIGHT, GESTURE_CENTER, GESTURE_RIGHT, GESTURE_CENTER}, // Refresh OSD [GESTURE_LRL] = {GESTURE_CENTER_IDLE, GESTURE_LEFT, GESTURE_CENTER, GESTURE_RIGHT, GESTURE_CENTER, GESTURE_LEFT, GESTURE_CENTER}, - -#ifdef PID_GESTURE_TUNING - [GESTURE_UDU] = {GESTURE_CENTER_IDLE, GESTURE_UP, GESTURE_CENTER, GESTURE_DOWN, GESTURE_CENTER, GESTURE_UP, GESTURE_CENTER}, - [GESTURE_UDD] = {GESTURE_CENTER_IDLE, GESTURE_UP, GESTURE_CENTER, GESTURE_DOWN, GESTURE_CENTER, GESTURE_DOWN, GESTURE_CENTER}, - [GESTURE_UDR] = {GESTURE_CENTER_IDLE, GESTURE_UP, GESTURE_CENTER, GESTURE_DOWN, GESTURE_CENTER, GESTURE_RIGHT, GESTURE_CENTER}, - [GESTURE_UDL] = {GESTURE_CENTER_IDLE, GESTURE_UP, GESTURE_CENTER, GESTURE_DOWN, GESTURE_CENTER, GESTURE_LEFT, GESTURE_CENTER}, -#endif }; static const uint8_t osd_commands[OSD_INPUT_MAX][OSD_GSIZE] = { diff --git a/src/flight/gestures.c b/src/flight/gestures.c index 67b5316f2..e22880b4b 100644 --- a/src/flight/gestures.c +++ b/src/flight/gestures.c @@ -11,7 +11,7 @@ #include "util/util.h" void gestures() { - static bool pid_gestures_used = false; + static bool skip_calib = false; const int32_t command = gestures_detect(); if (command == GESTURE_NONE) { @@ -25,30 +25,24 @@ void gestures() { switch (command) { case GESTURE_DDD: { // skip accel calibration if pid gestures used - if (!pid_gestures_used) { + if (!skip_calib) { sixaxis_gyro_cal(); // for flashing lights sixaxis_acc_cal(); } else { led_flash(); - pid_gestures_used = false; + skip_calib = false; } flash_save(); flash_load(); - // reset flash numbers - extern int number_of_increments[3][3]; - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) - number_of_increments[i][j] = 0; - // reset loop time looptime_reset(); break; } case GESTURE_UUU: { bind_storage.bind_saved = !bind_storage.bind_saved; - pid_gestures_used = true; + skip_calib = true; led_flash(); break; } @@ -72,51 +66,5 @@ void gestures() { ; break; } -#ifdef PID_GESTURE_TUNING - case GESTURE_UDU: { - // Cycle to next pid term (P I D) - const uint8_t index = next_pid_term(); - if (index) { - led_blink(index); - } else { - led_flash(); - } - pid_gestures_used = true; - break; - } - case GESTURE_UDD: { - // Cycle to next axis (Roll Pitch Yaw) - const uint8_t index = next_pid_axis(); - if (index) { - led_blink(index); - } else { - led_flash(); - } - pid_gestures_used = true; - break; - } - case GESTURE_UDR: { - // Increase by 10% - const uint8_t index = increase_pid(); - if (index) { - led_blink(index); - } else { - led_flash(); - } - pid_gestures_used = true; - break; - } - case GESTURE_UDL: { - // Descrease by 10% - const uint8_t index = decrease_pid(); - if (index) { - led_blink(index); - } else { - led_flash(); - } - pid_gestures_used = true; - break; - } -#endif } } diff --git a/src/flight/gestures.h b/src/flight/gestures.h index 909b0c1e3..9db442d10 100644 --- a/src/flight/gestures.h +++ b/src/flight/gestures.h @@ -13,12 +13,6 @@ typedef enum { GESTURE_RRD, GESTURE_RRR, GESTURE_LRL, -#ifdef PID_GESTURE_TUNING - GESTURE_UDU, - GESTURE_UDD, - GESTURE_UDR, - GESTURE_UDL, -#endif GESTURE_MAX, } gestures_t; diff --git a/src/flight/pid.c b/src/flight/pid.c index 4d51d2fc3..d19d0486f 100644 --- a/src/flight/pid.c +++ b/src/flight/pid.c @@ -23,10 +23,6 @@ extern profile_t profile; float timefactor; -int number_of_increments[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; -int current_pid_axis = 0; -int current_pid_term = 0; - // "p term setpoint weighting" 0.0 - 1.0 where 1.0 = normal pid static const float setpoint_weigth_brushed[3] = {0.93, 0.93, 0.9}; // BRUSHED FREESTYLE // float setpoint_weigth_brushed[3] = { 0.97 , 0.98 , 0.95}; //BRUSHED RACE @@ -274,95 +270,3 @@ void pid_calc() { pid(1); pid(2); } - -// below are functions used with gestures for changing pids by a percentage - -// Cycle through P / I / D - The initial value is P -// The return value is the currently selected TERM (after setting the next one) -// 1: P -// 2: I -// 3: D -// The return value is used to blink the leds in main.c -int next_pid_term() { - current_pid_term++; - if (current_pid_term == 3) { - current_pid_term = 0; - } - return current_pid_term + 1; -} - -vec3_t *current_pid_term_pointer() { - switch (current_pid_term) { - case 0: - return &profile_current_pid_rates()->kp; - case 1: - return &profile_current_pid_rates()->ki; - case 2: - return &profile_current_pid_rates()->kd; - } - return &profile_current_pid_rates()->kp; -} - -// Cycle through the axis - Initial is Roll -// Return value is the selected axis, after setting the next one. -// 1: Roll -// 2: Pitch -// 3: Yaw -// The return value is used to blink the leds in main.c -int next_pid_axis() { - const int size = 3; - if (current_pid_axis == size - 1) { - current_pid_axis = 0; - } else { -#ifdef COMBINE_PITCH_ROLL_PID_TUNING - if (current_pid_axis < 2) { - // Skip axis == 1 which is roll, and go directly to 2 (Yaw) - current_pid_axis = 2; - } -#else - current_pid_axis++; -#endif - } - - return current_pid_axis + 1; -} - -float adjust_rounded_pid(float input, float adjust_amount) { - const float value = (int)(input * 100.0f + 0.5f); - const float result = (float)(value + (100.0f * adjust_amount)) / 100.0f; - - if ((int)(result * 100.0f) <= 0) - return 0; - - return result; -} - -int change_pid_value(int increase) { - float pid_adjustment = (float)PID_TUNING_ADJUST_AMOUNT; - if (increase) { - number_of_increments[current_pid_term][current_pid_axis]++; - } else { - number_of_increments[current_pid_term][current_pid_axis]--; - pid_adjustment = -pid_adjustment; - } - - current_pid_term_pointer()->axis[current_pid_axis] = adjust_rounded_pid(current_pid_term_pointer()->axis[current_pid_axis], pid_adjustment); - -#ifdef COMBINE_PITCH_ROLL_PID_TUNING - if (current_pid_axis == 0) - current_pid_term_pointer()->axis[current_pid_axis + 1] = adjust_rounded_pid(current_pid_term_pointer()->axis[current_pid_axis + 1], pid_adjustment); -#endif - return abs(number_of_increments[current_pid_term][current_pid_axis]); -} - -// Increase currently selected term, for the currently selected axis, (by functions above) by 1 point -// The return value, is absolute number of times the specific term/axis was increased or decreased. For example, if P for Roll was increased by 1 point twice, -// And then reduced by 1 point 3 times, the return value would be 1 - The user has to track if the overall command was increase or decrease -int increase_pid() { - return change_pid_value(1); -} - -// Same as increase_pid but... you guessed it... decrease! -int decrease_pid() { - return change_pid_value(0); -} diff --git a/src/flight/pid.h b/src/flight/pid.h index 13979df81..ba17373cd 100644 --- a/src/flight/pid.h +++ b/src/flight/pid.h @@ -5,8 +5,3 @@ void rotateErrors(); void pid_init(); void pid_precalc(); void pid_calc(); - -int next_pid_term(); // Return value : 0 - p, 1 - i, 2 - d -int next_pid_axis(); // Return value : 0 - Roll, 1 - Pitch, 2 - Yaw -int increase_pid(); -int decrease_pid(); \ No newline at end of file diff --git a/src/osd/render.c b/src/osd/render.c index 776321b41..b74175bfc 100644 --- a/src/osd/render.c +++ b/src/osd/render.c @@ -274,12 +274,6 @@ void osd_save_exit() { flash_save(); flash_load(); - // reset flash numbers for pids - extern int number_of_increments[3][3]; - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) - number_of_increments[i][j] = 0; - // reset loop time - maybe not necessary cause it gets reset in the next screen clear looptime_reset(); diff --git a/src/rx/frsky_d8.c b/src/rx/frsky_d8.c index f772b8728..088611968 100644 --- a/src/rx/frsky_d8.c +++ b/src/rx/frsky_d8.c @@ -14,7 +14,7 @@ // these will get absimal range without pa/lna #define FRSKY_ENABLE_TELEMETRY -#define FRSKY_ENABLE_HUB_TELEMETRY +// #define FRSKY_ENABLE_HUB_TELEMETRY #define FRSKY_D8_CHANNEL_COUNT 8 #define FRSKY_D8_HUB_FIRST_USER_ID 0x31 @@ -113,46 +113,7 @@ static uint8_t frsky_d8_hub_encode(uint8_t *buf, uint8_t data) { } static uint8_t frsky_d8_append_hub_telemetry(uint8_t telemetry_id, uint8_t *buf) { - static uint8_t pid_axis = 0; - extern vec3_t *current_pid_term_pointer(); - - extern int current_pid_term; - extern int current_pid_axis; - - uint8_t size = 0; - buf[size++] = 0; - buf[size++] = telemetry_id; - - if (pid_axis >= 3) { - const int16_t term = current_pid_term; - const int16_t axis = current_pid_axis; - - buf[size++] = 0x5E; - buf[size++] = FRSKY_D8_HUB_FIRST_USER_ID + 0; - buf[size++] = (uint8_t)(term & 0xff); - buf[size++] = (uint8_t)(term >> 8); - buf[size++] = 0x5E; - buf[size++] = 0x5E; - buf[size++] = FRSKY_D8_HUB_FIRST_USER_ID + 1; - buf[size++] = (uint8_t)(axis & 0xff); - buf[size++] = (uint8_t)(axis >> 8); - buf[size++] = 0x5E; - - pid_axis = 0; - } else { - const int16_t pidk = (int16_t)(current_pid_term_pointer()->axis[pid_axis] * 1000); - buf[size++] = 0x5E; - buf[size++] = FRSKY_D8_HUB_FIRST_USER_ID + 2 + pid_axis; - size += frsky_d8_hub_encode(buf + size, (uint8_t)(pidk & 0xff)); - size += frsky_d8_hub_encode(buf + size, (uint8_t)(pidk >> 8)); - buf[size++] = 0x5E; - - pid_axis++; - } - - // write size - buf[0] = size - 2; - return size; + return 0; } #endif