From ec713be3eab4ba7525ae2182eeba4c944b0703e0 Mon Sep 17 00:00:00 2001 From: Les Newell Date: Tue, 10 Dec 2013 19:58:05 +0000 Subject: [PATCH 01/45] OP-984 Added data UAV object for current stabilization bank --- .../modules/Stabilization/inc/stabilization.h | 36 ++++++ flight/modules/Stabilization/stabilization.c | 105 ++++++++++++------ .../uavobjectdefinition/stabilizationbank.xml | 74 ++++++++++++ 3 files changed, 179 insertions(+), 36 deletions(-) create mode 100644 shared/uavobjectdefinition/stabilizationbank.xml diff --git a/flight/modules/Stabilization/inc/stabilization.h b/flight/modules/Stabilization/inc/stabilization.h index 396a91e89..51fafa60f 100644 --- a/flight/modules/Stabilization/inc/stabilization.h +++ b/flight/modules/Stabilization/inc/stabilization.h @@ -37,6 +37,42 @@ enum { ROLL, PITCH, YAW, MAX_AXES }; int32_t StabilizationInitialize(); +typedef struct stab_rate_pid{ + float Kp; + float Ki; + float Kd; + float ILimit; +}; + +typedef struct stab_att_pid{ + float Kp; + float Ki; + float ILimit; +}; + +typedef struct stab_rpy{ + float Roll; + float Pitch; + float Yaw; +}; + +typedef struct stab_bank { + float RollMax; + float PitchMax; + float YawMax; + struct{ + float Roll; + float Pitch; + float Yaw; + }; + float ManualRate; + float iAccumulator; + float lastErr; + float lastDer; +}; + + + #endif // STABILIZATION_H /** diff --git a/flight/modules/Stabilization/stabilization.c b/flight/modules/Stabilization/stabilization.c index 3ca9f3afc..36ec9ceed 100644 --- a/flight/modules/Stabilization/stabilization.c +++ b/flight/modules/Stabilization/stabilization.c @@ -47,6 +47,7 @@ #include "manualcontrol.h" // Just to get a macro #include "taskinfo.h" + // Math libraries #include "CoordinateConversions.h" #include "pid.h" @@ -71,9 +72,6 @@ #define TASK_PRIORITY (tskIDLE_PRIORITY + 4) #define FAILSAFE_TIMEOUT_MS 30 -enum { PID_RATE_ROLL, PID_RATE_PITCH, PID_RATE_YAW, PID_ROLL, PID_PITCH, PID_YAW, PID_MAX }; - - // Private variables static xTaskHandle taskHandle; static StabilizationSettingsData settings; @@ -88,12 +86,14 @@ bool lowThrottleZeroIntegral; bool lowThrottleZeroAxis[MAX_AXES]; float vbar_decay = 0.991f; struct pid pids[PID_MAX]; +int flight_mode = 0; // Private functions static void stabilizationTask(void *parameters); static float bound(float val, float range); static void ZeroPids(void); static void SettingsUpdatedCb(UAVObjEvent *ev); +static void UpdatePids(StabilizationSettings* settings); /** * Module initialization @@ -484,42 +484,75 @@ static float bound(float val, float range) return val; } +static void UpdatePids(StabilizationSettings* settings) +{ + + enum{RATE_P, RATE_I, RATE_D, RATE_LIMIT, RATE_OFFSET}; + enum{ATT_P, ATT_I, ATT_LIMIT, ATT_OFFSET}; + + int offset = flight_mode * RATE_OFFSET; + // Set the roll rate PID constants + float* pid = &settings.RollRatePID.Kp1; + pid += offset; + pid_configure(&pids[PID_RATE_ROLL], + pid[RATE_P], + pid[RATE_I], + pid[RATE_D], + pid[RATE_LIMIT]); + + // Set the pitch rate PID constants + pid = &settings.PitchRatePID.Kp1; + pid += offset; + pid_configure(&pids[PID_RATE_PITCH], + pid[RATE_P], + pid[RATE_I], + pid[RATE_D], + pid[RATE_LIMIT]); + + // Set the yaw rate PID constants + pid = &settings.YawRatePID.Kp1; + pid += offset; + pid_configure(&pids[PID_RATE_YAW], + pid[RATE_P], + pid[RATE_I], + pid[RATE_D], + pid[RATE_LIMIT]); + + offset = flight_mode * ATT_OFFSET; + + // Set the roll attitude PI constants + pid = &settings.RollPI.Kp1; + pid += offset; + pid_configure(&pids[PID_ROLL], + pid[ATT_P], + pid[ATT_I], + 0, + pid[ATT_LIMIT]); + + // Set the pitch attitude PI constants + pid = &settings.PitchPI.Kp1; + pid += offset; + pid_configure(&pids[PID_PITCH], + pid[ATT_P], + pid[ATT_I], + 0, + pid[ATT_LIMIT]); + + + // Set the yaw attitude PI constants + pid = &settings.YawPI.Kp1; + pid += offset; + pid_configure(&pids[PID_YAW], + pid[ATT_P], + pid[ATT_I], + 0, + pid[ATT_LIMIT]); +} + static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) { StabilizationSettingsGet(&settings); - - // Set the roll rate PID constants - pid_configure(&pids[PID_RATE_ROLL], settings.RollRatePID.Kp, - settings.RollRatePID.Ki, - pids[PID_RATE_ROLL].d = settings.RollRatePID.Kd, - pids[PID_RATE_ROLL].iLim = settings.RollRatePID.ILimit); - - // Set the pitch rate PID constants - pid_configure(&pids[PID_RATE_PITCH], settings.PitchRatePID.Kp, - pids[PID_RATE_PITCH].i = settings.PitchRatePID.Ki, - pids[PID_RATE_PITCH].d = settings.PitchRatePID.Kd, - pids[PID_RATE_PITCH].iLim = settings.PitchRatePID.ILimit); - - // Set the yaw rate PID constants - pid_configure(&pids[PID_RATE_YAW], settings.YawRatePID.Kp, - pids[PID_RATE_YAW].i = settings.YawRatePID.Ki, - pids[PID_RATE_YAW].d = settings.YawRatePID.Kd, - pids[PID_RATE_YAW].iLim = settings.YawRatePID.ILimit); - - // Set the roll attitude PI constants - pid_configure(&pids[PID_ROLL], settings.RollPI.Kp, - settings.RollPI.Ki, 0, - pids[PID_ROLL].iLim = settings.RollPI.ILimit); - - // Set the pitch attitude PI constants - pid_configure(&pids[PID_PITCH], settings.PitchPI.Kp, - pids[PID_PITCH].i = settings.PitchPI.Ki, 0, - settings.PitchPI.ILimit); - - // Set the yaw attitude PI constants - pid_configure(&pids[PID_YAW], settings.YawPI.Kp, - settings.YawPI.Ki, 0, - settings.YawPI.ILimit); + UpdatePids(&settings); // Set up the derivative term pid_configure_derivative(settings.DerivativeCutoff, settings.DerivativeGamma); diff --git a/shared/uavobjectdefinition/stabilizationbank.xml b/shared/uavobjectdefinition/stabilizationbank.xml new file mode 100644 index 000000000..f05a06a7c --- /dev/null +++ b/shared/uavobjectdefinition/stabilizationbank.xml @@ -0,0 +1,74 @@ + + + Currently selected PID bank + + + + + + + + + + + + + + + + + + + + + + PID settings used by the Stabilization module to combine the @ref AttitudeActual and @ref AttitudeDesired to compute @ref ActuatorDesired + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From fc1a4ce3bb44605c891072ac47db8f46d84b84f5 Mon Sep 17 00:00:00 2001 From: Les Newell Date: Tue, 10 Dec 2013 20:00:19 +0000 Subject: [PATCH 02/45] OP-984 cleaned up stabilization bank object --- .../uavobjectdefinition/stabilizationbank.xml | 51 ------------------- 1 file changed, 51 deletions(-) diff --git a/shared/uavobjectdefinition/stabilizationbank.xml b/shared/uavobjectdefinition/stabilizationbank.xml index f05a06a7c..027d19372 100644 --- a/shared/uavobjectdefinition/stabilizationbank.xml +++ b/shared/uavobjectdefinition/stabilizationbank.xml @@ -20,55 +20,4 @@ - - - PID settings used by the Stabilization module to combine the @ref AttitudeActual and @ref AttitudeDesired to compute @ref ActuatorDesired - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 114c0ac5617c4df810cb6dbb4f14744160947ec1 Mon Sep 17 00:00:00 2001 From: Les Newell Date: Tue, 10 Dec 2013 20:07:56 +0000 Subject: [PATCH 03/45] OP-984 Added multiple banks code to stabilization.c --- flight/modules/Stabilization/stabilization.c | 224 +++++++++++++------ 1 file changed, 159 insertions(+), 65 deletions(-) diff --git a/flight/modules/Stabilization/stabilization.c b/flight/modules/Stabilization/stabilization.c index 36ec9ceed..c8db700a3 100644 --- a/flight/modules/Stabilization/stabilization.c +++ b/flight/modules/Stabilization/stabilization.c @@ -35,6 +35,7 @@ #include #include "stabilization.h" #include "stabilizationsettings.h" +#include "stabilizationbank.h" #include "actuatordesired.h" #include "ratedesired.h" #include "relaytuning.h" @@ -47,7 +48,6 @@ #include "manualcontrol.h" // Just to get a macro #include "taskinfo.h" - // Math libraries #include "CoordinateConversions.h" #include "pid.h" @@ -72,6 +72,11 @@ #define TASK_PRIORITY (tskIDLE_PRIORITY + 4) #define FAILSAFE_TIMEOUT_MS 30 +enum { PID_RATE_ROLL, PID_RATE_PITCH, PID_RATE_YAW, PID_ROLL, PID_PITCH, PID_YAW, PID_MAX }; +enum{RATE_P, RATE_I, RATE_D, RATE_LIMIT, RATE_OFFSET}; +enum{ATT_P, ATT_I, ATT_LIMIT, ATT_OFFSET}; + + // Private variables static xTaskHandle taskHandle; static StabilizationSettingsData settings; @@ -86,14 +91,14 @@ bool lowThrottleZeroIntegral; bool lowThrottleZeroAxis[MAX_AXES]; float vbar_decay = 0.991f; struct pid pids[PID_MAX]; -int flight_mode = 0; // Private functions static void stabilizationTask(void *parameters); static float bound(float val, float range); static void ZeroPids(void); +static void BankChanged(); static void SettingsUpdatedCb(UAVObjEvent *ev); -static void UpdatePids(StabilizationSettings* settings); +static void BankUpdatedCb(UAVObjEvent *ev); /** * Module initialization @@ -111,6 +116,8 @@ int32_t StabilizationStart() StabilizationSettingsConnectCallback(SettingsUpdatedCb); SettingsUpdatedCb(StabilizationSettingsHandle()); + StabilizationBankConnectCallback(BankUpdatedCb); + // Start main task xTaskCreate(stabilizationTask, (signed char *)"Stabilization", STACK_SIZE_BYTES / 4, NULL, TASK_PRIORITY, &taskHandle); PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_STABILIZATION, taskHandle); @@ -159,6 +166,8 @@ static void stabilizationTask(__attribute__((unused)) void *parameters) AttitudeStateData attitudeState; GyroStateData gyroStateData; FlightStatusData flightStatus; + StabilizationBankData stabBank; + #ifdef REVOLUTION AirspeedStateData airspeedState; @@ -188,6 +197,7 @@ static void stabilizationTask(__attribute__((unused)) void *parameters) StabilizationDesiredGet(&stabDesired); AttitudeStateGet(&attitudeState); GyroStateGet(&gyroStateData); + StabilizationBankGet(&stabBank); #ifdef DIAG_RATEDESIRED RateDesiredGet(&rateDesired); #endif @@ -288,7 +298,7 @@ static void stabilizationTask(__attribute__((unused)) void *parameters) // Store to rate desired variable for storing to UAVO rateDesiredAxis[i] = - bound(attitudeDesiredAxis[i], cast_struct_to_array(settings.ManualRate, settings.ManualRate.Roll)[i]); + bound(attitudeDesiredAxis[i], cast_struct_to_array(stabBank.ManualRate, stabBank.ManualRate.Roll)[i]); // Compute the inner loop actuatorDesiredAxis[i] = pid_apply_setpoint(&pids[PID_RATE_ROLL + i], speedScaleFactor, rateDesiredAxis[i], gyro_filtered[i], dT); @@ -305,7 +315,7 @@ static void stabilizationTask(__attribute__((unused)) void *parameters) // Compute the outer loop rateDesiredAxis[i] = pid_apply(&pids[PID_ROLL + i], local_error[i], dT); rateDesiredAxis[i] = bound(rateDesiredAxis[i], - cast_struct_to_array(settings.MaximumRate, settings.MaximumRate.Roll)[i]); + cast_struct_to_array(stabBank.MaximumRate, stabBank.MaximumRate.Roll)[i]); // Compute the inner loop actuatorDesiredAxis[i] = pid_apply_setpoint(&pids[PID_RATE_ROLL + i], speedScaleFactor, rateDesiredAxis[i], gyro_filtered[i], dT); @@ -357,7 +367,7 @@ static void stabilizationTask(__attribute__((unused)) void *parameters) } rateDesiredAxis[i] = bound(rateDesiredAxis[i], - cast_struct_to_array(settings.ManualRate, settings.ManualRate.Roll)[i]); + cast_struct_to_array(stabBank.ManualRate, stabBank.ManualRate.Roll)[i]); actuatorDesiredAxis[i] = pid_apply_setpoint(&pids[PID_RATE_ROLL + i], speedScaleFactor, rateDesiredAxis[i], gyro_filtered[i], dT); actuatorDesiredAxis[i] = bound(actuatorDesiredAxis[i], 1.0f); @@ -367,7 +377,7 @@ static void stabilizationTask(__attribute__((unused)) void *parameters) case STABILIZATIONDESIRED_STABILIZATIONMODE_RELAYRATE: // Store to rate desired variable for storing to UAVO rateDesiredAxis[i] = bound(attitudeDesiredAxis[i], - cast_struct_to_array(settings.ManualRate, settings.ManualRate.Roll)[i]); + cast_struct_to_array(stabBank.ManualRate, stabBank.ManualRate.Roll)[i]); // Run the relay controller which also estimates the oscillation parameters stabilization_relay_rate(rateDesiredAxis[i] - gyro_filtered[i], &actuatorDesiredAxis[i], i, reinit); @@ -383,7 +393,7 @@ static void stabilizationTask(__attribute__((unused)) void *parameters) // Compute the outer loop like attitude mode rateDesiredAxis[i] = pid_apply(&pids[PID_ROLL + i], local_error[i], dT); rateDesiredAxis[i] = bound(rateDesiredAxis[i], - cast_struct_to_array(settings.MaximumRate, settings.MaximumRate.Roll)[i]); + cast_struct_to_array(stabBank.MaximumRate, stabBank.MaximumRate.Roll)[i]); // Run the relay controller which also estimates the oscillation parameters stabilization_relay_rate(rateDesiredAxis[i] - gyro_filtered[i], &actuatorDesiredAxis[i], i, reinit); @@ -484,75 +494,159 @@ static float bound(float val, float range) return val; } -static void UpdatePids(StabilizationSettings* settings) +static void BankChanged() { + StabilizationBankData bank; + FlightStatusData flightStatus; - enum{RATE_P, RATE_I, RATE_D, RATE_LIMIT, RATE_OFFSET}; - enum{ATT_P, ATT_I, ATT_LIMIT, ATT_OFFSET}; + StabilizationBankGet(&bank); + FlightStatusGet(&flightStatus); - int offset = flight_mode * RATE_OFFSET; - // Set the roll rate PID constants - float* pid = &settings.RollRatePID.Kp1; - pid += offset; - pid_configure(&pids[PID_RATE_ROLL], - pid[RATE_P], - pid[RATE_I], - pid[RATE_D], - pid[RATE_LIMIT]); + int offset = flightStatus.FlightMode; + bank.RollMax = settings.RollMax[offset]; + bank.PitchMax = settings.PitchMax[offset]; + bank.YawMax = settings.YawMax[offset]; - // Set the pitch rate PID constants - pid = &settings.PitchRatePID.Kp1; - pid += offset; - pid_configure(&pids[PID_RATE_PITCH], - pid[RATE_P], - pid[RATE_I], - pid[RATE_D], - pid[RATE_LIMIT]); + offset = flightStatus.FlightMode * MAX_AXES; + memcpy(&bank.ManualRate, (&settings.ManualRate) + offset, sizeof(float) * MAX_AXES); + memcpy(&bank.MaximumRate, (&settings.MaximumRate) + offset, sizeof(float) * MAX_AXES); - // Set the yaw rate PID constants - pid = &settings.YawRatePID.Kp1; - pid += offset; - pid_configure(&pids[PID_RATE_YAW], - pid[RATE_P], - pid[RATE_I], - pid[RATE_D], - pid[RATE_LIMIT]); + offset = flightStatus.FlightMode * RATE_OFFSET; + memcpy(&bank.RollRatePID, (&settings.RollRatePID) + offset, sizeof(float) * RATE_OFFSET); + memcpy(&bank.PitchRatePID, (&settings.PitchRatePID) + offset, sizeof(float) * RATE_OFFSET); + memcpy(&bank.YawRatePID, (&settings.YawRatePID) + offset, sizeof(float) * RATE_OFFSET); - offset = flight_mode * ATT_OFFSET; + offset = flightStatus.FlightMode * ATT_OFFSET; + memcpy(&bank.RollPI, (&settings.RollPI) + offset, sizeof(float) * ATT_OFFSET); + memcpy(&bank.PitchPI, (&settings.PitchPI) + offset, sizeof(float) * ATT_OFFSET); + memcpy(&bank.YawPI, (&settings.YawPI) + offset, sizeof(float) * ATT_OFFSET); - // Set the roll attitude PI constants - pid = &settings.RollPI.Kp1; - pid += offset; - pid_configure(&pids[PID_ROLL], - pid[ATT_P], - pid[ATT_I], - 0, - pid[ATT_LIMIT]); - - // Set the pitch attitude PI constants - pid = &settings.PitchPI.Kp1; - pid += offset; - pid_configure(&pids[PID_PITCH], - pid[ATT_P], - pid[ATT_I], - 0, - pid[ATT_LIMIT]); - - - // Set the yaw attitude PI constants - pid = &settings.YawPI.Kp1; - pid += offset; - pid_configure(&pids[PID_YAW], - pid[ATT_P], - pid[ATT_I], - 0, - pid[ATT_LIMIT]); + StabilizationBankSet(&bank); } +static void BankUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) +{ + StabilizationBankData bank; + FlightStatusData flightStatus; + + StabilizationBankGet(&bank); + FlightStatusGet(&flightStatus); + + bool change = false; + + int offset = flightStatus.FlightMode; + if(bank.RollMax != settings.RollMax[offset]) + { + change = true; + settings.RollMax[offset] = bank.RollMax; + } + if(bank.PitchMax != settings.PitchMax[offset]) + { + change = true; + settings.PitchMax[offset] = bank.PitchMax; + } + if(bank.YawMax != settings.YawMax[offset]) + { + change = true; + settings.YawMax[offset] = bank.YawMax; + } + + + offset = flightStatus.FlightMode * MAX_AXES; + if(memcmp(&bank.ManualRate, (&settings.ManualRate) + offset, sizeof(float) * MAX_AXES) != 0) + { + change = true; + memcpy((&settings.ManualRate) + offset, &bank.ManualRate, sizeof(float) * MAX_AXES); + } + if(memcmp(&bank.MaximumRate, (&settings.MaximumRate) + offset, sizeof(float) * MAX_AXES) != 0) + { + change = true; + memcpy((&settings.MaximumRate) + offset, &bank.MaximumRate, sizeof(float) * MAX_AXES); + } + + offset = flightStatus.FlightMode * RATE_OFFSET; + if(memcmp(&bank.RollRatePID, (&settings.RollRatePID) + offset, sizeof(float) * RATE_OFFSET) != 0) + { + change = true; + memcpy((&settings.RollRatePID) + offset, &bank.RollRatePID, sizeof(float) * RATE_OFFSET); + } + if(memcmp(&bank.PitchRatePID, (&settings.PitchRatePID) + offset, sizeof(float) * RATE_OFFSET) != 0) + { + change = true; + memcpy((&settings.PitchRatePID) + offset, &bank.PitchRatePID, sizeof(float) * RATE_OFFSET); + } + if(memcmp(&bank.YawRatePID, (&settings.YawRatePID) + offset, sizeof(float) * RATE_OFFSET) != 0) + { + change = true; + memcpy((&settings.YawRatePID) + offset, &bank.YawRatePID, sizeof(float) * RATE_OFFSET); + } + + offset = flightStatus.FlightMode * ATT_OFFSET; + if(memcmp(&bank.RollPI, (&settings.RollPI) + offset, sizeof(float) * ATT_OFFSET) != 0) + { + change = true; + memcpy((&settings.RollPI) + offset, &bank.RollPI, sizeof(float) * ATT_OFFSET); + } + if(memcmp(&bank.PitchPI, (&settings.PitchPI) + offset, sizeof(float) * ATT_OFFSET) != 0) + { + change = true; + memcpy((&settings.PitchPI) + offset, &bank.PitchPI, sizeof(float) * ATT_OFFSET); + } + if(memcmp(&bank.YawPI, (&settings.YawPI) + offset, sizeof(float) * ATT_OFFSET) != 0) + { + change = true; + memcpy((&settings.YawPI) + offset, &bank.YawPI, sizeof(float) * ATT_OFFSET); + } + + if(change) + { + StabilizationSettingsSet(&settings); + } +} + + static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) { StabilizationSettingsGet(&settings); - UpdatePids(&settings); + BankChanged(); + StabilizationBankData bank; + StabilizationBankGet(&bank); + + // Set the roll rate PID constants + pid_configure(&pids[PID_RATE_ROLL], bank.RollRatePID.Kp, + bank.RollRatePID.Ki, + bank.RollRatePID.Kd, + bank.RollRatePID.ILimit); + + // Set the pitch rate PID constants + pid_configure(&pids[PID_RATE_PITCH], bank.PitchRatePID.Kp, + bank.PitchRatePID.Ki, + bank.PitchRatePID.Kd, + bank.PitchRatePID.ILimit); + + // Set the yaw rate PID constants + pid_configure(&pids[PID_RATE_YAW], bank.YawRatePID.Kp, + bank.YawRatePID.Ki, + bank.YawRatePID.Kd, + bank.YawRatePID.ILimit); + + // Set the roll attitude PI constants + pid_configure(&pids[PID_ROLL], bank.RollPI.Kp, + bank.RollPI.Ki, + 0, + bank.RollPI.ILimit); + + // Set the pitch attitude PI constants + pid_configure(&pids[PID_PITCH], bank.PitchPI.Kp, + bank.PitchPI.Ki, + 0, + bank.PitchPI.ILimit); + + // Set the yaw attitude PI constants + pid_configure(&pids[PID_YAW], bank.YawPI.Kp, + bank.YawPI.Ki, + 0, + bank.YawPI.ILimit); // Set up the derivative term pid_configure_derivative(settings.DerivativeCutoff, settings.DerivativeGamma); From fddf61377e676e0e8c2fb92808d946aa2f612376 Mon Sep 17 00:00:00 2001 From: Les Newell Date: Tue, 10 Dec 2013 20:10:01 +0000 Subject: [PATCH 04/45] OP-984 More changes to stabilization.c for bank switching --- flight/modules/Stabilization/stabilization.c | 88 +++++++------------- 1 file changed, 29 insertions(+), 59 deletions(-) diff --git a/flight/modules/Stabilization/stabilization.c b/flight/modules/Stabilization/stabilization.c index c8db700a3..fd23680f3 100644 --- a/flight/modules/Stabilization/stabilization.c +++ b/flight/modules/Stabilization/stabilization.c @@ -91,6 +91,7 @@ bool lowThrottleZeroIntegral; bool lowThrottleZeroAxis[MAX_AXES]; float vbar_decay = 0.991f; struct pid pids[PID_MAX]; +int flight_mode = -1; // Private functions static void stabilizationTask(void *parameters); @@ -201,6 +202,12 @@ static void stabilizationTask(__attribute__((unused)) void *parameters) #ifdef DIAG_RATEDESIRED RateDesiredGet(&rateDesired); #endif + + if(flight_mode != flightStatus.FlightMode){ + BankChanged(); + flight_mode = flightStatus.FlightMode; + } + #ifdef REVOLUTION float speedScaleFactor; // Scale PID coefficients based on current airspeed estimation - needed for fixed wing planes @@ -496,11 +503,12 @@ static float bound(float val, float range) static void BankChanged() { - StabilizationBankData bank; + StabilizationBankData bank, oldBank; FlightStatusData flightStatus; StabilizationBankGet(&bank); FlightStatusGet(&flightStatus); + memcpy(&oldBank, &bank, sizeof(StabilizationBankData)); int offset = flightStatus.FlightMode; bank.RollMax = settings.RollMax[offset]; @@ -521,7 +529,11 @@ static void BankChanged() memcpy(&bank.PitchPI, (&settings.PitchPI) + offset, sizeof(float) * ATT_OFFSET); memcpy(&bank.YawPI, (&settings.YawPI) + offset, sizeof(float) * ATT_OFFSET); - StabilizationBankSet(&bank); +//Need to do this to prevent an infinite loop + if(memcmp(&oldBank, &bank, sizeof(StabilizationBankData)) != 0) + { + StabilizationBankSet(&bank); + } } static void BankUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) @@ -532,73 +544,31 @@ static void BankUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) StabilizationBankGet(&bank); FlightStatusGet(&flightStatus); - bool change = false; + StabilizationSettingsData oldSettings; + memcpy(&oldSettings, &settings, sizeof(StabilizationSettingsData)); int offset = flightStatus.FlightMode; - if(bank.RollMax != settings.RollMax[offset]) - { - change = true; - settings.RollMax[offset] = bank.RollMax; - } - if(bank.PitchMax != settings.PitchMax[offset]) - { - change = true; - settings.PitchMax[offset] = bank.PitchMax; - } - if(bank.YawMax != settings.YawMax[offset]) - { - change = true; - settings.YawMax[offset] = bank.YawMax; - } + settings.RollMax[offset] = bank.RollMax; + settings.PitchMax[offset] = bank.PitchMax; + settings.YawMax[offset] = bank.YawMax; offset = flightStatus.FlightMode * MAX_AXES; - if(memcmp(&bank.ManualRate, (&settings.ManualRate) + offset, sizeof(float) * MAX_AXES) != 0) - { - change = true; - memcpy((&settings.ManualRate) + offset, &bank.ManualRate, sizeof(float) * MAX_AXES); - } - if(memcmp(&bank.MaximumRate, (&settings.MaximumRate) + offset, sizeof(float) * MAX_AXES) != 0) - { - change = true; - memcpy((&settings.MaximumRate) + offset, &bank.MaximumRate, sizeof(float) * MAX_AXES); - } + memcpy((&settings.ManualRate) + offset, &bank.ManualRate, sizeof(float) * MAX_AXES); + memcpy((&settings.MaximumRate) + offset, &bank.MaximumRate, sizeof(float) * MAX_AXES); offset = flightStatus.FlightMode * RATE_OFFSET; - if(memcmp(&bank.RollRatePID, (&settings.RollRatePID) + offset, sizeof(float) * RATE_OFFSET) != 0) - { - change = true; - memcpy((&settings.RollRatePID) + offset, &bank.RollRatePID, sizeof(float) * RATE_OFFSET); - } - if(memcmp(&bank.PitchRatePID, (&settings.PitchRatePID) + offset, sizeof(float) * RATE_OFFSET) != 0) - { - change = true; - memcpy((&settings.PitchRatePID) + offset, &bank.PitchRatePID, sizeof(float) * RATE_OFFSET); - } - if(memcmp(&bank.YawRatePID, (&settings.YawRatePID) + offset, sizeof(float) * RATE_OFFSET) != 0) - { - change = true; - memcpy((&settings.YawRatePID) + offset, &bank.YawRatePID, sizeof(float) * RATE_OFFSET); - } + memcpy((&settings.RollRatePID) + offset, &bank.RollRatePID, sizeof(float) * RATE_OFFSET); + memcpy((&settings.PitchRatePID) + offset, &bank.PitchRatePID, sizeof(float) * RATE_OFFSET); + memcpy((&settings.YawRatePID) + offset, &bank.YawRatePID, sizeof(float) * RATE_OFFSET); offset = flightStatus.FlightMode * ATT_OFFSET; - if(memcmp(&bank.RollPI, (&settings.RollPI) + offset, sizeof(float) * ATT_OFFSET) != 0) - { - change = true; - memcpy((&settings.RollPI) + offset, &bank.RollPI, sizeof(float) * ATT_OFFSET); - } - if(memcmp(&bank.PitchPI, (&settings.PitchPI) + offset, sizeof(float) * ATT_OFFSET) != 0) - { - change = true; - memcpy((&settings.PitchPI) + offset, &bank.PitchPI, sizeof(float) * ATT_OFFSET); - } - if(memcmp(&bank.YawPI, (&settings.YawPI) + offset, sizeof(float) * ATT_OFFSET) != 0) - { - change = true; - memcpy((&settings.YawPI) + offset, &bank.YawPI, sizeof(float) * ATT_OFFSET); - } + memcpy((&settings.RollPI) + offset, &bank.RollPI, sizeof(float) * ATT_OFFSET); + memcpy((&settings.PitchPI) + offset, &bank.PitchPI, sizeof(float) * ATT_OFFSET); + memcpy((&settings.YawPI) + offset, &bank.YawPI, sizeof(float) * ATT_OFFSET); - if(change) +//Need to do this to prevent an infinite loop + if(memcmp(&oldSettings, &settings, sizeof(StabilizationSettingsData)) != 0) { StabilizationSettingsSet(&settings); } From f523ba949d8a4b50ae13e1e2ece28ddbafbba280 Mon Sep 17 00:00:00 2001 From: Les Newell Date: Tue, 10 Dec 2013 20:11:38 +0000 Subject: [PATCH 05/45] OP-984 Modified manualcontrol to use PID bank data object --- .../modules/Stabilization/inc/stabilization.h | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/flight/modules/Stabilization/inc/stabilization.h b/flight/modules/Stabilization/inc/stabilization.h index 51fafa60f..396a91e89 100644 --- a/flight/modules/Stabilization/inc/stabilization.h +++ b/flight/modules/Stabilization/inc/stabilization.h @@ -37,42 +37,6 @@ enum { ROLL, PITCH, YAW, MAX_AXES }; int32_t StabilizationInitialize(); -typedef struct stab_rate_pid{ - float Kp; - float Ki; - float Kd; - float ILimit; -}; - -typedef struct stab_att_pid{ - float Kp; - float Ki; - float ILimit; -}; - -typedef struct stab_rpy{ - float Roll; - float Pitch; - float Yaw; -}; - -typedef struct stab_bank { - float RollMax; - float PitchMax; - float YawMax; - struct{ - float Roll; - float Pitch; - float Yaw; - }; - float ManualRate; - float iAccumulator; - float lastErr; - float lastDer; -}; - - - #endif // STABILIZATION_H /** From b550e67056e73ecedd229dfc4905382d4d8373d8 Mon Sep 17 00:00:00 2001 From: Les Newell Date: Wed, 11 Dec 2013 11:56:15 +0000 Subject: [PATCH 06/45] OP-984 Updated txpid to handle pid banks --- flight/modules/TxPID/txpid.c | 83 +++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 38 deletions(-) diff --git a/flight/modules/TxPID/txpid.c b/flight/modules/TxPID/txpid.c index 125d921c0..c5865b61e 100644 --- a/flight/modules/TxPID/txpid.c +++ b/flight/modules/TxPID/txpid.c @@ -56,6 +56,7 @@ #include "accessorydesired.h" #include "manualcontrolcommand.h" #include "stabilizationsettings.h" +#include "stabilizationbank.h" #include "flightstatus.h" #include "hwsettings.h" @@ -163,11 +164,14 @@ static void updatePIDs(UAVObjEvent *ev) return; } + StabilizationBankData bank; + StabilizationBankGet(&bank); StabilizationSettingsData stab; StabilizationSettingsGet(&stab); AccessoryDesiredData accessory; - uint8_t needsUpdate = 0; + uint8_t needsUpdateBank = 0; + uint8_t needsUpdateStab = 0; // Loop through every enabled instance for (uint8_t i = 0; i < TXPIDSETTINGS_PIDS_NUMELEM; i++) { @@ -192,107 +196,110 @@ static void updatePIDs(UAVObjEvent *ev) switch (cast_struct_to_array(inst.PIDs, inst.PIDs.Instance1)[i]) { case TXPIDSETTINGS_PIDS_ROLLRATEKP: - needsUpdate |= update(&stab.RollRatePID.Kp, value); + needsUpdateBank |= update(&bank.RollRatePID.Kp, value); break; case TXPIDSETTINGS_PIDS_ROLLRATEKI: - needsUpdate |= update(&stab.RollRatePID.Ki, value); + needsUpdateBank |= update(&bank.RollRatePID.Ki, value); break; case TXPIDSETTINGS_PIDS_ROLLRATEKD: - needsUpdate |= update(&stab.RollRatePID.Kd, value); + needsUpdateBank |= update(&bank.RollRatePID.Kd, value); break; case TXPIDSETTINGS_PIDS_ROLLRATEILIMIT: - needsUpdate |= update(&stab.RollRatePID.ILimit, value); + needsUpdateBank |= update(&bank.RollRatePID.ILimit, value); break; case TXPIDSETTINGS_PIDS_ROLLATTITUDEKP: - needsUpdate |= update(&stab.RollPI.Kp, value); + needsUpdateBank |= update(&bank.RollPI.Kp, value); break; case TXPIDSETTINGS_PIDS_ROLLATTITUDEKI: - needsUpdate |= update(&stab.RollPI.Ki, value); + needsUpdateBank |= update(&bank.RollPI.Ki, value); break; case TXPIDSETTINGS_PIDS_ROLLATTITUDEILIMIT: - needsUpdate |= update(&stab.RollPI.ILimit, value); + needsUpdateBank |= update(&bank.RollPI.ILimit, value); break; case TXPIDSETTINGS_PIDS_PITCHRATEKP: - needsUpdate |= update(&stab.PitchRatePID.Kp, value); + needsUpdateBank |= update(&bank.PitchRatePID.Kp, value); break; case TXPIDSETTINGS_PIDS_PITCHRATEKI: - needsUpdate |= update(&stab.PitchRatePID.Ki, value); + needsUpdateBank |= update(&bank.PitchRatePID.Ki, value); break; case TXPIDSETTINGS_PIDS_PITCHRATEKD: - needsUpdate |= update(&stab.PitchRatePID.Kd, value); + needsUpdateBank |= update(&bank.PitchRatePID.Kd, value); break; case TXPIDSETTINGS_PIDS_PITCHRATEILIMIT: - needsUpdate |= update(&stab.PitchRatePID.ILimit, value); + needsUpdateBank |= update(&bank.PitchRatePID.ILimit, value); break; case TXPIDSETTINGS_PIDS_PITCHATTITUDEKP: - needsUpdate |= update(&stab.PitchPI.Kp, value); + needsUpdateBank |= update(&bank.PitchPI.Kp, value); break; case TXPIDSETTINGS_PIDS_PITCHATTITUDEKI: - needsUpdate |= update(&stab.PitchPI.Ki, value); + needsUpdateBank |= update(&bank.PitchPI.Ki, value); break; case TXPIDSETTINGS_PIDS_PITCHATTITUDEILIMIT: - needsUpdate |= update(&stab.PitchPI.ILimit, value); + needsUpdateBank |= update(&bank.PitchPI.ILimit, value); break; case TXPIDSETTINGS_PIDS_ROLLPITCHRATEKP: - needsUpdate |= update(&stab.RollRatePID.Kp, value); - needsUpdate |= update(&stab.PitchRatePID.Kp, value); + needsUpdateBank |= update(&bank.RollRatePID.Kp, value); + needsUpdateBank |= update(&bank.PitchRatePID.Kp, value); break; case TXPIDSETTINGS_PIDS_ROLLPITCHRATEKI: - needsUpdate |= update(&stab.RollRatePID.Ki, value); - needsUpdate |= update(&stab.PitchRatePID.Ki, value); + needsUpdateBank |= update(&bank.RollRatePID.Ki, value); + needsUpdateBank |= update(&bank.PitchRatePID.Ki, value); break; case TXPIDSETTINGS_PIDS_ROLLPITCHRATEKD: - needsUpdate |= update(&stab.RollRatePID.Kd, value); - needsUpdate |= update(&stab.PitchRatePID.Kd, value); + needsUpdateBank |= update(&bank.RollRatePID.Kd, value); + needsUpdateBank |= update(&bank.PitchRatePID.Kd, value); break; case TXPIDSETTINGS_PIDS_ROLLPITCHRATEILIMIT: - needsUpdate |= update(&stab.RollRatePID.ILimit, value); - needsUpdate |= update(&stab.PitchRatePID.ILimit, value); + needsUpdateBank |= update(&bank.RollRatePID.ILimit, value); + needsUpdateBank |= update(&bank.PitchRatePID.ILimit, value); break; case TXPIDSETTINGS_PIDS_ROLLPITCHATTITUDEKP: - needsUpdate |= update(&stab.RollPI.Kp, value); - needsUpdate |= update(&stab.PitchPI.Kp, value); + needsUpdateBank |= update(&bank.RollPI.Kp, value); + needsUpdateBank |= update(&bank.PitchPI.Kp, value); break; case TXPIDSETTINGS_PIDS_ROLLPITCHATTITUDEKI: - needsUpdate |= update(&stab.RollPI.Ki, value); - needsUpdate |= update(&stab.PitchPI.Ki, value); + needsUpdateBank |= update(&bank.RollPI.Ki, value); + needsUpdateBank |= update(&bank.PitchPI.Ki, value); break; case TXPIDSETTINGS_PIDS_ROLLPITCHATTITUDEILIMIT: - needsUpdate |= update(&stab.RollPI.ILimit, value); - needsUpdate |= update(&stab.PitchPI.ILimit, value); + needsUpdateBank |= update(&bank.RollPI.ILimit, value); + needsUpdateBank |= update(&bank.PitchPI.ILimit, value); break; case TXPIDSETTINGS_PIDS_YAWRATEKP: - needsUpdate |= update(&stab.YawRatePID.Kp, value); + needsUpdateBank |= update(&bank.YawRatePID.Kp, value); break; case TXPIDSETTINGS_PIDS_YAWRATEKI: - needsUpdate |= update(&stab.YawRatePID.Ki, value); + needsUpdateBank |= update(&bank.YawRatePID.Ki, value); break; case TXPIDSETTINGS_PIDS_YAWRATEKD: - needsUpdate |= update(&stab.YawRatePID.Kd, value); + needsUpdateBank |= update(&bank.YawRatePID.Kd, value); break; case TXPIDSETTINGS_PIDS_YAWRATEILIMIT: - needsUpdate |= update(&stab.YawRatePID.ILimit, value); + needsUpdateBank |= update(&bank.YawRatePID.ILimit, value); break; case TXPIDSETTINGS_PIDS_YAWATTITUDEKP: - needsUpdate |= update(&stab.YawPI.Kp, value); + needsUpdateBank |= update(&bank.YawPI.Kp, value); break; case TXPIDSETTINGS_PIDS_YAWATTITUDEKI: - needsUpdate |= update(&stab.YawPI.Ki, value); + needsUpdateBank |= update(&bank.YawPI.Ki, value); break; case TXPIDSETTINGS_PIDS_YAWATTITUDEILIMIT: - needsUpdate |= update(&stab.YawPI.ILimit, value); + needsUpdateBank |= update(&bank.YawPI.ILimit, value); break; case TXPIDSETTINGS_PIDS_GYROTAU: - needsUpdate |= update(&stab.GyroTau, value); + needsUpdateStab |= update(&stab.GyroTau, value); break; default: PIOS_Assert(0); } } } - if (needsUpdate) { + if (needsUpdateStab) { StabilizationSettingsSet(&stab); } + if (needsUpdateBank) { + StabilizationBankSet(&bank); + } } /** From e4bcd87ddd0e00e32cff45bc1cc06f2fb62f32b4 Mon Sep 17 00:00:00 2001 From: Les Newell Date: Wed, 11 Dec 2013 12:03:37 +0000 Subject: [PATCH 07/45] OP-984 Added stabilizationbank to inc files --- flight/targets/boards/coptercontrol/firmware/Makefile | 1 + flight/targets/boards/revolution/firmware/UAVObjects.inc | 1 + flight/targets/boards/revoproto/firmware/UAVObjects.inc | 3 ++- flight/targets/boards/simposix/firmware/UAVObjects.inc | 7 ++++--- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/flight/targets/boards/coptercontrol/firmware/Makefile b/flight/targets/boards/coptercontrol/firmware/Makefile index 2508f6a50..9d2e351d8 100644 --- a/flight/targets/boards/coptercontrol/firmware/Makefile +++ b/flight/targets/boards/coptercontrol/firmware/Makefile @@ -84,6 +84,7 @@ ifndef TESTAPP SRC += $(OPUAVSYNTHDIR)/systemsettings.c SRC += $(OPUAVSYNTHDIR)/stabilizationdesired.c SRC += $(OPUAVSYNTHDIR)/stabilizationsettings.c + SRC += $(OPUAVSYNTHDIR)/stabilizationbank.c SRC += $(OPUAVSYNTHDIR)/actuatorcommand.c SRC += $(OPUAVSYNTHDIR)/actuatordesired.c SRC += $(OPUAVSYNTHDIR)/actuatorsettings.c diff --git a/flight/targets/boards/revolution/firmware/UAVObjects.inc b/flight/targets/boards/revolution/firmware/UAVObjects.inc index 7a63dc9f2..1ee81ebc4 100644 --- a/flight/targets/boards/revolution/firmware/UAVObjects.inc +++ b/flight/targets/boards/revolution/firmware/UAVObjects.inc @@ -82,6 +82,7 @@ UAVOBJSRCFILENAMES += revosettings UAVOBJSRCFILENAMES += sonaraltitude UAVOBJSRCFILENAMES += stabilizationdesired UAVOBJSRCFILENAMES += stabilizationsettings +UAVOBJSRCFILENAMES += stabilizationbank UAVOBJSRCFILENAMES += systemalarms UAVOBJSRCFILENAMES += systemsettings UAVOBJSRCFILENAMES += systemstats diff --git a/flight/targets/boards/revoproto/firmware/UAVObjects.inc b/flight/targets/boards/revoproto/firmware/UAVObjects.inc index 80dab9e61..9c9265654 100644 --- a/flight/targets/boards/revoproto/firmware/UAVObjects.inc +++ b/flight/targets/boards/revoproto/firmware/UAVObjects.inc @@ -4,7 +4,7 @@ # Makefile for OpenPilot UAVObject code # # The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2011. -# +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or @@ -82,6 +82,7 @@ UAVOBJSRCFILENAMES += revosettings UAVOBJSRCFILENAMES += sonaraltitude UAVOBJSRCFILENAMES += stabilizationdesired UAVOBJSRCFILENAMES += stabilizationsettings +UAVOBJSRCFILENAMES += stabilizationbank UAVOBJSRCFILENAMES += systemalarms UAVOBJSRCFILENAMES += systemsettings UAVOBJSRCFILENAMES += systemstats diff --git a/flight/targets/boards/simposix/firmware/UAVObjects.inc b/flight/targets/boards/simposix/firmware/UAVObjects.inc index be99363d3..49ab58b2c 100644 --- a/flight/targets/boards/simposix/firmware/UAVObjects.inc +++ b/flight/targets/boards/simposix/firmware/UAVObjects.inc @@ -4,7 +4,7 @@ # Makefile for OpenPilot UAVObject code # # The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2011. -# +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or @@ -82,6 +82,7 @@ UAVOBJSRCFILENAMES += relaytuningsettings UAVOBJSRCFILENAMES += sonaraltitude UAVOBJSRCFILENAMES += stabilizationdesired UAVOBJSRCFILENAMES += stabilizationsettings +UAVOBJSRCFILENAMES += stabilizationbank UAVOBJSRCFILENAMES += systemalarms UAVOBJSRCFILENAMES += systemsettings UAVOBJSRCFILENAMES += systemstats @@ -98,8 +99,8 @@ UAVOBJSRCFILENAMES += hwsettings UAVOBJSRCFILENAMES += receiveractivity UAVOBJSRCFILENAMES += cameradesired UAVOBJSRCFILENAMES += camerastabsettings -UAVOBJSRCFILENAMES += altitudeholdsettings -UAVOBJSRCFILENAMES += altitudefiltersettings +UAVOBJSRCFILENAMES += altitudeholdsettings +UAVOBJSRCFILENAMES += altitudefiltersettings UAVOBJSRCFILENAMES += revosettings UAVOBJSRCFILENAMES += altitudeholddesired UAVOBJSRCFILENAMES += ekfconfiguration From d625242a45473ba33e1d3338396cc5d3b411d743 Mon Sep 17 00:00:00 2001 From: Les Newell Date: Wed, 11 Dec 2013 12:05:05 +0000 Subject: [PATCH 08/45] OP-984 Updated vtolpathfollower to handle PID banks --- flight/modules/Stabilization/stabilization.c | 1 + flight/modules/VtolPathFollower/vtolpathfollower.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/flight/modules/Stabilization/stabilization.c b/flight/modules/Stabilization/stabilization.c index fd23680f3..c4bc13518 100644 --- a/flight/modules/Stabilization/stabilization.c +++ b/flight/modules/Stabilization/stabilization.c @@ -135,6 +135,7 @@ int32_t StabilizationInitialize() { // Initialize variables StabilizationSettingsInitialize(); + StabilizationBankInitialize(); ActuatorDesiredInitialize(); #ifdef DIAG_RATEDESIRED RateDesiredInitialize(); diff --git a/flight/modules/VtolPathFollower/vtolpathfollower.c b/flight/modules/VtolPathFollower/vtolpathfollower.c index fad0b7b31..225a93967 100644 --- a/flight/modules/VtolPathFollower/vtolpathfollower.c +++ b/flight/modules/VtolPathFollower/vtolpathfollower.c @@ -65,6 +65,7 @@ #include "nedaccel.h" #include "stabilizationdesired.h" #include "stabilizationsettings.h" +#include "stabilizationbank.h" #include "systemsettings.h" #include "velocitydesired.h" #include "velocitystate.h" @@ -575,7 +576,7 @@ static void updateVtolDesiredAttitude(bool yaw_attitude) StabilizationDesiredData stabDesired; AttitudeStateData attitudeState; NedAccelData nedAccel; - StabilizationSettingsData stabSettings; + StabilizationBankData stabSettings; SystemSettingsData systemSettings; float northError; @@ -593,7 +594,7 @@ static void updateVtolDesiredAttitude(bool yaw_attitude) StabilizationDesiredGet(&stabDesired); VelocityDesiredGet(&velocityDesired); AttitudeStateGet(&attitudeState); - StabilizationSettingsGet(&stabSettings); + StabilizationBankGet(&stabSettings); NedAccelGet(&nedAccel); float northVel = 0, eastVel = 0, downVel = 0; From 73592766278106f3b72dd8dd1c5e01fd8a257e89 Mon Sep 17 00:00:00 2001 From: Les Newell Date: Wed, 11 Dec 2013 12:25:27 +0000 Subject: [PATCH 09/45] OP-984 Added stabilization bank to uavobjects.pro --- ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro b/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro index d1b002994..f3a0baa0a 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro @@ -60,6 +60,7 @@ HEADERS += $$UAVOBJECT_SYNTHETICS/accessorydesired.h \ $$UAVOBJECT_SYNTHETICS/overosyncsettings.h \ $$UAVOBJECT_SYNTHETICS/systemsettings.h \ $$UAVOBJECT_SYNTHETICS/stabilizationsettings.h \ + $$UAVOBJECT_SYNTHETICS/stabilizationbank.h \ $$UAVOBJECT_SYNTHETICS/manualcontrolsettings.h \ $$UAVOBJECT_SYNTHETICS/manualcontrolcommand.h \ $$UAVOBJECT_SYNTHETICS/stabilizationdesired.h \ @@ -151,6 +152,7 @@ SOURCES += $$UAVOBJECT_SYNTHETICS/accessorydesired.cpp \ $$UAVOBJECT_SYNTHETICS/overosyncsettings.cpp \ $$UAVOBJECT_SYNTHETICS/systemsettings.cpp \ $$UAVOBJECT_SYNTHETICS/stabilizationsettings.cpp \ + $$UAVOBJECT_SYNTHETICS/stabilizationbank.cpp \ $$UAVOBJECT_SYNTHETICS/manualcontrolsettings.cpp \ $$UAVOBJECT_SYNTHETICS/manualcontrolcommand.cpp \ $$UAVOBJECT_SYNTHETICS/stabilizationdesired.cpp \ From 084e3ccd5dee6142bee14c10565ab01713cd7e7d Mon Sep 17 00:00:00 2001 From: Les Newell Date: Wed, 11 Dec 2013 13:31:14 +0000 Subject: [PATCH 10/45] OP-984 Modified manualcontrol to handle pid bank --- flight/modules/ManualControl/manualcontrol.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flight/modules/ManualControl/manualcontrol.c b/flight/modules/ManualControl/manualcontrol.c index db1ae3cce..62006ed37 100644 --- a/flight/modules/ManualControl/manualcontrol.c +++ b/flight/modules/ManualControl/manualcontrol.c @@ -668,8 +668,8 @@ static void updateStabilizationDesired(ManualControlCommandData *cmd, ManualCont StabilizationDesiredGet(&stabilization); - StabilizationSettingsData stabSettings; - StabilizationSettingsGet(&stabSettings); + StabilizationBankData stabSettings; + StabilizationBankGet(&stabSettings); uint8_t *stab_settings; FlightStatusData flightStatus; @@ -871,8 +871,8 @@ static void altitudeHoldDesired(ManualControlCommandData *cmd, bool changed) AltitudeHoldSettingsThrottleRateGet(&throttleRate); } - StabilizationSettingsData stabSettings; - StabilizationSettingsGet(&stabSettings); + StabilizationBankData stabSettings; + StabilizationBankGet(&stabSettings); thisSysTime = xTaskGetTickCount(); dT = ((thisSysTime == lastSysTimeAH) ? 0.001f : (thisSysTime - lastSysTimeAH) * portTICK_RATE_MS * 0.001f); From 5833e2a7ccf85cdf68aec2c224f8e09f559d7f7c Mon Sep 17 00:00:00 2001 From: Les Newell Date: Wed, 11 Dec 2013 13:34:58 +0000 Subject: [PATCH 11/45] OP-984 Added one UAVObject per PID bank --- .../stabilizationsettings.xml | 14 +++-------- .../stabilizationsettingsbank1.xml | 23 +++++++++++++++++++ .../stabilizationsettingsbank2.xml | 23 +++++++++++++++++++ .../stabilizationsettingsbank3.xml | 23 +++++++++++++++++++ 4 files changed, 72 insertions(+), 11 deletions(-) create mode 100644 shared/uavobjectdefinition/stabilizationsettingsbank1.xml create mode 100644 shared/uavobjectdefinition/stabilizationsettingsbank2.xml create mode 100644 shared/uavobjectdefinition/stabilizationsettingsbank3.xml diff --git a/shared/uavobjectdefinition/stabilizationsettings.xml b/shared/uavobjectdefinition/stabilizationsettings.xml index 6979fb9f4..7e7e026bc 100644 --- a/shared/uavobjectdefinition/stabilizationsettings.xml +++ b/shared/uavobjectdefinition/stabilizationsettings.xml @@ -1,18 +1,10 @@ + PID settings used by the Stabilization module to combine the @ref AttitudeActual and @ref AttitudeDesired to compute @ref ActuatorDesired - - - - - - - - - - - + + diff --git a/shared/uavobjectdefinition/stabilizationsettingsbank1.xml b/shared/uavobjectdefinition/stabilizationsettingsbank1.xml new file mode 100644 index 000000000..f7924c0be --- /dev/null +++ b/shared/uavobjectdefinition/stabilizationsettingsbank1.xml @@ -0,0 +1,23 @@ + + + Currently selected PID bank + + + + + + + + + + + + + + + + + + + + diff --git a/shared/uavobjectdefinition/stabilizationsettingsbank2.xml b/shared/uavobjectdefinition/stabilizationsettingsbank2.xml new file mode 100644 index 000000000..381f1a7c6 --- /dev/null +++ b/shared/uavobjectdefinition/stabilizationsettingsbank2.xml @@ -0,0 +1,23 @@ + + + Currently selected PID bank + + + + + + + + + + + + + + + + + + + + diff --git a/shared/uavobjectdefinition/stabilizationsettingsbank3.xml b/shared/uavobjectdefinition/stabilizationsettingsbank3.xml new file mode 100644 index 000000000..14c44d626 --- /dev/null +++ b/shared/uavobjectdefinition/stabilizationsettingsbank3.xml @@ -0,0 +1,23 @@ + + + Currently selected PID bank + + + + + + + + + + + + + + + + + + + + From abaa17ab231467f86093d7cddc87cce3d1c151fa Mon Sep 17 00:00:00 2001 From: Les Newell Date: Wed, 11 Dec 2013 13:46:29 +0000 Subject: [PATCH 12/45] OP-984 Modified GCS to build with multiple pid banks. NOTE: stabilization config only uses bank 1 --- .../src/plugins/config/stabilization.ui | 108 +++++++++--------- .../src/plugins/uavobjects/uavobjects.pro | 6 + 2 files changed, 60 insertions(+), 54 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/stabilization.ui b/ground/openpilotgcs/src/plugins/config/stabilization.ui index 84291366e..034b51f0d 100644 --- a/ground/openpilotgcs/src/plugins/config/stabilization.ui +++ b/ground/openpilotgcs/src/plugins/config/stabilization.ui @@ -1312,7 +1312,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:RollMax haslimits:no scale:1 @@ -1346,7 +1346,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:ManualRate element:Roll haslimits:no @@ -1394,7 +1394,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:ManualRate element:Roll haslimits:no @@ -2583,7 +2583,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:RollMax haslimits:no scale:1 @@ -2617,7 +2617,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:ManualRate element:Yaw haslimits:no @@ -2668,7 +2668,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:ManualRate element:Yaw haslimits:no @@ -4448,7 +4448,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:RollRatePID element:Kp haslimits:yes @@ -4487,7 +4487,7 @@ Then lower the value by 5 or so. - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:RollRatePID element:Kp haslimits:yes @@ -4562,7 +4562,7 @@ Then lower the value by 5 or so. - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:YawRatePID element:Kp haslimits:yes @@ -4612,7 +4612,7 @@ Then lower the value by 5 or so. - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:PitchRatePID element:Kp haslimits:yes @@ -4651,7 +4651,7 @@ Then lower the value by 5 or so. - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:PitchRatePID element:Kp haslimits:yes @@ -4690,7 +4690,7 @@ Then lower the value by 5 or so. - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:YawRatePID element:Kp haslimits:yes @@ -4740,7 +4740,7 @@ Then lower the value by 5 or so. - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:RollRatePID element:Ki haslimits:yes @@ -4798,7 +4798,7 @@ value as the Kp. - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:RollRatePID element:Ki haslimits:yes @@ -4837,7 +4837,7 @@ value as the Kp. - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:YawRatePID element:Ki haslimits:yes @@ -4887,7 +4887,7 @@ value as the Kp. - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:YawRatePID element:Ki haslimits:yes @@ -4937,7 +4937,7 @@ value as the Kp. - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:PitchRatePID element:Ki haslimits:yes @@ -4976,7 +4976,7 @@ value as the Kp. - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:PitchRatePID element:Ki haslimits:yes @@ -8349,7 +8349,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:RollPI element:Kp scale:0.1 @@ -8384,7 +8384,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:RollPI element:Kp scale:0.1 @@ -8434,7 +8434,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:PitchPI element:Kp scale:0.1 @@ -8469,7 +8469,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:PitchPI element:Kp scale:0.1 @@ -8519,7 +8519,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:YawPI element:Kp scale:0.1 @@ -8554,7 +8554,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:YawPI element:Kp scale:0.1 @@ -9989,7 +9989,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:PitchMax haslimits:no scale:1 @@ -10072,7 +10072,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:MaximumRate element:Roll haslimits:no @@ -10141,7 +10141,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:ManualRate element:Yaw haslimits:no @@ -10194,7 +10194,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:YawMax haslimits:no scale:1 @@ -10246,7 +10246,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:MaximumRate element:Pitch haslimits:no @@ -11456,7 +11456,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:ManualRate element:Pitch haslimits:no @@ -12075,7 +12075,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:ManualRate element:Roll haslimits:no @@ -12131,7 +12131,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:RollMax haslimits:no scale:1 @@ -12183,7 +12183,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:MaximumRate element:Yaw haslimits:no @@ -13352,7 +13352,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:PitchRatePID element:Kd haslimits:no @@ -13971,7 +13971,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:YawRatePID element:Ki haslimits:no @@ -14021,7 +14021,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:PitchRatePID element:Ki haslimits:no @@ -14071,7 +14071,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:YawRatePID element:Kp haslimits:no @@ -14121,7 +14121,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:YawRatePID element:Kd haslimits:no @@ -15328,7 +15328,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:RollRatePID element:Kp haslimits:no @@ -15394,7 +15394,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:RollRatePID element:Ki haslimits:no @@ -15475,7 +15475,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:PitchRatePID element:Kp haslimits:no @@ -15525,7 +15525,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:RollRatePID element:Kd haslimits:no @@ -18378,7 +18378,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:RollPI element:Kp haslimits:no @@ -18428,7 +18428,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:PitchPI element:Kp haslimits:no @@ -18478,7 +18478,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:YawPI element:Kp haslimits:no @@ -18563,7 +18563,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:RollPI element:Ki haslimits:no @@ -18629,7 +18629,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:PitchPI element:Ki haslimits:no @@ -18695,7 +18695,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:YawPI element:Ki haslimits:no @@ -21937,7 +21937,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:PitchRatePID element:ILimit haslimits:no @@ -21990,7 +21990,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:RollRatePID element:ILimit haslimits:no @@ -23140,7 +23140,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:YawPI element:ILimit haslimits:no @@ -23221,7 +23221,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:PitchPI element:ILimit haslimits:no @@ -23331,7 +23331,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:RollPI element:ILimit haslimits:no @@ -23947,7 +23947,7 @@ border-radius: 5; - objname:StabilizationSettings + objname:StabilizationSettingsBank1 fieldname:YawRatePID element:ILimit haslimits:no diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro b/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro index f3a0baa0a..541c066d7 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro @@ -60,6 +60,9 @@ HEADERS += $$UAVOBJECT_SYNTHETICS/accessorydesired.h \ $$UAVOBJECT_SYNTHETICS/overosyncsettings.h \ $$UAVOBJECT_SYNTHETICS/systemsettings.h \ $$UAVOBJECT_SYNTHETICS/stabilizationsettings.h \ + $$UAVOBJECT_SYNTHETICS/stabilizationsettingsbank1.h \ + $$UAVOBJECT_SYNTHETICS/stabilizationsettingsbank2.h \ + $$UAVOBJECT_SYNTHETICS/stabilizationsettingsbank3.h \ $$UAVOBJECT_SYNTHETICS/stabilizationbank.h \ $$UAVOBJECT_SYNTHETICS/manualcontrolsettings.h \ $$UAVOBJECT_SYNTHETICS/manualcontrolcommand.h \ @@ -152,6 +155,9 @@ SOURCES += $$UAVOBJECT_SYNTHETICS/accessorydesired.cpp \ $$UAVOBJECT_SYNTHETICS/overosyncsettings.cpp \ $$UAVOBJECT_SYNTHETICS/systemsettings.cpp \ $$UAVOBJECT_SYNTHETICS/stabilizationsettings.cpp \ + $$UAVOBJECT_SYNTHETICS/stabilizationsettingsbank1.cpp \ + $$UAVOBJECT_SYNTHETICS/stabilizationsettingsbank2.cpp \ + $$UAVOBJECT_SYNTHETICS/stabilizationsettingsbank3.cpp \ $$UAVOBJECT_SYNTHETICS/stabilizationbank.cpp \ $$UAVOBJECT_SYNTHETICS/manualcontrolsettings.cpp \ $$UAVOBJECT_SYNTHETICS/manualcontrolcommand.cpp \ From b7cfc503eadf0bc05448951ea9a4ceb750373189 Mon Sep 17 00:00:00 2001 From: Les Newell Date: Wed, 11 Dec 2013 13:50:06 +0000 Subject: [PATCH 13/45] OP-984 Updated makefiles and inc files for multiple pid bank objects --- flight/targets/boards/coptercontrol/firmware/Makefile | 3 +++ flight/targets/boards/revolution/firmware/UAVObjects.inc | 3 +++ flight/targets/boards/revoproto/firmware/UAVObjects.inc | 3 +++ flight/targets/boards/simposix/firmware/UAVObjects.inc | 3 +++ 4 files changed, 12 insertions(+) diff --git a/flight/targets/boards/coptercontrol/firmware/Makefile b/flight/targets/boards/coptercontrol/firmware/Makefile index 9d2e351d8..f8534da9a 100644 --- a/flight/targets/boards/coptercontrol/firmware/Makefile +++ b/flight/targets/boards/coptercontrol/firmware/Makefile @@ -84,6 +84,9 @@ ifndef TESTAPP SRC += $(OPUAVSYNTHDIR)/systemsettings.c SRC += $(OPUAVSYNTHDIR)/stabilizationdesired.c SRC += $(OPUAVSYNTHDIR)/stabilizationsettings.c + SRC += $(OPUAVSYNTHDIR)/stabilizationsettingsbank1.c + SRC += $(OPUAVSYNTHDIR)/stabilizationsettingsbank2.c + SRC += $(OPUAVSYNTHDIR)/stabilizationsettingsbank3.c SRC += $(OPUAVSYNTHDIR)/stabilizationbank.c SRC += $(OPUAVSYNTHDIR)/actuatorcommand.c SRC += $(OPUAVSYNTHDIR)/actuatordesired.c diff --git a/flight/targets/boards/revolution/firmware/UAVObjects.inc b/flight/targets/boards/revolution/firmware/UAVObjects.inc index 1ee81ebc4..6259e2545 100644 --- a/flight/targets/boards/revolution/firmware/UAVObjects.inc +++ b/flight/targets/boards/revolution/firmware/UAVObjects.inc @@ -82,6 +82,9 @@ UAVOBJSRCFILENAMES += revosettings UAVOBJSRCFILENAMES += sonaraltitude UAVOBJSRCFILENAMES += stabilizationdesired UAVOBJSRCFILENAMES += stabilizationsettings +UAVOBJSRCFILENAMES += stabilizationsettingsbank1 +UAVOBJSRCFILENAMES += stabilizationsettingsbank2 +UAVOBJSRCFILENAMES += stabilizationsettingsbank3 UAVOBJSRCFILENAMES += stabilizationbank UAVOBJSRCFILENAMES += systemalarms UAVOBJSRCFILENAMES += systemsettings diff --git a/flight/targets/boards/revoproto/firmware/UAVObjects.inc b/flight/targets/boards/revoproto/firmware/UAVObjects.inc index 9c9265654..1020a8538 100644 --- a/flight/targets/boards/revoproto/firmware/UAVObjects.inc +++ b/flight/targets/boards/revoproto/firmware/UAVObjects.inc @@ -82,6 +82,9 @@ UAVOBJSRCFILENAMES += revosettings UAVOBJSRCFILENAMES += sonaraltitude UAVOBJSRCFILENAMES += stabilizationdesired UAVOBJSRCFILENAMES += stabilizationsettings +UAVOBJSRCFILENAMES += stabilizationsettingsbank1 +UAVOBJSRCFILENAMES += stabilizationsettingsbank2 +UAVOBJSRCFILENAMES += stabilizationsettingsbank3 UAVOBJSRCFILENAMES += stabilizationbank UAVOBJSRCFILENAMES += systemalarms UAVOBJSRCFILENAMES += systemsettings diff --git a/flight/targets/boards/simposix/firmware/UAVObjects.inc b/flight/targets/boards/simposix/firmware/UAVObjects.inc index 49ab58b2c..61bb25100 100644 --- a/flight/targets/boards/simposix/firmware/UAVObjects.inc +++ b/flight/targets/boards/simposix/firmware/UAVObjects.inc @@ -82,6 +82,9 @@ UAVOBJSRCFILENAMES += relaytuningsettings UAVOBJSRCFILENAMES += sonaraltitude UAVOBJSRCFILENAMES += stabilizationdesired UAVOBJSRCFILENAMES += stabilizationsettings +UAVOBJSRCFILENAMES += stabilizationsettingsbank1 +UAVOBJSRCFILENAMES += stabilizationsettingsbank2 +UAVOBJSRCFILENAMES += stabilizationsettingsbank3 UAVOBJSRCFILENAMES += stabilizationbank UAVOBJSRCFILENAMES += systemalarms UAVOBJSRCFILENAMES += systemsettings From 641cf474eb93d79f9669a707bb003a0cfea4f88c Mon Sep 17 00:00:00 2001 From: Les Newell Date: Wed, 11 Dec 2013 13:54:55 +0000 Subject: [PATCH 14/45] OP-984 Fixed missing include in manualcontrol.c --- flight/modules/ManualControl/manualcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flight/modules/ManualControl/manualcontrol.c b/flight/modules/ManualControl/manualcontrol.c index 62006ed37..af2fa9016 100644 --- a/flight/modules/ManualControl/manualcontrol.c +++ b/flight/modules/ManualControl/manualcontrol.c @@ -46,7 +46,7 @@ #include "manualcontrolcommand.h" #include "positionstate.h" #include "pathdesired.h" -#include "stabilizationsettings.h" +#include "stabilizationbank.h" #include "stabilizationdesired.h" #include "receiveractivity.h" #include "systemsettings.h" From 68b8586c6bc6155706e60432e025f9ab033b2315 Mon Sep 17 00:00:00 2001 From: Les Newell Date: Wed, 11 Dec 2013 13:56:00 +0000 Subject: [PATCH 15/45] OP-984 Changed stabilization.c to handle multiple pid bank objects --- flight/modules/Stabilization/stabilization.c | 131 ++++++++++--------- 1 file changed, 70 insertions(+), 61 deletions(-) diff --git a/flight/modules/Stabilization/stabilization.c b/flight/modules/Stabilization/stabilization.c index c4bc13518..221100a21 100644 --- a/flight/modules/Stabilization/stabilization.c +++ b/flight/modules/Stabilization/stabilization.c @@ -36,6 +36,9 @@ #include "stabilization.h" #include "stabilizationsettings.h" #include "stabilizationbank.h" +#include "stabilizationsettingsbank1.h" +#include "stabilizationsettingsbank2.h" +#include "stabilizationsettingsbank3.h" #include "actuatordesired.h" #include "ratedesired.h" #include "relaytuning.h" @@ -97,9 +100,9 @@ int flight_mode = -1; static void stabilizationTask(void *parameters); static float bound(float val, float range); static void ZeroPids(void); -static void BankChanged(); static void SettingsUpdatedCb(UAVObjEvent *ev); static void BankUpdatedCb(UAVObjEvent *ev); +static void SettingsBankUpdatedCb(UAVObjEvent *ev); /** * Module initialization @@ -119,6 +122,11 @@ int32_t StabilizationStart() StabilizationBankConnectCallback(BankUpdatedCb); + StabilizationSettingsBank1ConnectCallback(SettingsBankUpdatedCb); + StabilizationSettingsBank2ConnectCallback(SettingsBankUpdatedCb); + StabilizationSettingsBank3ConnectCallback(SettingsBankUpdatedCb); + + // Start main task xTaskCreate(stabilizationTask, (signed char *)"Stabilization", STACK_SIZE_BYTES / 4, NULL, TASK_PRIORITY, &taskHandle); PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_STABILIZATION, taskHandle); @@ -136,6 +144,9 @@ int32_t StabilizationInitialize() // Initialize variables StabilizationSettingsInitialize(); StabilizationBankInitialize(); + StabilizationSettingsBank1Initialize(); + StabilizationSettingsBank2Initialize(); + StabilizationSettingsBank3Initialize(); ActuatorDesiredInitialize(); #ifdef DIAG_RATEDESIRED RateDesiredInitialize(); @@ -205,8 +216,8 @@ static void stabilizationTask(__attribute__((unused)) void *parameters) #endif if(flight_mode != flightStatus.FlightMode){ - BankChanged(); flight_mode = flightStatus.FlightMode; + SettingsBankUpdatedCb(NULL); } #ifdef REVOLUTION @@ -502,36 +513,35 @@ static float bound(float val, float range) return val; } -static void BankChanged() + + +static void SettingsBankUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) { StabilizationBankData bank, oldBank; - FlightStatusData flightStatus; + StabilizationBankGet(&oldBank); - StabilizationBankGet(&bank); - FlightStatusGet(&flightStatus); - memcpy(&oldBank, &bank, sizeof(StabilizationBankData)); + if(flight_mode < 0) return; - int offset = flightStatus.FlightMode; - bank.RollMax = settings.RollMax[offset]; - bank.PitchMax = settings.PitchMax[offset]; - bank.YawMax = settings.YawMax[offset]; + switch(cast_struct_to_array(settings.FlightModeMap, settings.FlightModeMap.Stabilized1)[flight_mode]) + { + case 0: + StabilizationSettingsBank1Get((StabilizationSettingsBank1Data *) &bank); + break; - offset = flightStatus.FlightMode * MAX_AXES; - memcpy(&bank.ManualRate, (&settings.ManualRate) + offset, sizeof(float) * MAX_AXES); - memcpy(&bank.MaximumRate, (&settings.MaximumRate) + offset, sizeof(float) * MAX_AXES); + case 1: + StabilizationSettingsBank2Get((StabilizationSettingsBank2Data *) &bank); + break; - offset = flightStatus.FlightMode * RATE_OFFSET; - memcpy(&bank.RollRatePID, (&settings.RollRatePID) + offset, sizeof(float) * RATE_OFFSET); - memcpy(&bank.PitchRatePID, (&settings.PitchRatePID) + offset, sizeof(float) * RATE_OFFSET); - memcpy(&bank.YawRatePID, (&settings.YawRatePID) + offset, sizeof(float) * RATE_OFFSET); + case 2: + StabilizationSettingsBank3Get((StabilizationSettingsBank3Data *) &bank); + break; - offset = flightStatus.FlightMode * ATT_OFFSET; - memcpy(&bank.RollPI, (&settings.RollPI) + offset, sizeof(float) * ATT_OFFSET); - memcpy(&bank.PitchPI, (&settings.PitchPI) + offset, sizeof(float) * ATT_OFFSET); - memcpy(&bank.YawPI, (&settings.YawPI) + offset, sizeof(float) * ATT_OFFSET); + default: + return; //bank number is invalid. All we can do is ignore it. + } //Need to do this to prevent an infinite loop - if(memcmp(&oldBank, &bank, sizeof(StabilizationBankData)) != 0) + if(memcmp(&oldBank, &bank, sizeof(StabilizationBankDataPacked)) != 0) { StabilizationBankSet(&bank); } @@ -539,49 +549,40 @@ static void BankChanged() static void BankUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) { - StabilizationBankData bank; - FlightStatusData flightStatus; - + StabilizationBankData curBank, bank; StabilizationBankGet(&bank); - FlightStatusGet(&flightStatus); - StabilizationSettingsData oldSettings; - memcpy(&oldSettings, &settings, sizeof(StabilizationSettingsData)); + if(flight_mode < 0) return; - int offset = flightStatus.FlightMode; - settings.RollMax[offset] = bank.RollMax; - settings.PitchMax[offset] = bank.PitchMax; - settings.YawMax[offset] = bank.YawMax; - - - offset = flightStatus.FlightMode * MAX_AXES; - memcpy((&settings.ManualRate) + offset, &bank.ManualRate, sizeof(float) * MAX_AXES); - memcpy((&settings.MaximumRate) + offset, &bank.MaximumRate, sizeof(float) * MAX_AXES); - - offset = flightStatus.FlightMode * RATE_OFFSET; - memcpy((&settings.RollRatePID) + offset, &bank.RollRatePID, sizeof(float) * RATE_OFFSET); - memcpy((&settings.PitchRatePID) + offset, &bank.PitchRatePID, sizeof(float) * RATE_OFFSET); - memcpy((&settings.YawRatePID) + offset, &bank.YawRatePID, sizeof(float) * RATE_OFFSET); - - offset = flightStatus.FlightMode * ATT_OFFSET; - memcpy((&settings.RollPI) + offset, &bank.RollPI, sizeof(float) * ATT_OFFSET); - memcpy((&settings.PitchPI) + offset, &bank.PitchPI, sizeof(float) * ATT_OFFSET); - memcpy((&settings.YawPI) + offset, &bank.YawPI, sizeof(float) * ATT_OFFSET); - -//Need to do this to prevent an infinite loop - if(memcmp(&oldSettings, &settings, sizeof(StabilizationSettingsData)) != 0) + switch(cast_struct_to_array(settings.FlightModeMap, settings.FlightModeMap.Stabilized1)[flight_mode]) { - StabilizationSettingsSet(&settings); + case 0: + StabilizationSettingsBank1Get((StabilizationSettingsBank1Data *) &curBank); + if(memcmp(&curBank, &bank, sizeof(StabilizationBankDataPacked)) != 0) + { + StabilizationSettingsBank1Set((StabilizationSettingsBank1Data *) &bank); + } + break; + + case 1: + StabilizationSettingsBank2Get((StabilizationSettingsBank2Data *) &curBank); + if(memcmp(&curBank, &bank, sizeof(StabilizationBankDataPacked)) != 0) + { + StabilizationSettingsBank2Set((StabilizationSettingsBank2Data *) &bank); + } + break; + + case 2: + StabilizationSettingsBank3Get((StabilizationSettingsBank3Data *) &curBank); + if(memcmp(&curBank, &bank, sizeof(StabilizationBankDataPacked)) != 0) + { + StabilizationSettingsBank3Set((StabilizationSettingsBank3Data *) &bank); + } + break; + + default: + return; //invalid bank number } -} - - -static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) -{ - StabilizationSettingsGet(&settings); - BankChanged(); - StabilizationBankData bank; - StabilizationBankGet(&bank); // Set the roll rate PID constants pid_configure(&pids[PID_RATE_ROLL], bank.RollRatePID.Kp, @@ -618,6 +619,12 @@ static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) bank.YawPI.Ki, 0, bank.YawPI.ILimit); +} + + +static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) +{ + StabilizationSettingsGet(&settings); // Set up the derivative term pid_configure_derivative(settings.DerivativeCutoff, settings.DerivativeGamma); @@ -652,6 +659,8 @@ static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) // Compute time constant for vbar decay term based on a tau vbar_decay = expf(-fakeDt / settings.VbarTau); + + flight_mode = -1; //force flight mode update } From 63ecf6ad7321f6ad4173587b97b124d40a318949 Mon Sep 17 00:00:00 2001 From: Les Newell Date: Wed, 11 Dec 2013 16:29:20 +0000 Subject: [PATCH 16/45] OP-984 txpid can now select which bank it operates on, rather than using the flight mode selected bank. --- flight/modules/TxPID/txpid.c | 39 +++++++++++++++++++- shared/uavobjectdefinition/txpidsettings.xml | 3 +- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/flight/modules/TxPID/txpid.c b/flight/modules/TxPID/txpid.c index c5865b61e..5a53565cc 100644 --- a/flight/modules/TxPID/txpid.c +++ b/flight/modules/TxPID/txpid.c @@ -57,6 +57,9 @@ #include "manualcontrolcommand.h" #include "stabilizationsettings.h" #include "stabilizationbank.h" +#include "stabilizationsettingsbank1.h" +#include "stabilizationsettingsbank2.h" +#include "stabilizationsettingsbank3.h" #include "flightstatus.h" #include "hwsettings.h" @@ -165,7 +168,23 @@ static void updatePIDs(UAVObjEvent *ev) } StabilizationBankData bank; - StabilizationBankGet(&bank); + switch(inst.UpdateMode) + { + case 0: + StabilizationSettingsBank1Get((StabilizationSettingsBank1Data *) &bank); + break; + + case 1: + StabilizationSettingsBank2Get((StabilizationSettingsBank2Data *) &bank); + break; + + case 2: + StabilizationSettingsBank2Get((StabilizationSettingsBank2Data *) &bank); + break; + + default: + return; + } StabilizationSettingsData stab; StabilizationSettingsGet(&stab); AccessoryDesiredData accessory; @@ -298,7 +317,23 @@ static void updatePIDs(UAVObjEvent *ev) StabilizationSettingsSet(&stab); } if (needsUpdateBank) { - StabilizationBankSet(&bank); + switch(inst.UpdateMode) + { + case 0: + StabilizationSettingsBank1Set((StabilizationSettingsBank1Data *) &bank); + break; + + case 1: + StabilizationSettingsBank2Set((StabilizationSettingsBank2Data *) &bank); + break; + + case 2: + StabilizationSettingsBank2Set((StabilizationSettingsBank2Data *) &bank); + break; + + default: + return; + } } } diff --git a/shared/uavobjectdefinition/txpidsettings.xml b/shared/uavobjectdefinition/txpidsettings.xml index 41c7d06ca..3276635e0 100644 --- a/shared/uavobjectdefinition/txpidsettings.xml +++ b/shared/uavobjectdefinition/txpidsettings.xml @@ -2,6 +2,7 @@ Settings used by @ref TxPID optional module to tune PID settings using R/C transmitter + + diff --git a/shared/uavobjectdefinition/txpidsettings.xml b/shared/uavobjectdefinition/txpidsettings.xml index 3276635e0..9f1a91579 100644 --- a/shared/uavobjectdefinition/txpidsettings.xml +++ b/shared/uavobjectdefinition/txpidsettings.xml @@ -2,7 +2,7 @@ Settings used by @ref TxPID optional module to tune PID settings using R/C transmitter - + Date: Sun, 29 Dec 2013 17:47:27 +0100 Subject: [PATCH 21/45] OP-984 Added GUI to configure which PID bank to use for the 3 common stabilization modes. --- .../src/plugins/config/configinputwidget.cpp | 4 + .../openpilotgcs/src/plugins/config/input.ui | 797 +++++++++++------- 2 files changed, 494 insertions(+), 307 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index d1040724f..19b1d843a 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -146,6 +146,10 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization2Settings", ui->fmsSsPos2Yaw, "Yaw", 1, true); addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization3Settings", ui->fmsSsPos3Yaw, "Yaw", 1, true); + addUAVObjectToWidgetRelation("StabilizationSettings", "FlightModeMap", ui->pidBankSs1, "Stabilized1", 1, true); + addUAVObjectToWidgetRelation("StabilizationSettings", "FlightModeMap", ui->pidBankSs2, "Stabilized2", 1, true); + addUAVObjectToWidgetRelation("StabilizationSettings", "FlightModeMap", ui->pidBankSs3, "Stabilized3", 1, true); + addUAVObjectToWidgetRelation("ManualControlSettings", "Arming", ui->armControl); addUAVObjectToWidgetRelation("ManualControlSettings", "ArmedTimeout", ui->armTimeout, 0, 1000); connect(ManualControlCommand::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(moveFMSlider())); diff --git a/ground/openpilotgcs/src/plugins/config/input.ui b/ground/openpilotgcs/src/plugins/config/input.ui index 0f4e78a1e..1049a15a9 100644 --- a/ground/openpilotgcs/src/plugins/config/input.ui +++ b/ground/openpilotgcs/src/plugins/config/input.ui @@ -14,7 +14,16 @@ Form - + + 12 + + + 12 + + + 12 + + 12 @@ -30,7 +39,16 @@ 0 - + + 0 + + + 0 + + + 0 + + 0 @@ -111,15 +129,24 @@ 0 0 850 - 572 + 589 - + + 12 + + + 12 + + + 12 + + 12 - -1 + 6 @@ -146,7 +173,16 @@ - + + 12 + + + 12 + + + 12 + + 12 @@ -245,11 +281,20 @@ - + + 12 + + + 12 + + + 12 + + 12 - + 0 @@ -260,28 +305,28 @@ true - - - - - - - - - - - - 0 - 0 - - - - true - - - + - + + + + + + + + + + 0 + 0 + + + + true + + + + + @@ -418,7 +463,16 @@ Flight Mode Switch Settings - + + 0 + + + 0 + + + 0 + + 0 @@ -499,284 +553,22 @@ 0 0 850 - 572 + 589 - + + 12 + + + 12 + + + 12 + + 12 - - - - - - - Configure each stabilization mode for each axis - - - - 9 - - - 12 - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 5 - 20 - - - - - - - - Qt::StrongFocus - - - - - - - - 0 - 20 - - - - - 16777215 - 20 - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - Yaw - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - - 5 - 20 - - - - - - - - Stabilized1 - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - - 5 - 20 - - - - - - - - Qt::StrongFocus - - - - - - - Stabilized2 - - - Qt::AlignCenter - - - - - - - Qt::StrongFocus - - - - - - - Qt::StrongFocus - - - - - - - - 0 - 20 - - - - - 16777215 - 20 - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - Pitch - - - Qt::AlignCenter - - - - - - - - 0 - 20 - - - - - 16777215 - 20 - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - Roll - - - Qt::AlignCenter - - - - - - - Qt::StrongFocus - - - - - - - - 102 - 0 - - - - Qt::StrongFocus - - - - - - - Qt::StrongFocus - - - - - - - - 102 - 0 - - - - Qt::StrongFocus - - - - - - - - 102 - 0 - - - - Qt::StrongFocus - - - - - - - Stabilized3 - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - @@ -795,7 +587,16 @@ margin:1px; FlightMode Switch Positions - + + 12 + + + 12 + + + 12 + + 12 @@ -1070,6 +871,9 @@ Setup the flight mode channel on the RC Input tab if you have not done so alread Qt::Horizontal + + QSizePolicy::Expanding + 40 @@ -1180,6 +984,367 @@ channel value for each flight mode. + + + + + + + Stabilization Modes Configuration + + + + 9 + + + 12 + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 5 + 20 + + + + + + + + + 0 + 20 + + + + + 16777215 + 20 + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + Yaw + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 20 + 20 + + + + + + + + Qt::StrongFocus + + + + + + + Stabilized 1 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 20 + 20 + + + + + + + + Stabilized 2 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Qt::StrongFocus + + + + + + + Qt::StrongFocus + + + + + + + Qt::StrongFocus + + + + + + + + 0 + 20 + + + + + 16777215 + 20 + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + Roll + + + Qt::AlignCenter + + + + + + + + 0 + 20 + + + + + 16777215 + 20 + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + Pitch + + + Qt::AlignCenter + + + + + + + Qt::StrongFocus + + + + + + + + 102 + 0 + + + + Qt::StrongFocus + + + + + + + Qt::StrongFocus + + + + + + + + 102 + 0 + + + + Qt::StrongFocus + + + + + + + Stabilized 3 + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + 102 + 0 + + + + Qt::StrongFocus + + + + + + + + 102 + 0 + + + + Qt::StrongFocus + + + + + + + + 102 + 0 + + + + Qt::StrongFocus + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 20 + + + + + 16777215 + 20 + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + PID Bank + + + Qt::AlignCenter + + + + + + + + 102 + 0 + + + + Qt::StrongFocus + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 20 + 20 + + + + + + + @@ -1207,7 +1372,16 @@ channel value for each flight mode. Arming Settings - + + 0 + + + 0 + + + 0 + + 0 @@ -1288,11 +1462,20 @@ channel value for each flight mode. 0 0 850 - 572 + 589 - + + 12 + + + 12 + + + 12 + + 12 From 99d6c9e4bd3789333daaa9f49073670729634dba Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Sun, 29 Dec 2013 18:02:16 +0100 Subject: [PATCH 22/45] OP-984 Added GUI for selecting PID bank for TxPID module. --- .../src/plugins/config/configtxpidwidget.cpp | 2 + .../openpilotgcs/src/plugins/config/txpid.ui | 47 +++++++++++++++++-- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configtxpidwidget.cpp b/ground/openpilotgcs/src/plugins/config/configtxpidwidget.cpp index 02902f5c8..3ec4ed1cb 100644 --- a/ground/openpilotgcs/src/plugins/config/configtxpidwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configtxpidwidget.cpp @@ -51,6 +51,8 @@ ConfigTxPIDWidget::ConfigTxPIDWidget(QWidget *parent) : ConfigTaskWidget(parent) connect(m_txpid->Apply, SIGNAL(clicked()), this, SLOT(applySettings())); connect(m_txpid->Save, SIGNAL(clicked()), this, SLOT(saveSettings())); + addUAVObjectToWidgetRelation("TxPIDSettings", "BankNumber", m_txpid->pidBank, 0, 1, true); + addUAVObjectToWidgetRelation("TxPIDSettings", "PIDs", m_txpid->PID1, TxPIDSettings::PIDS_INSTANCE1); addUAVObjectToWidgetRelation("TxPIDSettings", "PIDs", m_txpid->PID2, TxPIDSettings::PIDS_INSTANCE2); addUAVObjectToWidgetRelation("TxPIDSettings", "PIDs", m_txpid->PID3, TxPIDSettings::PIDS_INSTANCE3); diff --git a/ground/openpilotgcs/src/plugins/config/txpid.ui b/ground/openpilotgcs/src/plugins/config/txpid.ui index 58b2f4479..550102209 100644 --- a/ground/openpilotgcs/src/plugins/config/txpid.ui +++ b/ground/openpilotgcs/src/plugins/config/txpid.ui @@ -17,7 +17,16 @@ 6 - + + 12 + + + 12 + + + 12 + + 12 @@ -33,7 +42,16 @@ 6 - + + 0 + + + 0 + + + 0 + + 0 @@ -113,15 +131,24 @@ 0 0 - 745 - 469 + 742 + 450 6 - + + 12 + + + 12 + + + 12 + + 12 @@ -661,6 +688,16 @@ margin:1px; + + + + PID Bank + + + + + + From b244f8a3cd985ebf1ef3b992ca76563a8560894a Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Wed, 1 Jan 2014 22:49:04 +0100 Subject: [PATCH 23/45] OP-984 Some refactoring to prepare for multi PID bank GUI support. --- .../plugins/config/config_cc_hw_widget.cpp | 16 +- .../plugins/config/configccattitudewidget.cpp | 10 +- .../src/plugins/config/configinputwidget.cpp | 56 +- .../plugins/config/configpipxtremewidget.cpp | 64 +- .../src/plugins/config/configrevohwwidget.cpp | 24 +- .../src/plugins/config/configrevowidget.cpp | 10 +- .../src/plugins/config/configtxpidwidget.cpp | 32 +- .../src/plugins/config/stabilization.ui | 45 +- .../uavobjectwidgetutils/configtaskwidget.cpp | 598 ++++++++++-------- .../uavobjectwidgetutils/configtaskwidget.h | 130 ++-- .../uavobjectwidgetutils/smartsavebutton.cpp | 36 +- .../uavobjectwidgetutils/smartsavebutton.h | 4 +- 12 files changed, 582 insertions(+), 443 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp index a2301a783..03a39355b 100644 --- a/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp +++ b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp @@ -75,14 +75,14 @@ ConfigCCHWWidget::ConfigCCHWWidget(QWidget *parent) : ConfigTaskWidget(parent) break; } addApplySaveButtons(m_telemetry->saveTelemetryToRAM, m_telemetry->saveTelemetryToSD); - addUAVObjectToWidgetRelation("HwSettings", "CC_FlexiPort", m_telemetry->cbFlexi); - addUAVObjectToWidgetRelation("HwSettings", "CC_MainPort", m_telemetry->cbTele); - addUAVObjectToWidgetRelation("HwSettings", "CC_RcvrPort", m_telemetry->cbRcvr); - addUAVObjectToWidgetRelation("HwSettings", "USB_HIDPort", m_telemetry->cbUsbHid); - addUAVObjectToWidgetRelation("HwSettings", "USB_VCPPort", m_telemetry->cbUsbVcp); - addUAVObjectToWidgetRelation("HwSettings", "TelemetrySpeed", m_telemetry->telemetrySpeed); - addUAVObjectToWidgetRelation("HwSettings", "GPSSpeed", m_telemetry->gpsSpeed); - addUAVObjectToWidgetRelation("HwSettings", "ComUsbBridgeSpeed", m_telemetry->comUsbBridgeSpeed); + addWidgetBinding("HwSettings", "CC_FlexiPort", m_telemetry->cbFlexi); + addWidgetBinding("HwSettings", "CC_MainPort", m_telemetry->cbTele); + addWidgetBinding("HwSettings", "CC_RcvrPort", m_telemetry->cbRcvr); + addWidgetBinding("HwSettings", "USB_HIDPort", m_telemetry->cbUsbHid); + addWidgetBinding("HwSettings", "USB_VCPPort", m_telemetry->cbUsbVcp); + addWidgetBinding("HwSettings", "TelemetrySpeed", m_telemetry->telemetrySpeed); + addWidgetBinding("HwSettings", "GPSSpeed", m_telemetry->gpsSpeed); + addWidgetBinding("HwSettings", "ComUsbBridgeSpeed", m_telemetry->comUsbBridgeSpeed); connect(m_telemetry->cchwHelp, SIGNAL(clicked()), this, SLOT(openHelp())); enableSaveButtons(false); populateWidgets(); diff --git a/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp b/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp index 17a4269ff..74e9ecaa5 100644 --- a/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp @@ -58,12 +58,12 @@ ConfigCCAttitudeWidget::ConfigCCAttitudeWidget(QWidget *parent) : // Connect the help button connect(ui->ccAttitudeHelp, SIGNAL(clicked()), this, SLOT(openHelp())); - addUAVObjectToWidgetRelation("AttitudeSettings", "ZeroDuringArming", ui->zeroGyroBiasOnArming); - addUAVObjectToWidgetRelation("AttitudeSettings", "AccelTau", ui->accelTauSpinbox); + addWidgetBinding("AttitudeSettings", "ZeroDuringArming", ui->zeroGyroBiasOnArming); + addWidgetBinding("AttitudeSettings", "AccelTau", ui->accelTauSpinbox); - addUAVObjectToWidgetRelation("AttitudeSettings", "BoardRotation", ui->rollBias, AttitudeSettings::BOARDROTATION_ROLL); - addUAVObjectToWidgetRelation("AttitudeSettings", "BoardRotation", ui->pitchBias, AttitudeSettings::BOARDROTATION_PITCH); - addUAVObjectToWidgetRelation("AttitudeSettings", "BoardRotation", ui->yawBias, AttitudeSettings::BOARDROTATION_YAW); + addWidgetBinding("AttitudeSettings", "BoardRotation", ui->rollBias, AttitudeSettings::BOARDROTATION_ROLL); + addWidgetBinding("AttitudeSettings", "BoardRotation", ui->pitchBias, AttitudeSettings::BOARDROTATION_PITCH); + addWidgetBinding("AttitudeSettings", "BoardRotation", ui->yawBias, AttitudeSettings::BOARDROTATION_YAW); addWidget(ui->zeroBias); refreshWidgetsValues(); } diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index 19b1d843a..1cc7bd14e 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -84,11 +84,11 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : inputChannelForm *inpForm = new inputChannelForm(this, index == 0); ui->channelSettings->layout()->addWidget(inpForm); // Add the row to the UI inpForm->setName(name); - addUAVObjectToWidgetRelation("ManualControlSettings", "ChannelGroups", inpForm->ui->channelGroup, index); - addUAVObjectToWidgetRelation("ManualControlSettings", "ChannelNumber", inpForm->ui->channelNumber, index); - addUAVObjectToWidgetRelation("ManualControlSettings", "ChannelMin", inpForm->ui->channelMin, index); - addUAVObjectToWidgetRelation("ManualControlSettings", "ChannelNeutral", inpForm->ui->channelNeutral, index); - addUAVObjectToWidgetRelation("ManualControlSettings", "ChannelMax", inpForm->ui->channelMax, index); + addWidgetBinding("ManualControlSettings", "ChannelGroups", inpForm->ui->channelGroup, index); + addWidgetBinding("ManualControlSettings", "ChannelNumber", inpForm->ui->channelNumber, index); + addWidgetBinding("ManualControlSettings", "ChannelMin", inpForm->ui->channelMin, index); + addWidgetBinding("ManualControlSettings", "ChannelNeutral", inpForm->ui->channelNeutral, index); + addWidgetBinding("ManualControlSettings", "ChannelMax", inpForm->ui->channelMax, index); addWidget(inpForm->ui->channelNumberDropdown); addWidget(inpForm->ui->channelRev); addWidget(inpForm->ui->channelResponseTime); @@ -101,7 +101,7 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : case ManualControlSettings::CHANNELGROUPS_ACCESSORY0: case ManualControlSettings::CHANNELGROUPS_ACCESSORY1: case ManualControlSettings::CHANNELGROUPS_ACCESSORY2: - addUAVObjectToWidgetRelation("ManualControlSettings", "ResponseTime", inpForm->ui->channelResponseTime, indexRT); + addWidgetBinding("ManualControlSettings", "ResponseTime", inpForm->ui->channelResponseTime, indexRT); ++indexRT; break; case ManualControlSettings::CHANNELGROUPS_THROTTLE: @@ -117,7 +117,7 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ++index; } - addUAVObjectToWidgetRelation("ManualControlSettings", "Deadband", ui->deadband, 0, 0.01f); + addWidgetBinding("ManualControlSettings", "Deadband", ui->deadband, 0, 0.01f); connect(ui->configurationWizard, SIGNAL(clicked()), this, SLOT(goToWizard())); connect(ui->stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(disableWizardButton(int))); @@ -128,30 +128,30 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : connect(ui->wzBack, SIGNAL(clicked()), this, SLOT(wzBack())); ui->stackedWidget->setCurrentIndex(0); - addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", ui->fmsModePos1, 0, 1, true); - addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", ui->fmsModePos2, 1, 1, true); - addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", ui->fmsModePos3, 2, 1, true); - addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", ui->fmsModePos4, 3, 1, true); - addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", ui->fmsModePos5, 4, 1, true); - addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", ui->fmsModePos6, 5, 1, true); - addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModeNumber", ui->fmsPosNum); + addWidgetBinding("ManualControlSettings", "FlightModePosition", ui->fmsModePos1, 0, 1, true); + addWidgetBinding("ManualControlSettings", "FlightModePosition", ui->fmsModePos2, 1, 1, true); + addWidgetBinding("ManualControlSettings", "FlightModePosition", ui->fmsModePos3, 2, 1, true); + addWidgetBinding("ManualControlSettings", "FlightModePosition", ui->fmsModePos4, 3, 1, true); + addWidgetBinding("ManualControlSettings", "FlightModePosition", ui->fmsModePos5, 4, 1, true); + addWidgetBinding("ManualControlSettings", "FlightModePosition", ui->fmsModePos6, 5, 1, true); + addWidgetBinding("ManualControlSettings", "FlightModeNumber", ui->fmsPosNum); - addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization1Settings", ui->fmsSsPos1Roll, "Roll", 1, true); - addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization2Settings", ui->fmsSsPos2Roll, "Roll", 1, true); - addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization3Settings", ui->fmsSsPos3Roll, "Roll", 1, true); - addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization1Settings", ui->fmsSsPos1Pitch, "Pitch", 1, true); - addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization2Settings", ui->fmsSsPos2Pitch, "Pitch", 1, true); - addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization3Settings", ui->fmsSsPos3Pitch, "Pitch", 1, true); - addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization1Settings", ui->fmsSsPos1Yaw, "Yaw", 1, true); - addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization2Settings", ui->fmsSsPos2Yaw, "Yaw", 1, true); - addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization3Settings", ui->fmsSsPos3Yaw, "Yaw", 1, true); + addWidgetBinding("ManualControlSettings", "Stabilization1Settings", ui->fmsSsPos1Roll, "Roll", 1, true); + addWidgetBinding("ManualControlSettings", "Stabilization2Settings", ui->fmsSsPos2Roll, "Roll", 1, true); + addWidgetBinding("ManualControlSettings", "Stabilization3Settings", ui->fmsSsPos3Roll, "Roll", 1, true); + addWidgetBinding("ManualControlSettings", "Stabilization1Settings", ui->fmsSsPos1Pitch, "Pitch", 1, true); + addWidgetBinding("ManualControlSettings", "Stabilization2Settings", ui->fmsSsPos2Pitch, "Pitch", 1, true); + addWidgetBinding("ManualControlSettings", "Stabilization3Settings", ui->fmsSsPos3Pitch, "Pitch", 1, true); + addWidgetBinding("ManualControlSettings", "Stabilization1Settings", ui->fmsSsPos1Yaw, "Yaw", 1, true); + addWidgetBinding("ManualControlSettings", "Stabilization2Settings", ui->fmsSsPos2Yaw, "Yaw", 1, true); + addWidgetBinding("ManualControlSettings", "Stabilization3Settings", ui->fmsSsPos3Yaw, "Yaw", 1, true); - addUAVObjectToWidgetRelation("StabilizationSettings", "FlightModeMap", ui->pidBankSs1, "Stabilized1", 1, true); - addUAVObjectToWidgetRelation("StabilizationSettings", "FlightModeMap", ui->pidBankSs2, "Stabilized2", 1, true); - addUAVObjectToWidgetRelation("StabilizationSettings", "FlightModeMap", ui->pidBankSs3, "Stabilized3", 1, true); + addWidgetBinding("StabilizationSettings", "FlightModeMap", ui->pidBankSs1, "Stabilized1", 1, true); + addWidgetBinding("StabilizationSettings", "FlightModeMap", ui->pidBankSs2, "Stabilized2", 1, true); + addWidgetBinding("StabilizationSettings", "FlightModeMap", ui->pidBankSs3, "Stabilized3", 1, true); - addUAVObjectToWidgetRelation("ManualControlSettings", "Arming", ui->armControl); - addUAVObjectToWidgetRelation("ManualControlSettings", "ArmedTimeout", ui->armTimeout, 0, 1000); + addWidgetBinding("ManualControlSettings", "Arming", ui->armControl); + addWidgetBinding("ManualControlSettings", "ArmedTimeout", ui->armTimeout, 0, 1000); connect(ManualControlCommand::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(moveFMSlider())); connect(ManualControlSettings::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updatePositionSlider())); diff --git a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp index b9035e7fe..b0c14b7f4 100644 --- a/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configpipxtremewidget.cpp @@ -60,39 +60,39 @@ ConfigPipXtremeWidget::ConfigPipXtremeWidget(QWidget *parent) : ConfigTaskWidget } addApplySaveButtons(m_oplink->Apply, m_oplink->Save); - addUAVObjectToWidgetRelation("OPLinkSettings", "MainPort", m_oplink->MainPort); - addUAVObjectToWidgetRelation("OPLinkSettings", "FlexiPort", m_oplink->FlexiPort); - addUAVObjectToWidgetRelation("OPLinkSettings", "VCPPort", m_oplink->VCPPort); - addUAVObjectToWidgetRelation("OPLinkSettings", "ComSpeed", m_oplink->ComSpeed); - addUAVObjectToWidgetRelation("OPLinkSettings", "MaxRFPower", m_oplink->MaxRFTxPower); - addUAVObjectToWidgetRelation("OPLinkSettings", "MinChannel", m_oplink->MinimumChannel); - addUAVObjectToWidgetRelation("OPLinkSettings", "MaxChannel", m_oplink->MaximumChannel); - addUAVObjectToWidgetRelation("OPLinkSettings", "ChannelSet", m_oplink->ChannelSet); - addUAVObjectToWidgetRelation("OPLinkSettings", "CoordID", m_oplink->CoordID); - addUAVObjectToWidgetRelation("OPLinkSettings", "Coordinator", m_oplink->Coordinator); - addUAVObjectToWidgetRelation("OPLinkSettings", "OneWay", m_oplink->OneWayLink); - addUAVObjectToWidgetRelation("OPLinkSettings", "PPMOnly", m_oplink->PPMOnly); - addUAVObjectToWidgetRelation("OPLinkSettings", "PPM", m_oplink->PPM); + addWidgetBinding("OPLinkSettings", "MainPort", m_oplink->MainPort); + addWidgetBinding("OPLinkSettings", "FlexiPort", m_oplink->FlexiPort); + addWidgetBinding("OPLinkSettings", "VCPPort", m_oplink->VCPPort); + addWidgetBinding("OPLinkSettings", "ComSpeed", m_oplink->ComSpeed); + addWidgetBinding("OPLinkSettings", "MaxRFPower", m_oplink->MaxRFTxPower); + addWidgetBinding("OPLinkSettings", "MinChannel", m_oplink->MinimumChannel); + addWidgetBinding("OPLinkSettings", "MaxChannel", m_oplink->MaximumChannel); + addWidgetBinding("OPLinkSettings", "ChannelSet", m_oplink->ChannelSet); + addWidgetBinding("OPLinkSettings", "CoordID", m_oplink->CoordID); + addWidgetBinding("OPLinkSettings", "Coordinator", m_oplink->Coordinator); + addWidgetBinding("OPLinkSettings", "OneWay", m_oplink->OneWayLink); + addWidgetBinding("OPLinkSettings", "PPMOnly", m_oplink->PPMOnly); + addWidgetBinding("OPLinkSettings", "PPM", m_oplink->PPM); - addUAVObjectToWidgetRelation("OPLinkStatus", "DeviceID", m_oplink->DeviceID); - addUAVObjectToWidgetRelation("OPLinkStatus", "RxGood", m_oplink->Good); - addUAVObjectToWidgetRelation("OPLinkStatus", "RxCorrected", m_oplink->Corrected); - addUAVObjectToWidgetRelation("OPLinkStatus", "RxErrors", m_oplink->Errors); - addUAVObjectToWidgetRelation("OPLinkStatus", "RxMissed", m_oplink->Missed); - addUAVObjectToWidgetRelation("OPLinkStatus", "RxFailure", m_oplink->RxFailure); - addUAVObjectToWidgetRelation("OPLinkStatus", "UAVTalkErrors", m_oplink->UAVTalkErrors); - addUAVObjectToWidgetRelation("OPLinkStatus", "TxDropped", m_oplink->Dropped); - addUAVObjectToWidgetRelation("OPLinkStatus", "TxResent", m_oplink->Resent); - addUAVObjectToWidgetRelation("OPLinkStatus", "TxFailure", m_oplink->TxFailure); - addUAVObjectToWidgetRelation("OPLinkStatus", "Resets", m_oplink->Resets); - addUAVObjectToWidgetRelation("OPLinkStatus", "Timeouts", m_oplink->Timeouts); - addUAVObjectToWidgetRelation("OPLinkStatus", "RSSI", m_oplink->RSSI); - addUAVObjectToWidgetRelation("OPLinkStatus", "HeapRemaining", m_oplink->FreeHeap); - addUAVObjectToWidgetRelation("OPLinkStatus", "LinkQuality", m_oplink->LinkQuality); - addUAVObjectToWidgetRelation("OPLinkStatus", "RXSeq", m_oplink->RXSeq); - addUAVObjectToWidgetRelation("OPLinkStatus", "TXSeq", m_oplink->TXSeq); - addUAVObjectToWidgetRelation("OPLinkStatus", "RXRate", m_oplink->RXRate); - addUAVObjectToWidgetRelation("OPLinkStatus", "TXRate", m_oplink->TXRate); + addWidgetBinding("OPLinkStatus", "DeviceID", m_oplink->DeviceID); + addWidgetBinding("OPLinkStatus", "RxGood", m_oplink->Good); + addWidgetBinding("OPLinkStatus", "RxCorrected", m_oplink->Corrected); + addWidgetBinding("OPLinkStatus", "RxErrors", m_oplink->Errors); + addWidgetBinding("OPLinkStatus", "RxMissed", m_oplink->Missed); + addWidgetBinding("OPLinkStatus", "RxFailure", m_oplink->RxFailure); + addWidgetBinding("OPLinkStatus", "UAVTalkErrors", m_oplink->UAVTalkErrors); + addWidgetBinding("OPLinkStatus", "TxDropped", m_oplink->Dropped); + addWidgetBinding("OPLinkStatus", "TxResent", m_oplink->Resent); + addWidgetBinding("OPLinkStatus", "TxFailure", m_oplink->TxFailure); + addWidgetBinding("OPLinkStatus", "Resets", m_oplink->Resets); + addWidgetBinding("OPLinkStatus", "Timeouts", m_oplink->Timeouts); + addWidgetBinding("OPLinkStatus", "RSSI", m_oplink->RSSI); + addWidgetBinding("OPLinkStatus", "HeapRemaining", m_oplink->FreeHeap); + addWidgetBinding("OPLinkStatus", "LinkQuality", m_oplink->LinkQuality); + addWidgetBinding("OPLinkStatus", "RXSeq", m_oplink->RXSeq); + addWidgetBinding("OPLinkStatus", "TXSeq", m_oplink->TXSeq); + addWidgetBinding("OPLinkStatus", "RXRate", m_oplink->RXRate); + addWidgetBinding("OPLinkStatus", "TXRate", m_oplink->TXRate); // Connect the bind buttons connect(m_oplink->Bind1, SIGNAL(clicked()), this, SLOT(bind1())); diff --git a/ground/openpilotgcs/src/plugins/config/configrevohwwidget.cpp b/ground/openpilotgcs/src/plugins/config/configrevohwwidget.cpp index 70f0c2d81..54a0928fb 100644 --- a/ground/openpilotgcs/src/plugins/config/configrevohwwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configrevohwwidget.cpp @@ -49,21 +49,21 @@ ConfigRevoHWWidget::ConfigRevoHWWidget(QWidget *parent) : ConfigTaskWidget(paren addApplySaveButtons(m_ui->saveTelemetryToRAM, m_ui->saveTelemetryToSD); - addUAVObjectToWidgetRelation("HwSettings", "RM_FlexiPort", m_ui->cbFlexi); - addUAVObjectToWidgetRelation("HwSettings", "RM_MainPort", m_ui->cbMain); - addUAVObjectToWidgetRelation("HwSettings", "RM_RcvrPort", m_ui->cbRcvr); + addWidgetBinding("HwSettings", "RM_FlexiPort", m_ui->cbFlexi); + addWidgetBinding("HwSettings", "RM_MainPort", m_ui->cbMain); + addWidgetBinding("HwSettings", "RM_RcvrPort", m_ui->cbRcvr); - addUAVObjectToWidgetRelation("HwSettings", "USB_HIDPort", m_ui->cbUSBHIDFunction); - addUAVObjectToWidgetRelation("HwSettings", "USB_VCPPort", m_ui->cbUSBVCPFunction); - addUAVObjectToWidgetRelation("HwSettings", "ComUsbBridgeSpeed", m_ui->cbUSBVCPSpeed); + addWidgetBinding("HwSettings", "USB_HIDPort", m_ui->cbUSBHIDFunction); + addWidgetBinding("HwSettings", "USB_VCPPort", m_ui->cbUSBVCPFunction); + addWidgetBinding("HwSettings", "ComUsbBridgeSpeed", m_ui->cbUSBVCPSpeed); - addUAVObjectToWidgetRelation("HwSettings", "TelemetrySpeed", m_ui->cbFlexiTelemSpeed); - addUAVObjectToWidgetRelation("HwSettings", "GPSSpeed", m_ui->cbFlexiGPSSpeed); - addUAVObjectToWidgetRelation("HwSettings", "ComUsbBridgeSpeed", m_ui->cbFlexiComSpeed); + addWidgetBinding("HwSettings", "TelemetrySpeed", m_ui->cbFlexiTelemSpeed); + addWidgetBinding("HwSettings", "GPSSpeed", m_ui->cbFlexiGPSSpeed); + addWidgetBinding("HwSettings", "ComUsbBridgeSpeed", m_ui->cbFlexiComSpeed); - addUAVObjectToWidgetRelation("HwSettings", "TelemetrySpeed", m_ui->cbMainTelemSpeed); - addUAVObjectToWidgetRelation("HwSettings", "GPSSpeed", m_ui->cbMainGPSSpeed); - addUAVObjectToWidgetRelation("HwSettings", "ComUsbBridgeSpeed", m_ui->cbMainComSpeed); + addWidgetBinding("HwSettings", "TelemetrySpeed", m_ui->cbMainTelemSpeed); + addWidgetBinding("HwSettings", "GPSSpeed", m_ui->cbMainGPSSpeed); + addWidgetBinding("HwSettings", "ComUsbBridgeSpeed", m_ui->cbMainComSpeed); connect(m_ui->cchwHelp, SIGNAL(clicked()), this, SLOT(openHelp())); diff --git a/ground/openpilotgcs/src/plugins/config/configrevowidget.cpp b/ground/openpilotgcs/src/plugins/config/configrevowidget.cpp index d3e61d9d1..9f85cbf76 100644 --- a/ground/openpilotgcs/src/plugins/config/configrevowidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configrevowidget.cpp @@ -226,12 +226,12 @@ ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) : connect(m_ui->hlClearButton, SIGNAL(clicked()), this, SLOT(clearHomeLocation())); - addUAVObjectToWidgetRelation("RevoSettings", "FusionAlgorithm", m_ui->FusionAlgorithm); + addWidgetBinding("RevoSettings", "FusionAlgorithm", m_ui->FusionAlgorithm); - addUAVObjectToWidgetRelation("AttitudeSettings", "BoardRotation", m_ui->rollRotation, AttitudeSettings::BOARDROTATION_ROLL); - addUAVObjectToWidgetRelation("AttitudeSettings", "BoardRotation", m_ui->pitchRotation, AttitudeSettings::BOARDROTATION_PITCH); - addUAVObjectToWidgetRelation("AttitudeSettings", "BoardRotation", m_ui->yawRotation, AttitudeSettings::BOARDROTATION_YAW); - addUAVObjectToWidgetRelation("AttitudeSettings", "AccelTau", m_ui->accelTau); + addWidgetBinding("AttitudeSettings", "BoardRotation", m_ui->rollRotation, AttitudeSettings::BOARDROTATION_ROLL); + addWidgetBinding("AttitudeSettings", "BoardRotation", m_ui->pitchRotation, AttitudeSettings::BOARDROTATION_PITCH); + addWidgetBinding("AttitudeSettings", "BoardRotation", m_ui->yawRotation, AttitudeSettings::BOARDROTATION_YAW); + addWidgetBinding("AttitudeSettings", "AccelTau", m_ui->accelTau); populateWidgets(); refreshWidgetsValues(); diff --git a/ground/openpilotgcs/src/plugins/config/configtxpidwidget.cpp b/ground/openpilotgcs/src/plugins/config/configtxpidwidget.cpp index 3ec4ed1cb..85657e0f3 100644 --- a/ground/openpilotgcs/src/plugins/config/configtxpidwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configtxpidwidget.cpp @@ -51,28 +51,28 @@ ConfigTxPIDWidget::ConfigTxPIDWidget(QWidget *parent) : ConfigTaskWidget(parent) connect(m_txpid->Apply, SIGNAL(clicked()), this, SLOT(applySettings())); connect(m_txpid->Save, SIGNAL(clicked()), this, SLOT(saveSettings())); - addUAVObjectToWidgetRelation("TxPIDSettings", "BankNumber", m_txpid->pidBank, 0, 1, true); + addWidgetBinding("TxPIDSettings", "BankNumber", m_txpid->pidBank, 0, 1, true); - addUAVObjectToWidgetRelation("TxPIDSettings", "PIDs", m_txpid->PID1, TxPIDSettings::PIDS_INSTANCE1); - addUAVObjectToWidgetRelation("TxPIDSettings", "PIDs", m_txpid->PID2, TxPIDSettings::PIDS_INSTANCE2); - addUAVObjectToWidgetRelation("TxPIDSettings", "PIDs", m_txpid->PID3, TxPIDSettings::PIDS_INSTANCE3); + addWidgetBinding("TxPIDSettings", "PIDs", m_txpid->PID1, TxPIDSettings::PIDS_INSTANCE1); + addWidgetBinding("TxPIDSettings", "PIDs", m_txpid->PID2, TxPIDSettings::PIDS_INSTANCE2); + addWidgetBinding("TxPIDSettings", "PIDs", m_txpid->PID3, TxPIDSettings::PIDS_INSTANCE3); - addUAVObjectToWidgetRelation("TxPIDSettings", "Inputs", m_txpid->Input1, TxPIDSettings::INPUTS_INSTANCE1); - addUAVObjectToWidgetRelation("TxPIDSettings", "Inputs", m_txpid->Input2, TxPIDSettings::INPUTS_INSTANCE2); - addUAVObjectToWidgetRelation("TxPIDSettings", "Inputs", m_txpid->Input3, TxPIDSettings::INPUTS_INSTANCE3); + addWidgetBinding("TxPIDSettings", "Inputs", m_txpid->Input1, TxPIDSettings::INPUTS_INSTANCE1); + addWidgetBinding("TxPIDSettings", "Inputs", m_txpid->Input2, TxPIDSettings::INPUTS_INSTANCE2); + addWidgetBinding("TxPIDSettings", "Inputs", m_txpid->Input3, TxPIDSettings::INPUTS_INSTANCE3); - addUAVObjectToWidgetRelation("TxPIDSettings", "MinPID", m_txpid->MinPID1, TxPIDSettings::MINPID_INSTANCE1); - addUAVObjectToWidgetRelation("TxPIDSettings", "MinPID", m_txpid->MinPID2, TxPIDSettings::MINPID_INSTANCE2); - addUAVObjectToWidgetRelation("TxPIDSettings", "MinPID", m_txpid->MinPID3, TxPIDSettings::MINPID_INSTANCE3); + addWidgetBinding("TxPIDSettings", "MinPID", m_txpid->MinPID1, TxPIDSettings::MINPID_INSTANCE1); + addWidgetBinding("TxPIDSettings", "MinPID", m_txpid->MinPID2, TxPIDSettings::MINPID_INSTANCE2); + addWidgetBinding("TxPIDSettings", "MinPID", m_txpid->MinPID3, TxPIDSettings::MINPID_INSTANCE3); - addUAVObjectToWidgetRelation("TxPIDSettings", "MaxPID", m_txpid->MaxPID1, TxPIDSettings::MAXPID_INSTANCE1); - addUAVObjectToWidgetRelation("TxPIDSettings", "MaxPID", m_txpid->MaxPID2, TxPIDSettings::MAXPID_INSTANCE2); - addUAVObjectToWidgetRelation("TxPIDSettings", "MaxPID", m_txpid->MaxPID3, TxPIDSettings::MAXPID_INSTANCE3); + addWidgetBinding("TxPIDSettings", "MaxPID", m_txpid->MaxPID1, TxPIDSettings::MAXPID_INSTANCE1); + addWidgetBinding("TxPIDSettings", "MaxPID", m_txpid->MaxPID2, TxPIDSettings::MAXPID_INSTANCE2); + addWidgetBinding("TxPIDSettings", "MaxPID", m_txpid->MaxPID3, TxPIDSettings::MAXPID_INSTANCE3); - addUAVObjectToWidgetRelation("TxPIDSettings", "ThrottleRange", m_txpid->ThrottleMin, TxPIDSettings::THROTTLERANGE_MIN); - addUAVObjectToWidgetRelation("TxPIDSettings", "ThrottleRange", m_txpid->ThrottleMax, TxPIDSettings::THROTTLERANGE_MAX); + addWidgetBinding("TxPIDSettings", "ThrottleRange", m_txpid->ThrottleMin, TxPIDSettings::THROTTLERANGE_MIN); + addWidgetBinding("TxPIDSettings", "ThrottleRange", m_txpid->ThrottleMax, TxPIDSettings::THROTTLERANGE_MAX); - addUAVObjectToWidgetRelation("TxPIDSettings", "UpdateMode", m_txpid->UpdateMode); + addWidgetBinding("TxPIDSettings", "UpdateMode", m_txpid->UpdateMode); addWidget(m_txpid->TxPIDEnable); diff --git a/ground/openpilotgcs/src/plugins/config/stabilization.ui b/ground/openpilotgcs/src/plugins/config/stabilization.ui index 034b51f0d..41633f7d5 100644 --- a/ground/openpilotgcs/src/plugins/config/stabilization.ui +++ b/ground/openpilotgcs/src/plugins/config/stabilization.ui @@ -627,7 +627,7 @@ 0 0 - 778 + 796 659 @@ -8752,6 +8752,35 @@ border-radius: 5; + + + + + 0 + 0 + + + + + 16777215 + 22 + + + + 0 + + + + Tab 1 + + + + + Tab 2 + + + + @@ -8867,9 +8896,9 @@ border-radius: 5; 0 - -117 - 778 - 762 + 0 + 779 + 684 @@ -18908,8 +18937,8 @@ border-radius: 5; 0 0 - 792 - 645 + 796 + 659 @@ -27021,8 +27050,8 @@ border-radius: 5; 0 0 - 792 - 645 + 796 + 659 diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index ac6951d3a..32d8f0038 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -32,17 +32,17 @@ /** * Constructor */ -ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent), isConnected(false), allowWidgetUpdates(true), smartsave(NULL), dirty(false), outOfLimitsStyle("background-color: rgb(255, 0, 0);"), timeOut(NULL) +ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent), m_isConnected(false), m_isWidgetUpdatesAllowed(true), + m_saveButton(NULL), m_isDirty(false), m_outOfLimitsStyle("background-color: rgb(255, 0, 0);"), m_realtimeUpdateTimer(NULL) { - pm = ExtensionSystem::PluginManager::instance(); - objManager = pm->getObject(); - TelemetryManager *telMngr = pm->getObject(); - utilMngr = pm->getObject(); + m_pluginManager = ExtensionSystem::PluginManager::instance(); + TelemetryManager *telMngr = m_pluginManager->getObject(); + m_objectUtilManager = m_pluginManager->getObject(); connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect()), Qt::UniqueConnection); connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect()), Qt::UniqueConnection); connect(telMngr, SIGNAL(connected()), this, SIGNAL(autoPilotConnected()), Qt::UniqueConnection); connect(telMngr, SIGNAL(disconnected()), this, SIGNAL(autoPilotDisconnected()), Qt::UniqueConnection); - UAVSettingsImportExportFactory *importexportplugin = pm->getObject(); + UAVSettingsImportExportFactory *importexportplugin = m_pluginManager->getObject(); connect(importexportplugin, SIGNAL(importAboutToBegin()), this, SLOT(invalidateObjects())); } @@ -52,15 +52,16 @@ ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent), isConnect */ void ConfigTaskWidget::addWidget(QWidget *widget) { - addUAVObjectToWidgetRelation("", "", widget); + addWidgetBinding("", "", widget); } + /** * Add an object to the management system * @param objectName name of the object to add to the management system */ void ConfigTaskWidget::addUAVObject(QString objectName, QList *reloadGroups) { - addUAVObjectToWidgetRelation(objectName, "", NULL, 0, 1, false, reloadGroups); + addWidgetBinding(objectName, "", NULL, 0, 1, false, reloadGroups); } void ConfigTaskWidget::addUAVObject(UAVObject *objectName, QList *reloadGroups) @@ -72,6 +73,7 @@ void ConfigTaskWidget::addUAVObject(UAVObject *objectName, QList *reloadGro } addUAVObject(objstr, reloadGroups); } + /** * Add an UAVObject field to widget relation to the management system * @param object name of the object to add @@ -79,19 +81,19 @@ void ConfigTaskWidget::addUAVObject(UAVObject *objectName, QList *reloadGro * @param widget pointer to the widget whitch will display/define the field value * @param index index of the field element to add to this relation */ -void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString field, QWidget *widget, QString index) +void ConfigTaskWidget::addWidgetBinding(QString object, QString field, QWidget *widget, QString index) { UAVObject *obj = NULL; UAVObjectField *_field = NULL; - obj = objManager->getObject(QString(object)); + obj = getObject(QString(object)); Q_ASSERT(obj); _field = obj->getField(QString(field)); Q_ASSERT(_field); - addUAVObjectToWidgetRelation(object, field, widget, _field->getElementNames().indexOf(index)); + addWidgetBinding(object, field, widget, _field->getElementNames().indexOf(index)); } -void ConfigTaskWidget::addUAVObjectToWidgetRelation(UAVObject *obj, UAVObjectField *field, QWidget *widget, QString index) +void ConfigTaskWidget::addWidgetBinding(UAVObject *obj, UAVObjectField *field, QWidget *widget, QString index) { QString objstr; QString fieldstr; @@ -102,7 +104,7 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(UAVObject *obj, UAVObjectFie if (field) { fieldstr = field->getName(); } - addUAVObjectToWidgetRelation(objstr, fieldstr, widget, index); + addWidgetBinding(objstr, fieldstr, widget, index); } /** * Add a UAVObject field to widget relation to the management system @@ -115,9 +117,9 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(UAVObject *obj, UAVObjectFie * @param defaultReloadGroups default and reload groups this relation belongs to * @param instID instance ID of the object used on this relation */ -void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString field, QWidget *widget, QString element, double scale, bool isLimited, QList *defaultReloadGroups, quint32 instID) +void ConfigTaskWidget::addWidgetBinding(QString object, QString field, QWidget *widget, QString element, double scale, bool isLimited, QList *defaultReloadGroups, quint32 instID) { - UAVObject *obj = objManager->getObject(QString(object), instID); + UAVObject *obj = getObject(QString(object), instID); Q_ASSERT(obj); UAVObjectField *_field; @@ -128,10 +130,10 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString fiel index = _field->getElementNames().indexOf(QString(element)); } } - addUAVObjectToWidgetRelation(object, field, widget, index, scale, isLimited, defaultReloadGroups, instID); + addWidgetBinding(object, field, widget, index, scale, isLimited, defaultReloadGroups, instID); } -void ConfigTaskWidget::addUAVObjectToWidgetRelation(UAVObject *obj, UAVObjectField *field, QWidget *widget, QString element, double scale, bool isLimited, QList *defaultReloadGroups, quint32 instID) +void ConfigTaskWidget::addWidgetBinding(UAVObject *obj, UAVObjectField *field, QWidget *widget, QString element, double scale, bool isLimited, QList *defaultReloadGroups, quint32 instID) { QString objstr; QString fieldstr; @@ -142,9 +144,10 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(UAVObject *obj, UAVObjectFie if (field) { fieldstr = field->getName(); } - addUAVObjectToWidgetRelation(objstr, fieldstr, widget, element, scale, isLimited, defaultReloadGroups, instID); + addWidgetBinding(objstr, fieldstr, widget, element, scale, isLimited, defaultReloadGroups, instID); } -void ConfigTaskWidget::addUAVObjectToWidgetRelation(UAVObject *obj, UAVObjectField *field, QWidget *widget, int index, double scale, bool isLimited, QList *defaultReloadGroups, quint32 instID) + +void ConfigTaskWidget::addWidgetBinding(UAVObject *obj, UAVObjectField *field, QWidget *widget, int index, double scale, bool isLimited, QList *defaultReloadGroups, quint32 instID) { QString objstr; QString fieldstr; @@ -155,7 +158,7 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(UAVObject *obj, UAVObjectFie if (field) { fieldstr = field->getName(); } - addUAVObjectToWidgetRelation(objstr, fieldstr, widget, index, scale, isLimited, defaultReloadGroups, instID); + addWidgetBinding(objstr, fieldstr, widget, index, scale, isLimited, defaultReloadGroups, instID); } /** @@ -169,45 +172,41 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(UAVObject *obj, UAVObjectFie * @param defaultReloadGroups default and reload groups this relation belongs to * @param instID instance ID of the object used on this relation */ -void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString field, QWidget *widget, int index, double scale, bool isLimited, QList *defaultReloadGroups, quint32 instID) +void ConfigTaskWidget::addWidgetBinding(QString object, QString field, QWidget *widget, int index, double scale, bool isLimited, QList *defaultReloadGroups, quint32 instID) { - if (addShadowWidget(object, field, widget, index, scale, isLimited, defaultReloadGroups, instID)) { + if (addShadowWidgetBinding(object, field, widget, index, scale, isLimited, defaultReloadGroups, instID)) { return; } UAVObject *obj = NULL; UAVObjectField *_field = NULL; if (!object.isEmpty()) { - obj = objManager->getObject(QString(object), instID); + obj = getObject(QString(object), instID); Q_ASSERT(obj); - objectUpdates.insert(obj, true); + m_updatedObjects.insert(obj, true); connect(obj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(objectUpdated(UAVObject *))); connect(obj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(refreshWidgetsValues(UAVObject *)), Qt::UniqueConnection); } + if (!field.isEmpty() && obj) { _field = obj->getField(QString(field)); } - objectToWidget *ow = new objectToWidget(); - ow->field = _field; - ow->object = obj; - ow->widget = widget; - ow->index = index; - ow->scale = scale; - ow->isLimited = isLimited; - objOfInterest.append(ow); - if (obj) { - if (smartsave) { - smartsave->addObject((UAVDataObject *)obj); - } + + WidgetBinding *binding = new WidgetBinding(widget, obj, _field, index, scale, isLimited); + m_widgetBindings.append(binding); + + if (obj && m_saveButton) { + m_saveButton->addObject((UAVDataObject *)obj); } - if (widget == NULL) { + + if (!widget) { if (defaultReloadGroups && obj) { foreach(int i, *defaultReloadGroups) { - if (this->defaultReloadGroups.contains(i)) { - this->defaultReloadGroups.value(i)->append(ow); + if (this->m_reloadGroups.contains(i)) { + this->m_reloadGroups.value(i)->append(binding); } else { - this->defaultReloadGroups.insert(i, new QList()); - this->defaultReloadGroups.value(i)->append(ow); + this->m_reloadGroups.insert(i, new QList()); + this->m_reloadGroups.value(i)->append(binding); } } } @@ -216,31 +215,32 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString fiel if (defaultReloadGroups) { addWidgetToDefaultReloadGroups(widget, defaultReloadGroups); } - shadowsList.insert(widget, ow); + m_shadowBindings.insert(widget, binding); loadWidgetLimits(widget, _field, index, isLimited, scale); } } + /** * destructor */ ConfigTaskWidget::~ConfigTaskWidget() { - if (smartsave) { - delete smartsave; + if (m_saveButton) { + delete m_saveButton; } - foreach(QList *pointer, defaultReloadGroups.values()) { - if (pointer) { - delete pointer; + foreach(QList *reloadGroup, m_reloadGroups.values()) { + if (reloadGroup) { + delete reloadGroup; } } - foreach(objectToWidget * oTw, objOfInterest) { - if (oTw) { - delete oTw; + foreach(WidgetBinding * binding, m_widgetBindings) { + if (binding) { + delete binding; } } - if (timeOut) { - delete timeOut; - timeOut = NULL; + if (m_realtimeUpdateTimer) { + delete m_realtimeUpdateTimer; + m_realtimeUpdateTimer = NULL; } } @@ -310,26 +310,26 @@ double ConfigTaskWidget::listVar(QList list) void ConfigTaskWidget::onAutopilotDisconnect() { - isConnected = false; + m_isConnected = false; enableControls(false); invalidateObjects(); } void ConfigTaskWidget::forceConnectedState() // dynamic widgets don't recieve the connected signal. This should be called instead. { - isConnected = true; + m_isConnected = true; setDirty(false); } void ConfigTaskWidget::onAutopilotConnect() { - if (utilMngr) { - currentBoard = utilMngr->getBoardModel(); // TODO REMEMBER TO ADD THIS TO FORCE CONNECTED FUNC ON CC3D_RELEASE + if (m_objectUtilManager) { + m_currentBoardId = m_objectUtilManager->getBoardModel(); // TODO REMEMBER TO ADD THIS TO FORCE CONNECTED FUNC ON CC3D_RELEASE } invalidateObjects(); - isConnected = true; - foreach(objectToWidget * ow, objOfInterest) { - loadWidgetLimits(ow->widget, ow->field, ow->index, ow->isLimited, ow->scale); + m_isConnected = true; + foreach(WidgetBinding * binding, m_widgetBindings) { + loadWidgetLimits(binding->widget(), binding->field(), binding->index(), binding->isLimited(), binding->scale()); } setDirty(false); enableControls(true); @@ -341,14 +341,12 @@ void ConfigTaskWidget::onAutopilotConnect() */ void ConfigTaskWidget::populateWidgets() { - bool dirtyBack = dirty; + bool dirtyBack = m_isDirty; emit populateWidgetsRequested(); - foreach(objectToWidget * ow, objOfInterest) { - if (ow->object == NULL || ow->field == NULL || ow->widget == NULL) { - // do nothing - } else { - setWidgetFromField(ow->widget, ow->field, ow->index, ow->scale, ow->isLimited); + foreach(WidgetBinding * binding, m_widgetBindings) { + if (binding->object() != NULL && binding->field() != NULL && binding->widget() != NULL) { + setWidgetFromField(binding->widget(), binding->field(), binding->index(), binding->scale(), binding->isLimited()); } } setDirty(dirtyBack); @@ -360,23 +358,20 @@ void ConfigTaskWidget::populateWidgets() */ void ConfigTaskWidget::refreshWidgetsValues(UAVObject *obj) { - if (!allowWidgetUpdates) { + if (!m_isWidgetUpdatesAllowed) { return; } - bool dirtyBack = dirty; + bool dirtyBack = m_isDirty; emit refreshWidgetsValuesRequested(); - foreach(objectToWidget * ow, objOfInterest) { - if (ow->object == NULL || ow->field == NULL || ow->widget == NULL) { - // do nothing - } else { - if (ow->object == obj || obj == NULL) { - setWidgetFromField(ow->widget, ow->field, ow->index, ow->scale, ow->isLimited); - } + foreach(WidgetBinding * binding, m_widgetBindings) { + if (binding->object() == obj && binding->field() != NULL && binding->widget() != NULL) { + setWidgetFromField(binding->widget(), binding->field(), binding->index(), binding->scale(), binding->isLimited()); } } setDirty(dirtyBack); } + /** * SLOT function used to update the uavobject fields from widgets with relation to * object field added to the framework pool @@ -386,24 +381,26 @@ void ConfigTaskWidget::updateObjectsFromWidgets() { emit updateObjectsFromWidgetsRequested(); - foreach(objectToWidget * ow, objOfInterest) { - if (ow->object == NULL || ow->field == NULL) {} else { - setFieldFromWidget(ow->widget, ow->field, ow->index, ow->scale); + foreach(WidgetBinding * binding, m_widgetBindings) { + if (binding->object() != NULL && binding->field() != NULL) { + setFieldFromWidget(binding->widget(), binding->field(), binding->index(), binding->scale()); } } } + /** * SLOT function used handle help button presses * Overwrite this if you need to change the default behavior */ void ConfigTaskWidget::helpButtonPressed() { - QString url = helpButtonList.value((QPushButton *)sender(), QString()); + QString url = m_helpButtons.value((QPushButton *)sender(), QString()); if (!url.isEmpty()) { QDesktopServices::openUrl(QUrl(url, QUrl::StrictMode)); } } + /** * Add update and save buttons to the form * multiple buttons can be added for the same function @@ -412,23 +409,23 @@ void ConfigTaskWidget::helpButtonPressed() */ void ConfigTaskWidget::addApplySaveButtons(QPushButton *update, QPushButton *save) { - if (!smartsave) { - smartsave = new smartSaveButton(this); - connect(smartsave, SIGNAL(preProcessOperations()), this, SLOT(updateObjectsFromWidgets())); - connect(smartsave, SIGNAL(saveSuccessfull()), this, SLOT(clearDirty())); - connect(smartsave, SIGNAL(beginOp()), this, SLOT(disableObjUpdates())); - connect(smartsave, SIGNAL(endOp()), this, SLOT(enableObjUpdates())); + if (!m_saveButton) { + m_saveButton = new SmartSaveButton(this); + connect(m_saveButton, SIGNAL(preProcessOperations()), this, SLOT(updateObjectsFromWidgets())); + connect(m_saveButton, SIGNAL(saveSuccessfull()), this, SLOT(clearDirty())); + connect(m_saveButton, SIGNAL(beginOp()), this, SLOT(disableObjectUpdates())); + connect(m_saveButton, SIGNAL(endOp()), this, SLOT(enableObjectUpdates())); } if (update && save) { - smartsave->addButtons(save, update); + m_saveButton->addButtons(save, update); } else if (update) { - smartsave->addApplyButton(update); + m_saveButton->addApplyButton(update); } else if (save) { - smartsave->addSaveButton(save); + m_saveButton->addSaveButton(save); } - if (objOfInterest.count() > 0) { - foreach(objectToWidget * oTw, objOfInterest) { - smartsave->addObject((UAVDataObject *)oTw->object); + if (m_widgetBindings.count() > 0) { + foreach(WidgetBinding * binding, m_widgetBindings) { + m_saveButton->addObject((UAVDataObject *)binding->object()); } } updateEnableControls(); @@ -441,19 +438,19 @@ void ConfigTaskWidget::addApplySaveButtons(QPushButton *update, QPushButton *sav */ void ConfigTaskWidget::enableControls(bool enable) { - if (smartsave) { - smartsave->enableControls(enable); + if (m_saveButton) { + m_saveButton->enableControls(enable); } - foreach(QPushButton * button, reloadButtonList) { + foreach(QPushButton * button, m_reloadButtons) { button->setEnabled(enable); } - foreach(objectToWidget * ow, objOfInterest) { - if (ow->widget) { - ow->widget->setEnabled(enable); - foreach(shadow * sh, ow->shadowsList) { - sh->widget->setEnabled(enable); + foreach(WidgetBinding * binding, m_widgetBindings) { + if (binding->widget()) { + binding->widget()->setEnabled(enable); + foreach(ShadowWidgetBinding * shadow, binding->shadows()) { + shadow->widget()->setEnabled(enable); } } } @@ -470,62 +467,72 @@ bool ConfigTaskWidget::shouldObjectBeSaved(UAVObject *object) */ void ConfigTaskWidget::forceShadowUpdates() { - foreach(objectToWidget * oTw, objOfInterest) { - foreach(shadow * sh, oTw->shadowsList) { - disconnectWidgetUpdatesToSlot((QWidget *)sh->widget, SLOT(widgetsContentsChanged())); - checkWidgetsLimits(sh->widget, oTw->field, oTw->index, sh->isLimited, getVariantFromWidget(oTw->widget, oTw->scale, oTw->getUnits()), sh->scale); - setWidgetFromVariant(sh->widget, getVariantFromWidget(oTw->widget, oTw->scale, oTw->getUnits()), sh->scale); - emit widgetContentsChanged((QWidget *)sh->widget); - connectWidgetUpdatesToSlot((QWidget *)sh->widget, SLOT(widgetsContentsChanged())); + foreach(WidgetBinding * binding, m_widgetBindings) { + foreach(ShadowWidgetBinding * shadow, binding->shadows()) { + disconnectWidgetUpdatesToSlot(shadow->widget(), SLOT(widgetsContentsChanged())); + checkWidgetsLimits(shadow->widget(), binding->field(), binding->index(), shadow->isLimited(), + getVariantFromWidget(binding->widget(), binding->scale(), binding->units()), shadow->scale()); + setWidgetFromVariant(shadow->widget(), getVariantFromWidget(binding->widget(), binding->scale(), binding->units()), shadow->scale()); + emit widgetContentsChanged(shadow->widget()); + connectWidgetUpdatesToSlot(shadow->widget(), SLOT(widgetsContentsChanged())); } } setDirty(true); } + /** * SLOT function called when one of the widgets contents added to the framework changes */ void ConfigTaskWidget::widgetsContentsChanged() { - emit widgetContentsChanged((QWidget *)sender()); + QWidget *emitter = ((QWidget *)sender()); + emit widgetContentsChanged(emitter); double scale; - objectToWidget *oTw = shadowsList.value((QWidget *)sender(), NULL); + WidgetBinding *binding = m_shadowBindings.value(emitter, NULL); - if (oTw) { - if (oTw->widget == (QWidget *)sender()) { - scale = oTw->scale; - checkWidgetsLimits((QWidget *)sender(), oTw->field, oTw->index, oTw->isLimited, getVariantFromWidget((QWidget *)sender(), - oTw->scale, oTw->getUnits()), oTw->scale); + if (binding) { + if (binding->widget() == emitter) { + scale = binding->scale(); + checkWidgetsLimits(emitter, binding->field(), binding->index(), binding->isLimited(), + getVariantFromWidget(emitter, binding->scale(), binding->units()), binding->scale()); } else { - foreach(shadow * sh, oTw->shadowsList) { - if (sh->widget == (QWidget *)sender()) { - scale = sh->scale; - checkWidgetsLimits((QWidget *)sender(), oTw->field, oTw->index, sh->isLimited, getVariantFromWidget((QWidget *)sender(), - scale, oTw->getUnits()), scale); + foreach(ShadowWidgetBinding * shadow, binding->shadows()) { + if (shadow->widget() == emitter) { + scale = shadow->scale(); + checkWidgetsLimits(emitter, binding->field(), binding->index(), shadow->isLimited(), + getVariantFromWidget(emitter, scale, binding->units()), scale); } } } - if (oTw->widget != (QWidget *)sender()) { - disconnectWidgetUpdatesToSlot((QWidget *)oTw->widget, SLOT(widgetsContentsChanged())); - checkWidgetsLimits(oTw->widget, oTw->field, oTw->index, oTw->isLimited, getVariantFromWidget((QWidget *)sender(), scale, oTw->getUnits()), oTw->scale); - setWidgetFromVariant(oTw->widget, getVariantFromWidget((QWidget *)sender(), scale, oTw->getUnits()), oTw->scale); - emit widgetContentsChanged((QWidget *)oTw->widget); - connectWidgetUpdatesToSlot((QWidget *)oTw->widget, SLOT(widgetsContentsChanged())); + if (binding->widget() != emitter) { + disconnectWidgetUpdatesToSlot(binding->widget(), SLOT(widgetsContentsChanged())); + + checkWidgetsLimits(binding->widget(), binding->field(), binding->index(), binding->isLimited(), + getVariantFromWidget(emitter, scale, binding->units()), binding->scale()); + setWidgetFromVariant(binding->widget(), getVariantFromWidget(emitter, scale, binding->units()), binding->scale()); + emit widgetContentsChanged(binding->widget()); + + connectWidgetUpdatesToSlot(binding->widget(), SLOT(widgetsContentsChanged())); } - foreach(shadow * sh, oTw->shadowsList) { - if (sh->widget != (QWidget *)sender()) { - disconnectWidgetUpdatesToSlot((QWidget *)sh->widget, SLOT(widgetsContentsChanged())); - checkWidgetsLimits(sh->widget, oTw->field, oTw->index, sh->isLimited, getVariantFromWidget((QWidget *)sender(), scale, oTw->getUnits()), sh->scale); - setWidgetFromVariant(sh->widget, getVariantFromWidget((QWidget *)sender(), scale, oTw->getUnits()), sh->scale); - emit widgetContentsChanged((QWidget *)sh->widget); - connectWidgetUpdatesToSlot((QWidget *)sh->widget, SLOT(widgetsContentsChanged())); + foreach(ShadowWidgetBinding * shadow, binding->shadows()) { + if (shadow->widget() != emitter) { + disconnectWidgetUpdatesToSlot(shadow->widget(), SLOT(widgetsContentsChanged())); + + checkWidgetsLimits(shadow->widget(), binding->field(), binding->index(), shadow->isLimited(), + getVariantFromWidget(emitter, scale, binding->units()), shadow->scale()); + setWidgetFromVariant(shadow->widget(), getVariantFromWidget(emitter, scale, binding->units()), shadow->scale()); + emit widgetContentsChanged(shadow->widget()); + + connectWidgetUpdatesToSlot(shadow->widget(), SLOT(widgetsContentsChanged())); } } } - if (smartsave) { - smartsave->resetIcons(); + if (m_saveButton) { + m_saveButton->resetIcons(); } setDirty(true); } + /** * SLOT function used clear the forms dirty status flag */ @@ -539,7 +546,7 @@ void ConfigTaskWidget::clearDirty() */ void ConfigTaskWidget::setDirty(bool value) { - dirty = value; + m_isDirty = value; } /** * Checks if the form is dirty (unsaved changes) @@ -547,8 +554,8 @@ void ConfigTaskWidget::setDirty(bool value) */ bool ConfigTaskWidget::isDirty() { - if (isConnected) { - return dirty; + if (m_isConnected) { + return m_isDirty; } else { return false; } @@ -556,49 +563,52 @@ bool ConfigTaskWidget::isDirty() /** * SLOT function used to disable widget contents changes when related object field changes */ -void ConfigTaskWidget::disableObjUpdates() +void ConfigTaskWidget::disableObjectUpdates() { - allowWidgetUpdates = false; - foreach(objectToWidget * obj, objOfInterest) { - if (obj->object) { - disconnect(obj->object, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(refreshWidgetsValues(UAVObject *))); + m_isWidgetUpdatesAllowed = false; + foreach(WidgetBinding * binding, m_widgetBindings) { + if (binding->object()) { + disconnect(binding->object(), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(refreshWidgetsValues(UAVObject *))); } } } + /** * SLOT function used to enable widget contents changes when related object field changes */ -void ConfigTaskWidget::enableObjUpdates() +void ConfigTaskWidget::enableObjectUpdates() { - allowWidgetUpdates = true; - foreach(objectToWidget * obj, objOfInterest) { - if (obj->object) { - connect(obj->object, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(refreshWidgetsValues(UAVObject *)), Qt::UniqueConnection); + m_isWidgetUpdatesAllowed = true; + foreach(WidgetBinding * binding, m_widgetBindings) { + if (binding->object()) { + connect(binding->object(), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(refreshWidgetsValues(UAVObject *)), Qt::UniqueConnection); } } } + /** * Called when an uav object is updated * @param obj pointer to the object whitch has just been updated */ -void ConfigTaskWidget::objectUpdated(UAVObject *obj) +void ConfigTaskWidget::objectUpdated(UAVObject *object) { - objectUpdates[obj] = true; + m_updatedObjects[object] = true; } + /** * Checks if all objects added to the pool have already been updated * @return true if all objects added to the pool have already been updated */ bool ConfigTaskWidget::allObjectsUpdated() { - qDebug() << "ConfigTaskWidge:allObjectsUpdated called"; - bool ret = true; - foreach(UAVObject * obj, objectUpdates.keys()) { - ret = ret & objectUpdates[obj]; + bool result = true; + + foreach(UAVObject * object, m_updatedObjects.keys()) { + result = result & m_updatedObjects[object]; } - qDebug() << "Returned:" << ret; - return ret; + return result; } + /** * Adds a new help button * @param button pointer to the help button @@ -606,7 +616,7 @@ bool ConfigTaskWidget::allObjectsUpdated() */ void ConfigTaskWidget::addHelpButton(QPushButton *button, QString url) { - helpButtonList.insert(button, url); + m_helpButtons.insert(button, url); connect(button, SIGNAL(clicked()), this, SLOT(helpButtonPressed())); } /** @@ -614,8 +624,8 @@ void ConfigTaskWidget::addHelpButton(QPushButton *button, QString url) */ void ConfigTaskWidget::invalidateObjects() { - foreach(UAVObject * obj, objectUpdates.keys()) { - objectUpdates[obj] = false; + foreach(UAVObject * obj, m_updatedObjects.keys()) { + m_updatedObjects[obj] = false; } } /** @@ -623,8 +633,8 @@ void ConfigTaskWidget::invalidateObjects() */ void ConfigTaskWidget::apply() { - if (smartsave) { - smartsave->apply(); + if (m_saveButton) { + m_saveButton->apply(); } } /** @@ -632,8 +642,8 @@ void ConfigTaskWidget::apply() */ void ConfigTaskWidget::save() { - if (smartsave) { - smartsave->save(); + if (m_saveButton) { + m_saveButton->save(); } } /** @@ -642,52 +652,32 @@ void ConfigTaskWidget::save() * This function doesn't have to be used directly, addUAVObjectToWidgetRelation will call it if a previous relation exhists. * @return returns false if the shadow widget relation failed to be added (no previous relation exhisted) */ -bool ConfigTaskWidget::addShadowWidget(QString object, QString field, QWidget *widget, int index, double scale, bool isLimited, +bool ConfigTaskWidget::addShadowWidgetBinding(QString object, QString field, QWidget *widget, int index, double scale, bool isLimited, QList *defaultReloadGroups, quint32 instID) { - foreach(objectToWidget * oTw, objOfInterest) { - if (!oTw->object || !oTw->widget || !oTw->field) { + foreach(WidgetBinding * binding, m_widgetBindings) { + if (!binding->object() || !binding->widget() || !binding->field()) { continue; } - if (oTw->object->getName() == object && oTw->field->getName() == field && oTw->index == index && oTw->object->getInstID() == instID) { - shadow *sh = NULL; - // prefer anything else to QLabel - if (qobject_cast(oTw->widget) && !qobject_cast(widget)) { - sh = new shadow; - sh->isLimited = oTw->isLimited; - sh->scale = oTw->scale; - sh->widget = oTw->widget; - oTw->isLimited = isLimited; - oTw->scale = scale; - oTw->widget = widget; - } - // prefer QDoubleSpinBox to anything else - else if (!qobject_cast(oTw->widget) && qobject_cast(widget)) { - sh = new shadow; - sh->isLimited = oTw->isLimited; - sh->scale = oTw->scale; - sh->widget = oTw->widget; - oTw->isLimited = isLimited; - oTw->scale = scale; - oTw->widget = widget; - } else { - sh = new shadow; - sh->isLimited = isLimited; - sh->scale = scale; - sh->widget = widget; - } - shadowsList.insert(widget, oTw); - oTw->shadowsList.append(sh); + if (binding->object()->getName() == object && + binding->field()->getName() == field && + binding->index() == index && + binding->object()->getInstID() == instID) { + + binding->addShadow(widget, scale, isLimited); + + m_shadowBindings.insert(widget, binding); connectWidgetUpdatesToSlot(widget, SLOT(widgetsContentsChanged())); if (defaultReloadGroups) { addWidgetToDefaultReloadGroups(widget, defaultReloadGroups); } - loadWidgetLimits(widget, oTw->field, oTw->index, isLimited, scale); + loadWidgetLimits(widget, binding->field(), binding->index(), isLimited, scale); return true; } } return false; } + /** * Auto loads widgets based on the Dynamic property named "objrelation" * Check the wiki for more information @@ -788,24 +778,25 @@ void ConfigTaskWidget::autoLoadWidgets() } else { QWidget *wid = qobject_cast(widget); if (wid) { - addUAVObjectToWidgetRelation(uiRelation.objname, uiRelation.fieldname, wid, uiRelation.element, uiRelation.scale, uiRelation.haslimits, &uiRelation.buttonGroup); + addWidgetBinding(uiRelation.objname, uiRelation.fieldname, wid, uiRelation.element, uiRelation.scale, uiRelation.haslimits, &uiRelation.buttonGroup); } } } } refreshWidgetsValues(); forceShadowUpdates(); - foreach(objectToWidget * ow, objOfInterest) { - if (ow->widget) { - qDebug() << "Master:" << ow->widget->objectName(); + foreach(WidgetBinding *binding, m_widgetBindings) { + if (binding->widget()) { + qDebug() << "Binding:" << binding->widget()->objectName(); } - foreach(shadow * sh, ow->shadowsList) { - if (sh->widget) { - qDebug() << "Child" << sh->widget->objectName(); + foreach(ShadowWidgetBinding *shadow, binding->shadows()) { + if (shadow->widget()) { + qDebug() << " Shadow" << shadow->widget()->objectName(); } } } } + /** * Adds a widget to a list of default/reload groups * default/reload groups are groups of widgets to be set with default or reloaded (values from persistent memory) when a defined button is pressed @@ -814,30 +805,31 @@ void ConfigTaskWidget::autoLoadWidgets() */ void ConfigTaskWidget::addWidgetToDefaultReloadGroups(QWidget *widget, QList *groups) { - foreach(objectToWidget * oTw, objOfInterest) { - bool addOTW = false; + foreach(WidgetBinding *binding, m_widgetBindings) { + bool addBinding = false; - if (oTw->widget == widget) { - addOTW = true; + if (binding->widget() == widget) { + addBinding = true; } else { - foreach(shadow * sh, oTw->shadowsList) { - if (sh->widget == widget) { - addOTW = true; + foreach(ShadowWidgetBinding *shadow, binding->shadows()) { + if (shadow->widget() == widget) { + addBinding = true; } } } - if (addOTW) { + if (addBinding) { foreach(int i, *groups) { - if (defaultReloadGroups.contains(i)) { - defaultReloadGroups.value(i)->append(oTw); + if (m_reloadGroups.contains(i)) { + m_reloadGroups.value(i)->append(binding); } else { - defaultReloadGroups.insert(i, new QList()); - defaultReloadGroups.value(i)->append(oTw); + m_reloadGroups.insert(i, new QList()); + m_reloadGroups.value(i)->append(binding); } } } } } + /** * Adds a button to a default group * @param button pointer to the default button @@ -848,6 +840,7 @@ void ConfigTaskWidget::addDefaultButton(QPushButton *button, int buttonGroup) button->setProperty("group", buttonGroup); connect(button, SIGNAL(clicked()), this, SLOT(defaultButtonClicked())); } + /** * Adds a button to a reload group * @param button pointer to the reload button @@ -856,9 +849,10 @@ void ConfigTaskWidget::addDefaultButton(QPushButton *button, int buttonGroup) void ConfigTaskWidget::addReloadButton(QPushButton *button, int buttonGroup) { button->setProperty("group", buttonGroup); - reloadButtonList.append(button); + m_reloadButtons.append(button); connect(button, SIGNAL(clicked()), this, SLOT(reloadButtonClicked())); } + /** * Called when a default button is clicked */ @@ -867,40 +861,41 @@ void ConfigTaskWidget::defaultButtonClicked() int group = sender()->property("group").toInt(); emit defaultRequested(group); - QList *list = defaultReloadGroups.value(group); - foreach(objectToWidget * oTw, *list) { - if (!oTw->object || !oTw->field) { + QList *bindings = m_reloadGroups.value(group); + foreach(WidgetBinding * binding, *bindings) { + if (!binding->object() || !binding->field()) { continue; } - UAVDataObject *temp = ((UAVDataObject *)oTw->object)->dirtyClone(); - setWidgetFromField(oTw->widget, temp->getField(oTw->field->getName()), oTw->index, oTw->scale, oTw->isLimited); + UAVDataObject *temp = ((UAVDataObject *)binding->object())->dirtyClone(); + setWidgetFromField(binding->widget(), temp->getField(binding->field()->getName()), binding->index(), binding->scale(), binding->isLimited()); } } + /** * Called when a reload button is clicked */ void ConfigTaskWidget::reloadButtonClicked() { - if (timeOut) { + if (m_realtimeUpdateTimer) { return; } int group = sender()->property("group").toInt(); - QList *list = defaultReloadGroups.value(group, NULL); - if (!list) { + QList *bindings = m_reloadGroups.value(group, NULL); + if (!bindings) { return; } ObjectPersistence *objper = dynamic_cast(getObjectManager()->getObject(ObjectPersistence::NAME)); - timeOut = new QTimer(this); + m_realtimeUpdateTimer = new QTimer(this); QEventLoop *eventLoop = new QEventLoop(this); - connect(timeOut, SIGNAL(timeout()), eventLoop, SLOT(quit())); + connect(m_realtimeUpdateTimer, SIGNAL(timeout()), eventLoop, SLOT(quit())); connect(objper, SIGNAL(objectUpdated(UAVObject *)), eventLoop, SLOT(quit())); QList temp; - foreach(objectToWidget * oTw, *list) { - if (oTw->object != NULL) { + foreach(WidgetBinding *binding, *bindings) { + if (binding->object() != NULL) { temphelper value; - value.objid = oTw->object->getObjID(); - value.objinstid = oTw->object->getInstID(); + value.objid = binding->object()->getObjID(); + value.objinstid = binding->object()->getInstID(); if (temp.contains(value)) { continue; } else { @@ -909,28 +904,28 @@ void ConfigTaskWidget::reloadButtonClicked() ObjectPersistence::DataFields data; data.Operation = ObjectPersistence::OPERATION_LOAD; data.Selection = ObjectPersistence::SELECTION_SINGLEOBJECT; - data.ObjectID = oTw->object->getObjID(); - data.InstanceID = oTw->object->getInstID(); + data.ObjectID = binding->object()->getObjID(); + data.InstanceID = binding->object()->getInstID(); objper->setData(data); objper->updated(); - timeOut->start(500); + m_realtimeUpdateTimer->start(500); eventLoop->exec(); - if (timeOut->isActive()) { - oTw->object->requestUpdate(); - if (oTw->widget) { - setWidgetFromField(oTw->widget, oTw->field, oTw->index, oTw->scale, oTw->isLimited); + if (m_realtimeUpdateTimer->isActive()) { + binding->object()->requestUpdate(); + if (binding->widget()) { + setWidgetFromField(binding->widget(), binding->field(), binding->index(), binding->scale(), binding->isLimited()); } } - timeOut->stop(); + m_realtimeUpdateTimer->stop(); } } if (eventLoop) { delete eventLoop; eventLoop = NULL; } - if (timeOut) { - delete timeOut; - timeOut = NULL; + if (m_realtimeUpdateTimer) { + delete m_realtimeUpdateTimer; + m_realtimeUpdateTimer = NULL; } } @@ -962,6 +957,7 @@ void ConfigTaskWidget::connectWidgetUpdatesToSlot(QWidget *widget, const char *f qDebug() << __FUNCTION__ << "widget to uavobject relation not implemented" << widget->metaObject()->className(); } } + /** * Disconnects widgets "contents changed" signals to a slot */ @@ -990,6 +986,7 @@ void ConfigTaskWidget::disconnectWidgetUpdatesToSlot(QWidget *widget, const char qDebug() << __FUNCTION__ << "widget to uavobject relation not implemented" << widget->metaObject()->className(); } } + /** * Sets a widget value from an UAVObject field * @param widget pointer for the widget to set @@ -1013,6 +1010,7 @@ bool ConfigTaskWidget::setFieldFromWidget(QWidget *widget, UAVObjectField *field return false; } } + /** * Gets a variant from a widget * @param widget pointer to the widget from where to get the value @@ -1043,6 +1041,7 @@ QVariant ConfigTaskWidget::getVariantFromWidget(QWidget *widget, double scale, Q return QVariant(); } } + /** * Sets a widget from a variant * @param widget pointer for the widget to set @@ -1133,16 +1132,17 @@ bool ConfigTaskWidget::setWidgetFromField(QWidget *widget, UAVObjectField *field return false; } } + void ConfigTaskWidget::checkWidgetsLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, QVariant value, double scale) { if (!hasLimits) { return; } - if (!field->isWithinLimits(value, index, currentBoard)) { + if (!field->isWithinLimits(value, index, m_currentBoardId)) { if (!widget->property("styleBackup").isValid()) { widget->setProperty("styleBackup", widget->styleSheet()); } - widget->setStyleSheet(outOfLimitsStyle); + widget->setStyleSheet(m_outOfLimitsStyle); widget->setProperty("wasOverLimits", (bool)true); if (QComboBox * cb = qobject_cast(widget)) { if (cb->findText(value.toString()) == -1) { @@ -1189,7 +1189,7 @@ void ConfigTaskWidget::loadWidgetLimits(QWidget *widget, UAVObjectField *field, QStringList option = field->getOptions(); if (hasLimits) { foreach(QString str, option) { - if (field->isWithinLimits(str, index, currentBoard)) { + if (field->isWithinLimits(str, index, m_currentBoardId)) { cb->addItem(str); } } @@ -1201,31 +1201,36 @@ void ConfigTaskWidget::loadWidgetLimits(QWidget *widget, UAVObjectField *field, return; } else if (QDoubleSpinBox * cb = qobject_cast(widget)) { if (field->getMaxLimit(index).isValid()) { - cb->setMaximum((double)(field->getMaxLimit(index, currentBoard).toDouble() / scale)); + cb->setMaximum((double)(field->getMaxLimit(index, m_currentBoardId).toDouble() / scale)); } - if (field->getMinLimit(index, currentBoard).isValid()) { - cb->setMinimum((double)(field->getMinLimit(index, currentBoard).toDouble() / scale)); + if (field->getMinLimit(index, m_currentBoardId).isValid()) { + cb->setMinimum((double)(field->getMinLimit(index, m_currentBoardId).toDouble() / scale)); } } else if (QSpinBox * cb = qobject_cast(widget)) { - if (field->getMaxLimit(index, currentBoard).isValid()) { - cb->setMaximum((int)qRound(field->getMaxLimit(index, currentBoard).toDouble() / scale)); + if (field->getMaxLimit(index, m_currentBoardId).isValid()) { + cb->setMaximum((int)qRound(field->getMaxLimit(index, m_currentBoardId).toDouble() / scale)); } - if (field->getMinLimit(index, currentBoard).isValid()) { - cb->setMinimum((int)qRound(field->getMinLimit(index, currentBoard).toDouble() / scale)); + if (field->getMinLimit(index, m_currentBoardId).isValid()) { + cb->setMinimum((int)qRound(field->getMinLimit(index, m_currentBoardId).toDouble() / scale)); } } else if (QSlider * cb = qobject_cast(widget)) { - if (field->getMaxLimit(index, currentBoard).isValid()) { - cb->setMaximum((int)qRound(field->getMaxLimit(index, currentBoard).toDouble() / scale)); + if (field->getMaxLimit(index, m_currentBoardId).isValid()) { + cb->setMaximum((int)qRound(field->getMaxLimit(index, m_currentBoardId).toDouble() / scale)); } - if (field->getMinLimit(index, currentBoard).isValid()) { - cb->setMinimum((int)(field->getMinLimit(index, currentBoard).toDouble() / scale)); + if (field->getMinLimit(index, m_currentBoardId).isValid()) { + cb->setMinimum((int)(field->getMinLimit(index, m_currentBoardId).toDouble() / scale)); } } } +UAVObject *ConfigTaskWidget::getObject(const QString name, quint32 instId) +{ + return m_pluginManager->getObject()->getObject(name, instId); +} + void ConfigTaskWidget::updateEnableControls() { - TelemetryManager *telMngr = pm->getObject(); + TelemetryManager *telMngr = m_pluginManager->getObject(); Q_ASSERT(telMngr); enableControls(telMngr->isConnected()); @@ -1264,3 +1269,88 @@ bool ConfigTaskWidget::eventFilter(QObject *obj, QEvent *evt) @} @} */ + +WidgetBinding::WidgetBinding(QWidget *widget, UAVObject *object, UAVObjectField *field, int index, double scale, bool isLimited) : + ShadowWidgetBinding(widget, scale, isLimited) +{ + m_object = object; + m_field = field; + m_index = index; +} + +WidgetBinding::~WidgetBinding() +{ + +} + +QString WidgetBinding::units() const +{ + if(m_field) { + return m_field->getUnits(); + } + return QString(""); +} + +UAVObject *WidgetBinding::object() const +{ + return m_object; +} + +UAVObjectField *WidgetBinding::field() const +{ + return m_field; +} + +int WidgetBinding::index() const +{ + return m_index; +} + +QList WidgetBinding::shadows() const +{ + return m_shadows; +} + +void WidgetBinding::addShadow(QWidget *widget, int scale, bool isLimited) +{ + ShadowWidgetBinding *shadow = NULL; + + // Prefer anything else to QLabel and prefer QDoubleSpinBox to anything else + if ((qobject_cast(m_widget) && !qobject_cast(widget)) || + (!qobject_cast(m_widget) && qobject_cast(widget))) { + shadow = new ShadowWidgetBinding(m_widget, m_scale, m_isLimited); + m_isLimited = isLimited; + m_scale = scale; + m_widget = widget; + } else { + shadow = new ShadowWidgetBinding(widget, scale, isLimited); + } + m_shadows.append(shadow); +} + +ShadowWidgetBinding::ShadowWidgetBinding(QWidget *widget, double scale, bool isLimited) +{ + m_widget = widget; + m_scale = scale; + m_isLimited = isLimited; +} + +ShadowWidgetBinding::~ShadowWidgetBinding() +{ + +} + +QWidget *ShadowWidgetBinding::widget() const +{ + return m_widget; +} + +double ShadowWidgetBinding::scale() const +{ + return m_scale; +} + +bool ShadowWidgetBinding::isLimited() const +{ + return m_isLimited; +} diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index 3382c7f39..b259f52fe 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -27,7 +27,6 @@ #ifndef CONFIGTASKWIDGET_H #define CONFIGTASKWIDGET_H - #include "extensionsystem/pluginmanager.h" #include "uavobjectmanager.h" #include "uavobject.h" @@ -48,32 +47,46 @@ #include #include +class ShadowWidgetBinding : public QObject { + Q_OBJECT +public: + ShadowWidgetBinding(QWidget* widget, double scale, bool isLimited); + ~ShadowWidgetBinding(); + QWidget *widget() const; + double scale() const; + bool isLimited() const; + +protected: + QWidget *m_widget; + double m_scale; + bool m_isLimited; +}; + +class WidgetBinding : public ShadowWidgetBinding { + Q_OBJECT +public: + WidgetBinding(QWidget* widget, UAVObject* object, UAVObjectField* field, int index, double scale, bool isLimited); + ~WidgetBinding(); + + QString units() const; + UAVObject *object() const; + UAVObjectField *field() const; + int index() const; + QList shadows() const; + + void addShadow(QWidget* widget, int scale, bool isLimited); + +private: + UAVObject *m_object; + UAVObjectField *m_field; + int m_index; + QList m_shadows; +}; + class UAVOBJECTWIDGETUTILS_EXPORT ConfigTaskWidget : public QWidget { Q_OBJECT public: - struct shadow { - QWidget *widget; - double scale; - bool isLimited; - }; - struct objectToWidget { - UAVObject *object; - UAVObjectField *field; - QWidget *widget; - int index; - double scale; - bool isLimited; - QList shadowsList; - QString getUnits() const - { - if (field) { - return field->getUnits(); - } - return QString(""); - } - }; - struct temphelper { quint32 objid; quint32 objinstid; @@ -111,25 +124,24 @@ public: void addWidget(QWidget *widget); - void addUAVObjectToWidgetRelation(QString object, QString field, QWidget *widget, int index = 0, double scale = 1, bool isLimited = false, QList *defaultReloadGroups = 0, quint32 instID = 0); - void addUAVObjectToWidgetRelation(UAVObject *obj, UAVObjectField *field, QWidget *widget, int index = 0, double scale = 1, bool isLimited = false, QList *defaultReloadGroups = 0, quint32 instID = 0); + void addWidgetBinding(QString object, QString field, QWidget *widget, int index = 0, double scale = 1, bool isLimited = false, QList *m_reloadGroups = 0, quint32 instID = 0); + void addWidgetBinding(UAVObject *obj, UAVObjectField *field, QWidget *widget, int index = 0, double scale = 1, bool isLimited = false, QList *m_reloadGroups = 0, quint32 instID = 0); - void addUAVObjectToWidgetRelation(QString object, QString field, QWidget *widget, QString element, double scale, bool isLimited = false, QList *defaultReloadGroups = 0, quint32 instID = 0); - void addUAVObjectToWidgetRelation(UAVObject *obj, UAVObjectField *field, QWidget *widget, QString element, double scale, bool isLimited = false, QList *defaultReloadGroups = 0, quint32 instID = 0); + void addWidgetBinding(QString object, QString field, QWidget *widget, QString element, double scale, bool isLimited = false, QList *m_reloadGroups = 0, quint32 instID = 0); + void addWidgetBinding(UAVObject *obj, UAVObjectField *field, QWidget *widget, QString element, double scale, bool isLimited = false, QList *m_reloadGroups = 0, quint32 instID = 0); - void addUAVObjectToWidgetRelation(QString object, QString field, QWidget *widget, QString index); - void addUAVObjectToWidgetRelation(UAVObject *obj, UAVObjectField *field, QWidget *widget, QString index); + void addWidgetBinding(QString object, QString field, QWidget *widget, QString index); + void addWidgetBinding(UAVObject *obj, UAVObjectField *field, QWidget *widget, QString index); - // BUTTONS// void addApplySaveButtons(QPushButton *update, QPushButton *save); void addReloadButton(QPushButton *button, int buttonGroup); void addDefaultButton(QPushButton *button, int buttonGroup); - ////////// void addWidgetToDefaultReloadGroups(QWidget *widget, QList *groups); - bool addShadowWidget(QWidget *masterWidget, QWidget *shadowWidget, double shadowScale = 1, bool shadowIsLimited = false); - bool addShadowWidget(QString object, QString field, QWidget *widget, int index = 0, double scale = 1, bool isLimited = false, QList *defaultReloadGroups = NULL, quint32 instID = 0); + bool addShadowWidgetBinding(QWidget *masterWidget, QWidget *shadowWidget, double shadowScale = 1, bool shadowIsLimited = false); + bool addShadowWidgetBinding(QString object, QString field, QWidget *widget, int index = 0, double scale = 1, bool isLimited = false, + QList *m_reloadGroups = NULL, quint32 instID = 0); void autoLoadWidgets(); @@ -139,18 +151,20 @@ public: bool allObjectsUpdated(); void setOutOfLimitsStyle(QString style) { - outOfLimitsStyle = style; + m_outOfLimitsStyle = style; } void addHelpButton(QPushButton *button, QString url); void forceShadowUpdates(); void forceConnectedState(); virtual bool shouldObjectBeSaved(UAVObject *object); + public slots: void onAutopilotDisconnect(); void onAutopilotConnect(); void invalidateObjects(); void apply(); void save(); + signals: // fired when a widgets contents changes void widgetContentsChanged(QWidget *widget); @@ -165,40 +179,46 @@ signals: // fired when the autopilot disconnects void autoPilotDisconnected(); void defaultRequested(int group); + private slots: - void objectUpdated(UAVObject *); + void objectUpdated(UAVObject *object); void defaultButtonClicked(); void reloadButtonClicked(); + private: - int currentBoard; - bool isConnected; - bool allowWidgetUpdates; - QStringList objectsList; - QList objOfInterest; - ExtensionSystem::PluginManager *pm; - UAVObjectManager *objManager; - UAVObjectUtilManager *utilMngr; - smartSaveButton *smartsave; - QMap objectUpdates; - QMap *> defaultReloadGroups; - QMap shadowsList; - QMap helpButtonList; - QList reloadButtonList; - bool dirty; + int m_currentBoardId; + bool m_isConnected; + bool m_isWidgetUpdatesAllowed; + QStringList m_objects; + QList m_widgetBindings; + ExtensionSystem::PluginManager *m_pluginManager; + UAVObjectUtilManager *m_objectUtilManager; + SmartSaveButton *m_saveButton; + QMap m_updatedObjects; + QMap *> m_reloadGroups; + QMap m_shadowBindings; + QMap m_helpButtons; + QList m_reloadButtons; + bool m_isDirty; + QString m_outOfLimitsStyle; + QTimer *m_realtimeUpdateTimer; + bool setFieldFromWidget(QWidget *widget, UAVObjectField *field, int index, double scale); bool setWidgetFromField(QWidget *widget, UAVObjectField *field, int index, double scale, bool hasLimits); - QVariant getVariantFromWidget(QWidget *widget, double scale, QString units); + + QVariant getVariantFromWidget(QWidget *widget, double scale, const QString units); bool setWidgetFromVariant(QWidget *widget, QVariant value, double scale, QString units); bool setWidgetFromVariant(QWidget *widget, QVariant value, double scale); + void connectWidgetUpdatesToSlot(QWidget *widget, const char *function); void disconnectWidgetUpdatesToSlot(QWidget *widget, const char *function); + void loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, double sclale); - QString outOfLimitsStyle; - QTimer *timeOut; + virtual UAVObject* getObject(const QString name, quint32 instId = 0); protected slots: - virtual void disableObjUpdates(); - virtual void enableObjUpdates(); + virtual void disableObjectUpdates(); + virtual void enableObjectUpdates(); virtual void clearDirty(); virtual void widgetsContentsChanged(); virtual void populateWidgets(); diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.cpp index 0165c32bb..eb421b9ef 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.cpp @@ -27,27 +27,27 @@ #include "smartsavebutton.h" #include "configtaskwidget.h" -smartSaveButton::smartSaveButton(ConfigTaskWidget *configTaskWidget) : configWidget(configTaskWidget) +SmartSaveButton::SmartSaveButton(ConfigTaskWidget *configTaskWidget) : configWidget(configTaskWidget) {} -void smartSaveButton::addButtons(QPushButton *save, QPushButton *apply) +void SmartSaveButton::addButtons(QPushButton *save, QPushButton *apply) { buttonList.insert(save, save_button); buttonList.insert(apply, apply_button); connect(save, SIGNAL(clicked()), this, SLOT(processClick())); connect(apply, SIGNAL(clicked()), this, SLOT(processClick())); } -void smartSaveButton::addApplyButton(QPushButton *apply) +void SmartSaveButton::addApplyButton(QPushButton *apply) { buttonList.insert(apply, apply_button); connect(apply, SIGNAL(clicked()), this, SLOT(processClick())); } -void smartSaveButton::addSaveButton(QPushButton *save) +void SmartSaveButton::addSaveButton(QPushButton *save) { buttonList.insert(save, save_button); connect(save, SIGNAL(clicked()), this, SLOT(processClick())); } -void smartSaveButton::processClick() +void SmartSaveButton::processClick() { emit beginOp(); bool save = false; @@ -62,7 +62,7 @@ void smartSaveButton::processClick() processOperation(button, save); } -void smartSaveButton::processOperation(QPushButton *button, bool save) +void SmartSaveButton::processOperation(QPushButton *button, bool save) { emit preProcessOperations(); @@ -157,33 +157,33 @@ void smartSaveButton::processOperation(QPushButton *button, bool save) emit endOp(); } -void smartSaveButton::setObjects(QList list) +void SmartSaveButton::setObjects(QList list) { objects = list; } -void smartSaveButton::addObject(UAVDataObject *obj) +void SmartSaveButton::addObject(UAVDataObject *obj) { Q_ASSERT(obj); if (!objects.contains(obj)) { objects.append(obj); } } -void smartSaveButton::removeObject(UAVDataObject *obj) +void SmartSaveButton::removeObject(UAVDataObject *obj) { if (objects.contains(obj)) { objects.removeAll(obj); } } -void smartSaveButton::removeAllObjects() +void SmartSaveButton::removeAllObjects() { objects.clear(); } -void smartSaveButton::clearObjects() +void SmartSaveButton::clearObjects() { objects.clear(); } -void smartSaveButton::transaction_finished(UAVObject *obj, bool result) +void SmartSaveButton::transaction_finished(UAVObject *obj, bool result) { if (current_object == obj) { up_result = result; @@ -191,32 +191,32 @@ void smartSaveButton::transaction_finished(UAVObject *obj, bool result) } } -void smartSaveButton::saving_finished(int id, bool result) +void SmartSaveButton::saving_finished(int id, bool result) { - if (id == current_objectID) { + if (id == (int)current_objectID) { sv_result = result; loop.quit(); } } -void smartSaveButton::enableControls(bool value) +void SmartSaveButton::enableControls(bool value) { foreach(QPushButton * button, buttonList.keys()) button->setEnabled(value); } -void smartSaveButton::resetIcons() +void SmartSaveButton::resetIcons() { foreach(QPushButton * button, buttonList.keys()) button->setIcon(QIcon()); } -void smartSaveButton::apply() +void SmartSaveButton::apply() { processOperation(NULL, false); } -void smartSaveButton::save() +void SmartSaveButton::save() { processOperation(NULL, true); } diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.h index 42d9b06e8..9af855dcd 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.h @@ -40,13 +40,13 @@ class ConfigTaskWidget; -class smartSaveButton : public QObject { +class SmartSaveButton : public QObject { enum buttonTypeEnum { save_button, apply_button }; public: Q_OBJECT public: - smartSaveButton(ConfigTaskWidget *configTaskWidget); + SmartSaveButton(ConfigTaskWidget *configTaskWidget); void addButtons(QPushButton *save, QPushButton *apply); void setObjects(QList); void addObject(UAVDataObject *); From 1ea13ba1615148f058ca6a2622896f548afc4c47 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Wed, 1 Jan 2014 23:03:20 +0100 Subject: [PATCH 24/45] OP-984 More refactorng. --- .../plugins/uavobjectwidgetutils/configtaskwidget.cpp | 10 ++-------- .../plugins/uavobjectwidgetutils/configtaskwidget.h | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index 32d8f0038..251628bc6 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -954,7 +954,7 @@ void ConfigTaskWidget::connectWidgetUpdatesToSlot(QWidget *widget, const char *f } else if (QPushButton * cb = qobject_cast(widget)) { connect(cb, SIGNAL(clicked()), this, function); } else { - qDebug() << __FUNCTION__ << "widget to uavobject relation not implemented" << widget->metaObject()->className(); + qDebug() << __FUNCTION__ << "widget binding not implemented" << widget->metaObject()->className(); } } @@ -983,7 +983,7 @@ void ConfigTaskWidget::disconnectWidgetUpdatesToSlot(QWidget *widget, const char } else if (QPushButton * cb = qobject_cast(widget)) { disconnect(cb, SIGNAL(clicked()), this, function); } else { - qDebug() << __FUNCTION__ << "widget to uavobject relation not implemented" << widget->metaObject()->className(); + qDebug() << __FUNCTION__ << "widget binding not implemented" << widget->metaObject()->className(); } } @@ -1265,10 +1265,6 @@ bool ConfigTaskWidget::eventFilter(QObject *obj, QEvent *evt) } return QWidget::eventFilter(obj, evt); } -/** - @} - @} - */ WidgetBinding::WidgetBinding(QWidget *widget, UAVObject *object, UAVObjectField *field, int index, double scale, bool isLimited) : ShadowWidgetBinding(widget, scale, isLimited) @@ -1280,7 +1276,6 @@ WidgetBinding::WidgetBinding(QWidget *widget, UAVObject *object, UAVObjectField WidgetBinding::~WidgetBinding() { - } QString WidgetBinding::units() const @@ -1337,7 +1332,6 @@ ShadowWidgetBinding::ShadowWidgetBinding(QWidget *widget, double scale, bool isL ShadowWidgetBinding::~ShadowWidgetBinding() { - } QWidget *ShadowWidgetBinding::widget() const diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index b259f52fe..ee56b6f21 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -137,7 +137,7 @@ public: void addReloadButton(QPushButton *button, int buttonGroup); void addDefaultButton(QPushButton *button, int buttonGroup); - void addWidgetToDefaultReloadGroups(QWidget *widget, QList *groups); + void addWidgetToReloadGroups(QWidget *widget, QList *groups); bool addShadowWidgetBinding(QWidget *masterWidget, QWidget *shadowWidget, double shadowScale = 1, bool shadowIsLimited = false); bool addShadowWidgetBinding(QString object, QString field, QWidget *widget, int index = 0, double scale = 1, bool isLimited = false, From ab27f417347cec289817de707a0a6b5d01a8c9c0 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Wed, 1 Jan 2014 23:17:31 +0100 Subject: [PATCH 25/45] OP-984 Refactoring. --- .../uavobjectwidgetutils/configtaskwidget.cpp | 12 +++--- .../uavobjectwidgetutils/configtaskwidget.h | 42 +++++++++---------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index 251628bc6..067b19bf9 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -213,7 +213,7 @@ void ConfigTaskWidget::addWidgetBinding(QString object, QString field, QWidget * } else { connectWidgetUpdatesToSlot(widget, SLOT(widgetsContentsChanged())); if (defaultReloadGroups) { - addWidgetToDefaultReloadGroups(widget, defaultReloadGroups); + addWidgetToReloadGroups(widget, defaultReloadGroups); } m_shadowBindings.insert(widget, binding); loadWidgetLimits(widget, _field, index, isLimited, scale); @@ -669,7 +669,7 @@ bool ConfigTaskWidget::addShadowWidgetBinding(QString object, QString field, QWi m_shadowBindings.insert(widget, binding); connectWidgetUpdatesToSlot(widget, SLOT(widgetsContentsChanged())); if (defaultReloadGroups) { - addWidgetToDefaultReloadGroups(widget, defaultReloadGroups); + addWidgetToReloadGroups(widget, defaultReloadGroups); } loadWidgetLimits(widget, binding->field(), binding->index(), isLimited, scale); return true; @@ -691,7 +691,7 @@ void ConfigTaskWidget::autoLoadWidgets() QVariant info = widget->property("objrelation"); if (info.isValid()) { - uiRelationAutomation uiRelation; + bindingStruct uiRelation; uiRelation.buttonType = none; uiRelation.scale = 1; uiRelation.element = QString(); @@ -803,7 +803,7 @@ void ConfigTaskWidget::autoLoadWidgets() * @param widget pointer to the widget to be added to the groups * @param groups list of the groups on which to add the widget */ -void ConfigTaskWidget::addWidgetToDefaultReloadGroups(QWidget *widget, QList *groups) +void ConfigTaskWidget::addWidgetToReloadGroups(QWidget *widget, QList *groups) { foreach(WidgetBinding *binding, m_widgetBindings) { bool addBinding = false; @@ -890,10 +890,10 @@ void ConfigTaskWidget::reloadButtonClicked() connect(m_realtimeUpdateTimer, SIGNAL(timeout()), eventLoop, SLOT(quit())); connect(objper, SIGNAL(objectUpdated(UAVObject *)), eventLoop, SLOT(quit())); - QList temp; + QList temp; foreach(WidgetBinding *binding, *bindings) { if (binding->object() != NULL) { - temphelper value; + objectComparator value; value.objid = binding->object()->getObjID(); value.objinstid = binding->object()->getInstID(); if (temp.contains(value)) { diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index ee56b6f21..3578c2c53 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -87,27 +87,6 @@ class UAVOBJECTWIDGETUTILS_EXPORT ConfigTaskWidget : public QWidget { Q_OBJECT public: - struct temphelper { - quint32 objid; - quint32 objinstid; - bool operator==(const temphelper & lhs) - { - return lhs.objid == this->objid && lhs.objinstid == this->objinstid; - } - }; - - enum buttonTypeEnum { none, save_button, apply_button, reload_button, default_button, help_button }; - struct uiRelationAutomation { - QString objname; - QString fieldname; - QString element; - QString url; - buttonTypeEnum buttonType; - QList buttonGroup; - double scale; - bool haslimits; - }; - ConfigTaskWidget(QWidget *parent = 0); virtual ~ConfigTaskWidget(); @@ -186,6 +165,27 @@ private slots: void reloadButtonClicked(); private: + struct objectComparator { + quint32 objid; + quint32 objinstid; + bool operator==(const objectComparator & lhs) + { + return lhs.objid == this->objid && lhs.objinstid == this->objinstid; + } + }; + + enum buttonTypeEnum { none, save_button, apply_button, reload_button, default_button, help_button }; + struct bindingStruct { + QString objname; + QString fieldname; + QString element; + QString url; + buttonTypeEnum buttonType; + QList buttonGroup; + double scale; + bool haslimits; + }; + int m_currentBoardId; bool m_isConnected; bool m_isWidgetUpdatesAllowed; From b97c410e379ae6001cd766c99e85951cda6fd754 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Thu, 2 Jan 2014 20:47:23 +0100 Subject: [PATCH 26/45] OP-984 Small fixes after re-factoring. --- .../src/plugins/config/stabilization.ui | 29 -- .../uavobjectwidgetutils/configtaskwidget.cpp | 421 +++++------------- .../uavobjectwidgetutils/configtaskwidget.h | 38 +- 3 files changed, 121 insertions(+), 367 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/stabilization.ui b/ground/openpilotgcs/src/plugins/config/stabilization.ui index 41633f7d5..6b6bb6bf0 100644 --- a/ground/openpilotgcs/src/plugins/config/stabilization.ui +++ b/ground/openpilotgcs/src/plugins/config/stabilization.ui @@ -8752,35 +8752,6 @@ border-radius: 5; - - - - - 0 - 0 - - - - - 16777215 - 22 - - - - 0 - - - - Tab 1 - - - - - Tab 2 - - - - diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index 067b19bf9..903bbc360 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -29,9 +29,6 @@ #include #include "uavsettingsimportexport/uavsettingsimportexportfactory.h" -/** - * Constructor - */ ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent), m_isConnected(false), m_isWidgetUpdatesAllowed(true), m_saveButton(NULL), m_isDirty(false), m_outOfLimitsStyle("background-color: rgb(255, 0, 0);"), m_realtimeUpdateTimer(NULL) { @@ -46,19 +43,11 @@ ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent), m_isConne connect(importexportplugin, SIGNAL(importAboutToBegin()), this, SLOT(invalidateObjects())); } -/** - * Add a widget to the dirty detection pool - * @param widget to add to the detection pool - */ void ConfigTaskWidget::addWidget(QWidget *widget) { addWidgetBinding("", "", widget); } -/** - * Add an object to the management system - * @param objectName name of the object to add to the management system - */ void ConfigTaskWidget::addUAVObject(QString objectName, QList *reloadGroups) { addWidgetBinding(objectName, "", NULL, 0, 1, false, reloadGroups); @@ -66,142 +55,86 @@ void ConfigTaskWidget::addUAVObject(QString objectName, QList *reloadGroups void ConfigTaskWidget::addUAVObject(UAVObject *objectName, QList *reloadGroups) { - QString objstr; - - if (objectName) { - objstr = objectName->getName(); - } - addUAVObject(objstr, reloadGroups); + addUAVObject(objectName ? objectName->getName() : QString(""), reloadGroups); } -/** - * Add an UAVObject field to widget relation to the management system - * @param object name of the object to add - * @param field name of the field to add - * @param widget pointer to the widget whitch will display/define the field value - * @param index index of the field element to add to this relation - */ -void ConfigTaskWidget::addWidgetBinding(QString object, QString field, QWidget *widget, QString index) -{ - UAVObject *obj = NULL; - UAVObjectField *_field = NULL; +int ConfigTaskWidget::fieldIndexFromElementName(QString objectName, QString fieldName, QString elementName) { - obj = getObject(QString(object)); - Q_ASSERT(obj); - _field = obj->getField(QString(field)); - Q_ASSERT(_field); - addWidgetBinding(object, field, widget, _field->getElementNames().indexOf(index)); + if(elementName.isEmpty()) { + return 0; + } + + UAVObject *object = getObject(objectName); + Q_ASSERT(object); + + UAVObjectField *field = object->getField(fieldName); + Q_ASSERT(field); + + return field->getElementNames().indexOf(elementName); } -void ConfigTaskWidget::addWidgetBinding(UAVObject *obj, UAVObjectField *field, QWidget *widget, QString index) +void ConfigTaskWidget::addWidgetBinding(QString objectName, QString fieldName, QWidget *widget, QString elementName) { - QString objstr; - QString fieldstr; - - if (obj) { - objstr = obj->getName(); - } - if (field) { - fieldstr = field->getName(); - } - addWidgetBinding(objstr, fieldstr, widget, index); -} -/** - * Add a UAVObject field to widget relation to the management system - * @param object name of the object to add - * @param field name of the field to add - * @param widget pointer to the widget whitch will display/define the field value - * @param element name of the element of the field element to add to this relation - * @param scale scale value of this relation - * @param isLimited bool to signal if this widget contents is limited in value - * @param defaultReloadGroups default and reload groups this relation belongs to - * @param instID instance ID of the object used on this relation - */ -void ConfigTaskWidget::addWidgetBinding(QString object, QString field, QWidget *widget, QString element, double scale, bool isLimited, QList *defaultReloadGroups, quint32 instID) -{ - UAVObject *obj = getObject(QString(object), instID); - - Q_ASSERT(obj); - UAVObjectField *_field; - int index = 0; - if (!field.isEmpty() && obj) { - _field = obj->getField(QString(field)); - if (!element.isEmpty()) { - index = _field->getElementNames().indexOf(QString(element)); - } - } - addWidgetBinding(object, field, widget, index, scale, isLimited, defaultReloadGroups, instID); + addWidgetBinding(objectName, fieldName, widget, fieldIndexFromElementName(objectName, fieldName, elementName)); } -void ConfigTaskWidget::addWidgetBinding(UAVObject *obj, UAVObjectField *field, QWidget *widget, QString element, double scale, bool isLimited, QList *defaultReloadGroups, quint32 instID) +void ConfigTaskWidget::addWidgetBinding(UAVObject *object, UAVObjectField *field, QWidget *widget, QString elementName) { - QString objstr; - QString fieldstr; - - if (obj) { - objstr = obj->getName(); - } - if (field) { - fieldstr = field->getName(); - } - addWidgetBinding(objstr, fieldstr, widget, element, scale, isLimited, defaultReloadGroups, instID); + addWidgetBinding(object ? object->getName() : QString(""), field ? field->getName() : QString(""), widget, elementName); } -void ConfigTaskWidget::addWidgetBinding(UAVObject *obj, UAVObjectField *field, QWidget *widget, int index, double scale, bool isLimited, QList *defaultReloadGroups, quint32 instID) +void ConfigTaskWidget::addWidgetBinding(QString objectName, QString fieldName, QWidget *widget, QString elementName, double scale, + bool isLimited, QList *reloadGroups, quint32 instID) { - QString objstr; - QString fieldstr; - - if (obj) { - objstr = obj->getName(); - } - if (field) { - fieldstr = field->getName(); - } - addWidgetBinding(objstr, fieldstr, widget, index, scale, isLimited, defaultReloadGroups, instID); + addWidgetBinding(objectName, fieldName, widget, fieldIndexFromElementName(objectName, fieldName, elementName), + scale, isLimited, reloadGroups, instID); } -/** - * Add an UAVObject field to widget relation to the management system - * @param object name of the object to add - * @param field name of the field to add - * @param widget pointer to the widget whitch will display/define the field value - * @param index index of the element of the field to add to this relation - * @param scale scale value of this relation - * @param isLimited bool to signal if this widget contents is limited in value - * @param defaultReloadGroups default and reload groups this relation belongs to - * @param instID instance ID of the object used on this relation - */ -void ConfigTaskWidget::addWidgetBinding(QString object, QString field, QWidget *widget, int index, double scale, bool isLimited, QList *defaultReloadGroups, quint32 instID) +void ConfigTaskWidget::addWidgetBinding(UAVObject *object, UAVObjectField *field, QWidget *widget, QString elementName, double scale, + bool isLimited, QList *reloadGroups, quint32 instID) { - if (addShadowWidgetBinding(object, field, widget, index, scale, isLimited, defaultReloadGroups, instID)) { + addWidgetBinding(object ? object->getName() : QString(""), field ? field->getName() : QString(""), widget, elementName, scale, + isLimited, reloadGroups, instID); +} + +void ConfigTaskWidget::addWidgetBinding(UAVObject *object, UAVObjectField *field, QWidget *widget, int index, double scale, + bool isLimited, QList *reloadGroups, quint32 instID) +{ + addWidgetBinding(object ? object->getName() : QString(""), field ? field->getName() : QString(""), widget, index, scale, + isLimited, reloadGroups, instID); +} + +void ConfigTaskWidget::addWidgetBinding(QString objectName, QString fieldName, QWidget *widget, int index, double scale, + bool isLimited, QList *reloadGroups, quint32 instID) +{ + if (addShadowWidgetBinding(objectName, fieldName, widget, index, scale, isLimited, reloadGroups, instID)) { return; } - UAVObject *obj = NULL; - UAVObjectField *_field = NULL; - if (!object.isEmpty()) { - obj = getObject(QString(object), instID); - Q_ASSERT(obj); - m_updatedObjects.insert(obj, true); - connect(obj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(objectUpdated(UAVObject *))); - connect(obj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(refreshWidgetsValues(UAVObject *)), Qt::UniqueConnection); + UAVObject *object = NULL; + UAVObjectField *field = NULL; + if (!objectName.isEmpty()) { + object = getObject(QString(objectName), instID); + Q_ASSERT(object); + m_updatedObjects.insert(object, true); + connect(object, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(objectUpdated(UAVObject *))); + connect(object, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(refreshWidgetsValues(UAVObject *)), Qt::UniqueConnection); } - if (!field.isEmpty() && obj) { - _field = obj->getField(QString(field)); + if (!fieldName.isEmpty() && object) { + field = object->getField(QString(fieldName)); } - WidgetBinding *binding = new WidgetBinding(widget, obj, _field, index, scale, isLimited); + WidgetBinding *binding = new WidgetBinding(widget, object, field, index, scale, isLimited); m_widgetBindings.append(binding); - if (obj && m_saveButton) { - m_saveButton->addObject((UAVDataObject *)obj); + if (object && m_saveButton) { + m_saveButton->addObject((UAVDataObject *)object); } if (!widget) { - if (defaultReloadGroups && obj) { - foreach(int i, *defaultReloadGroups) { + if (reloadGroups && object) { + foreach(int i, *reloadGroups) { if (this->m_reloadGroups.contains(i)) { this->m_reloadGroups.value(i)->append(binding); } else { @@ -212,17 +145,14 @@ void ConfigTaskWidget::addWidgetBinding(QString object, QString field, QWidget * } } else { connectWidgetUpdatesToSlot(widget, SLOT(widgetsContentsChanged())); - if (defaultReloadGroups) { - addWidgetToReloadGroups(widget, defaultReloadGroups); + if (reloadGroups) { + addWidgetToReloadGroups(widget, reloadGroups); } m_shadowBindings.insert(widget, binding); - loadWidgetLimits(widget, _field, index, isLimited, scale); + loadWidgetLimits(widget, field, index, isLimited, scale); } } -/** - * destructor - */ ConfigTaskWidget::~ConfigTaskWidget() { if (m_saveButton) { @@ -254,10 +184,6 @@ void ConfigTaskWidget::saveObjectToSD(UAVObject *obj) utilMngr->saveObjectToSD(obj); } -/** - * Util function to get a pointer to the object manager - * @return pointer to the UAVObjectManager - */ UAVObjectManager *ConfigTaskWidget::getObjectManager() { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); @@ -266,11 +192,7 @@ UAVObjectManager *ConfigTaskWidget::getObjectManager() Q_ASSERT(objMngr); return objMngr; } -/** - * Utility function which calculates the Mean value of a list of values - * @param list list of double values - * @returns Mean value of the list of parameter values - */ + double ConfigTaskWidget::listMean(QList list) { double accum = 0; @@ -281,11 +203,6 @@ double ConfigTaskWidget::listMean(QList list) return accum / list.size(); } -/** - * Utility function which calculates the Variance value of a list of values - * @param list list of double values - * @returns Variance of the list of parameter values - */ double ConfigTaskWidget::listVar(QList list) { double mean_accum = 0; @@ -305,9 +222,6 @@ double ConfigTaskWidget::listVar(QList list) return var_accum / (list.size() - 1); } -// ************************************ -// telemetry start/stop connect/disconnect signals - void ConfigTaskWidget::onAutopilotDisconnect() { m_isConnected = false; @@ -335,10 +249,7 @@ void ConfigTaskWidget::onAutopilotConnect() enableControls(true); refreshWidgetsValues(); } -/** - * SLOT Function used to populate the widgets with the initial values - * Overwrite this if you need to change the default behavior - */ + void ConfigTaskWidget::populateWidgets() { bool dirtyBack = m_isDirty; @@ -351,11 +262,7 @@ void ConfigTaskWidget::populateWidgets() } setDirty(dirtyBack); } -/** - * SLOT function used to refresh the widgets contents of the widgets with relation to - * object field added to the framework pool - * Overwrite this if you need to change the default behavior - */ + void ConfigTaskWidget::refreshWidgetsValues(UAVObject *obj) { if (!m_isWidgetUpdatesAllowed) { @@ -372,11 +279,6 @@ void ConfigTaskWidget::refreshWidgetsValues(UAVObject *obj) setDirty(dirtyBack); } -/** - * SLOT function used to update the uavobject fields from widgets with relation to - * object field added to the framework pool - * Overwrite this if you need to change the default behavior - */ void ConfigTaskWidget::updateObjectsFromWidgets() { emit updateObjectsFromWidgetsRequested(); @@ -388,10 +290,6 @@ void ConfigTaskWidget::updateObjectsFromWidgets() } } -/** - * SLOT function used handle help button presses - * Overwrite this if you need to change the default behavior - */ void ConfigTaskWidget::helpButtonPressed() { QString url = m_helpButtons.value((QPushButton *)sender(), QString()); @@ -401,12 +299,6 @@ void ConfigTaskWidget::helpButtonPressed() } } -/** - * Add update and save buttons to the form - * multiple buttons can be added for the same function - * @param update pointer to the update button - * @param save pointer to the save button - */ void ConfigTaskWidget::addApplySaveButtons(QPushButton *update, QPushButton *save) { if (!m_saveButton) { @@ -431,11 +323,6 @@ void ConfigTaskWidget::addApplySaveButtons(QPushButton *update, QPushButton *sav updateEnableControls(); } -/** - * SLOT function used the enable or disable the SAVE, UPLOAD and RELOAD buttons - * @param enable set to true to enable the buttons or false to disable them - * @param field name of the field to add - */ void ConfigTaskWidget::enableControls(bool enable) { if (m_saveButton) { @@ -462,17 +349,17 @@ bool ConfigTaskWidget::shouldObjectBeSaved(UAVObject *object) return true; } -/** - * SLOT function called when on of the widgets contents added to the framework changes - */ void ConfigTaskWidget::forceShadowUpdates() { foreach(WidgetBinding * binding, m_widgetBindings) { + QVariant widgetValue = getVariantFromWidget(binding->widget(), binding->scale(), binding->units()); + foreach(ShadowWidgetBinding * shadow, binding->shadows()) { disconnectWidgetUpdatesToSlot(shadow->widget(), SLOT(widgetsContentsChanged())); - checkWidgetsLimits(shadow->widget(), binding->field(), binding->index(), shadow->isLimited(), - getVariantFromWidget(binding->widget(), binding->scale(), binding->units()), shadow->scale()); - setWidgetFromVariant(shadow->widget(), getVariantFromWidget(binding->widget(), binding->scale(), binding->units()), shadow->scale()); + + checkWidgetsLimits(shadow->widget(), binding->field(), binding->index(), shadow->isLimited(), widgetValue, shadow->scale()); + setWidgetFromVariant(shadow->widget(), widgetValue, shadow->scale()); + emit widgetContentsChanged(shadow->widget()); connectWidgetUpdatesToSlot(shadow->widget(), SLOT(widgetsContentsChanged())); } @@ -480,9 +367,6 @@ void ConfigTaskWidget::forceShadowUpdates() setDirty(true); } -/** - * SLOT function called when one of the widgets contents added to the framework changes - */ void ConfigTaskWidget::widgetsContentsChanged() { QWidget *emitter = ((QWidget *)sender()); @@ -500,7 +384,7 @@ void ConfigTaskWidget::widgetsContentsChanged() if (shadow->widget() == emitter) { scale = shadow->scale(); checkWidgetsLimits(emitter, binding->field(), binding->index(), shadow->isLimited(), - getVariantFromWidget(emitter, scale, binding->units()), scale); + getVariantFromWidget(emitter, shadow->scale(), binding->units()), scale); } } } @@ -533,25 +417,16 @@ void ConfigTaskWidget::widgetsContentsChanged() setDirty(true); } -/** - * SLOT function used clear the forms dirty status flag - */ void ConfigTaskWidget::clearDirty() { setDirty(false); } -/** - * Sets the form's dirty status flag - * @param value - */ + void ConfigTaskWidget::setDirty(bool value) { m_isDirty = value; } -/** - * Checks if the form is dirty (unsaved changes) - * @return true if the form has unsaved changes - */ + bool ConfigTaskWidget::isDirty() { if (m_isConnected) { @@ -560,9 +435,7 @@ bool ConfigTaskWidget::isDirty() return false; } } -/** - * SLOT function used to disable widget contents changes when related object field changes - */ + void ConfigTaskWidget::disableObjectUpdates() { m_isWidgetUpdatesAllowed = false; @@ -573,9 +446,6 @@ void ConfigTaskWidget::disableObjectUpdates() } } -/** - * SLOT function used to enable widget contents changes when related object field changes - */ void ConfigTaskWidget::enableObjectUpdates() { m_isWidgetUpdatesAllowed = true; @@ -586,19 +456,11 @@ void ConfigTaskWidget::enableObjectUpdates() } } -/** - * Called when an uav object is updated - * @param obj pointer to the object whitch has just been updated - */ void ConfigTaskWidget::objectUpdated(UAVObject *object) { m_updatedObjects[object] = true; } -/** - * Checks if all objects added to the pool have already been updated - * @return true if all objects added to the pool have already been updated - */ bool ConfigTaskWidget::allObjectsUpdated() { bool result = true; @@ -609,61 +471,44 @@ bool ConfigTaskWidget::allObjectsUpdated() return result; } -/** - * Adds a new help button - * @param button pointer to the help button - * @param url url to open in the browser when the help button is pressed - */ void ConfigTaskWidget::addHelpButton(QPushButton *button, QString url) { m_helpButtons.insert(button, url); connect(button, SIGNAL(clicked()), this, SLOT(helpButtonPressed())); } -/** - * Invalidates all the uav objects "is updated" flag - */ + void ConfigTaskWidget::invalidateObjects() { foreach(UAVObject * obj, m_updatedObjects.keys()) { m_updatedObjects[obj] = false; } } -/** - * SLOT call this to apply changes to uav objects - */ + void ConfigTaskWidget::apply() { if (m_saveButton) { m_saveButton->apply(); } } -/** - * SLOT call this to save changes to uav objects - */ + void ConfigTaskWidget::save() { if (m_saveButton) { m_saveButton->save(); } } -/** - * Adds a new shadow widget - * shadow widgets are widgets whitch have a relation to an object already present on the framework pool i.e. already added trough addUAVObjectToWidgetRelation - * This function doesn't have to be used directly, addUAVObjectToWidgetRelation will call it if a previous relation exhists. - * @return returns false if the shadow widget relation failed to be added (no previous relation exhisted) - */ -bool ConfigTaskWidget::addShadowWidgetBinding(QString object, QString field, QWidget *widget, int index, double scale, bool isLimited, - QList *defaultReloadGroups, quint32 instID) + +bool ConfigTaskWidget::addShadowWidgetBinding(QString objectName, QString fieldName, QWidget *widget, int index, double scale, bool isLimited, + QList *defaultReloadGroups, quint32 instID) { foreach(WidgetBinding * binding, m_widgetBindings) { if (!binding->object() || !binding->widget() || !binding->field()) { continue; } - if (binding->object()->getName() == object && - binding->field()->getName() == field && - binding->index() == index && - binding->object()->getInstID() == instID) { - + if (binding->object()->getName() == objectName && + binding->field()->getName() == fieldName && + binding->index() == index && + binding->object()->getInstID() == instID) { binding->addShadow(widget, scale, isLimited); m_shadowBindings.insert(widget, binding); @@ -678,10 +523,6 @@ bool ConfigTaskWidget::addShadowWidgetBinding(QString object, QString field, QWi return false; } -/** - * Auto loads widgets based on the Dynamic property named "objrelation" - * Check the wiki for more information - */ void ConfigTaskWidget::autoLoadWidgets() { QPushButton *saveButtonWidget = NULL; @@ -785,33 +626,31 @@ void ConfigTaskWidget::autoLoadWidgets() } refreshWidgetsValues(); forceShadowUpdates(); - foreach(WidgetBinding *binding, m_widgetBindings) { + foreach(WidgetBinding * binding, m_widgetBindings) { if (binding->widget()) { - qDebug() << "Binding:" << binding->widget()->objectName(); + qDebug() << "Binding :" << binding->widget()->objectName(); + qDebug() << " Object:" << binding->object()->getName(); + qDebug() << " Field :" << binding->field()->getName(); + qDebug() << " Scale :" << binding->scale(); } - foreach(ShadowWidgetBinding *shadow, binding->shadows()) { + foreach(ShadowWidgetBinding * shadow, binding->shadows()) { if (shadow->widget()) { - qDebug() << " Shadow" << shadow->widget()->objectName(); + qDebug() << " Shadow:" << shadow->widget()->objectName(); + qDebug() << " Scale :" << shadow->scale(); } } } } -/** - * Adds a widget to a list of default/reload groups - * default/reload groups are groups of widgets to be set with default or reloaded (values from persistent memory) when a defined button is pressed - * @param widget pointer to the widget to be added to the groups - * @param groups list of the groups on which to add the widget - */ void ConfigTaskWidget::addWidgetToReloadGroups(QWidget *widget, QList *groups) { - foreach(WidgetBinding *binding, m_widgetBindings) { + foreach(WidgetBinding * binding, m_widgetBindings) { bool addBinding = false; if (binding->widget() == widget) { addBinding = true; } else { - foreach(ShadowWidgetBinding *shadow, binding->shadows()) { + foreach(ShadowWidgetBinding * shadow, binding->shadows()) { if (shadow->widget() == widget) { addBinding = true; } @@ -830,22 +669,12 @@ void ConfigTaskWidget::addWidgetToReloadGroups(QWidget *widget, QList *grou } } -/** - * Adds a button to a default group - * @param button pointer to the default button - * @param buttongroup number of the group - */ void ConfigTaskWidget::addDefaultButton(QPushButton *button, int buttonGroup) { button->setProperty("group", buttonGroup); connect(button, SIGNAL(clicked()), this, SLOT(defaultButtonClicked())); } -/** - * Adds a button to a reload group - * @param button pointer to the reload button - * @param buttongroup number of the group - */ void ConfigTaskWidget::addReloadButton(QPushButton *button, int buttonGroup) { button->setProperty("group", buttonGroup); @@ -853,9 +682,6 @@ void ConfigTaskWidget::addReloadButton(QPushButton *button, int buttonGroup) connect(button, SIGNAL(clicked()), this, SLOT(reloadButtonClicked())); } -/** - * Called when a default button is clicked - */ void ConfigTaskWidget::defaultButtonClicked() { int group = sender()->property("group").toInt(); @@ -871,9 +697,6 @@ void ConfigTaskWidget::defaultButtonClicked() } } -/** - * Called when a reload button is clicked - */ void ConfigTaskWidget::reloadButtonClicked() { if (m_realtimeUpdateTimer) { @@ -891,7 +714,7 @@ void ConfigTaskWidget::reloadButtonClicked() connect(objper, SIGNAL(objectUpdated(UAVObject *)), eventLoop, SLOT(quit())); QList temp; - foreach(WidgetBinding *binding, *bindings) { + foreach(WidgetBinding * binding, *bindings) { if (binding->object() != NULL) { objectComparator value; value.objid = binding->object()->getObjID(); @@ -929,9 +752,6 @@ void ConfigTaskWidget::reloadButtonClicked() } } -/** - * Connects widgets "contents changed" signals to a slot - */ void ConfigTaskWidget::connectWidgetUpdatesToSlot(QWidget *widget, const char *function) { if (!widget) { @@ -958,9 +778,6 @@ void ConfigTaskWidget::connectWidgetUpdatesToSlot(QWidget *widget, const char *f } } -/** - * Disconnects widgets "contents changed" signals to a slot - */ void ConfigTaskWidget::disconnectWidgetUpdatesToSlot(QWidget *widget, const char *function) { if (!widget) { @@ -987,14 +804,6 @@ void ConfigTaskWidget::disconnectWidgetUpdatesToSlot(QWidget *widget, const char } } -/** - * Sets a widget value from an UAVObject field - * @param widget pointer for the widget to set - * @param field pointer to the UAVObject field to use - * @param index index of the element to use - * @param scale scale to be used on the assignement - * @return returns true if the assignement was successfull - */ bool ConfigTaskWidget::setFieldFromWidget(QWidget *widget, UAVObjectField *field, int index, double scale) { if (!widget || !field) { @@ -1011,12 +820,6 @@ bool ConfigTaskWidget::setFieldFromWidget(QWidget *widget, UAVObjectField *field } } -/** - * Gets a variant from a widget - * @param widget pointer to the widget from where to get the value - * @param scale scale to be used on the assignement - * @return returns the value of the widget times the scale - */ QVariant ConfigTaskWidget::getVariantFromWidget(QWidget *widget, double scale, QString units) { if (QComboBox * cb = qobject_cast(widget)) { @@ -1042,16 +845,9 @@ QVariant ConfigTaskWidget::getVariantFromWidget(QWidget *widget, double scale, Q } } -/** - * Sets a widget from a variant - * @param widget pointer for the widget to set - * @param value value to be used on the assignement - * @param scale scale to be used on the assignement - * @param units the units for the value - * @return returns true if the assignement was successfull - */ bool ConfigTaskWidget::setWidgetFromVariant(QWidget *widget, QVariant value, double scale, QString units) { + qDebug() << widget->objectName() << "=" << value; if (QComboBox * cb = qobject_cast(widget)) { cb->setCurrentIndex(cb->findText(value.toString())); return true; @@ -1091,27 +887,11 @@ bool ConfigTaskWidget::setWidgetFromVariant(QWidget *widget, QVariant value, dou } } -/** - * Sets a widget from a variant - * @param widget pointer for the widget to set - * @param value value to be used on the assignement - * @param scale scale to be used on the assignement - * @return returns true if the assignement was successfull - */ bool ConfigTaskWidget::setWidgetFromVariant(QWidget *widget, QVariant value, double scale) { return setWidgetFromVariant(widget, value, scale, QString("")); } -/** - * Sets a widget from a UAVObject field - * @param widget pointer to the widget to set - * @param field pointer to the field from where to get the value from - * @param index index of the element to use - * @param scale scale to be used on the assignement - * @param hasLimits set to true if you want to limit the values (check wiki) - * @return returns true if the assignement was successfull - */ bool ConfigTaskWidget::setWidgetFromField(QWidget *widget, UAVObjectField *field, int index, double scale, bool hasLimits) { if (!widget || !field) { @@ -1122,10 +902,11 @@ bool ConfigTaskWidget::setWidgetFromField(QWidget *widget, UAVObjectField *field loadWidgetLimits(cb, field, index, hasLimits, scale); } } - QVariant var = field->getValue(index); - checkWidgetsLimits(widget, field, index, hasLimits, var, scale); - bool ret = setWidgetFromVariant(widget, var, scale, field->getUnits()); - if (ret) { + qDebug() << field->getName() << ":" << index; + QVariant value = field->getValue(index); + checkWidgetsLimits(widget, field, index, hasLimits, value, scale); + bool result = setWidgetFromVariant(widget, value, scale, field->getUnits()); + if (result) { return true; } else { qDebug() << __FUNCTION__ << "widget to uavobject relation not implemented" << widget->metaObject()->className(); @@ -1275,12 +1056,11 @@ WidgetBinding::WidgetBinding(QWidget *widget, UAVObject *object, UAVObjectField } WidgetBinding::~WidgetBinding() -{ -} +{} QString WidgetBinding::units() const { - if(m_field) { + if (m_field) { return m_field->getUnits(); } return QString(""); @@ -1306,7 +1086,7 @@ QList WidgetBinding::shadows() const return m_shadows; } -void WidgetBinding::addShadow(QWidget *widget, int scale, bool isLimited) +void WidgetBinding::addShadow(QWidget *widget, double scale, bool isLimited) { ShadowWidgetBinding *shadow = NULL; @@ -1331,8 +1111,7 @@ ShadowWidgetBinding::ShadowWidgetBinding(QWidget *widget, double scale, bool isL } ShadowWidgetBinding::~ShadowWidgetBinding() -{ -} +{} QWidget *ShadowWidgetBinding::widget() const { diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index 3578c2c53..23e78ba54 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -50,7 +50,7 @@ class ShadowWidgetBinding : public QObject { Q_OBJECT public: - ShadowWidgetBinding(QWidget* widget, double scale, bool isLimited); + ShadowWidgetBinding(QWidget *widget, double scale, bool isLimited); ~ShadowWidgetBinding(); QWidget *widget() const; double scale() const; @@ -58,23 +58,23 @@ public: protected: QWidget *m_widget; - double m_scale; - bool m_isLimited; + double m_scale; + bool m_isLimited; }; class WidgetBinding : public ShadowWidgetBinding { Q_OBJECT public: - WidgetBinding(QWidget* widget, UAVObject* object, UAVObjectField* field, int index, double scale, bool isLimited); + WidgetBinding(QWidget *widget, UAVObject *object, UAVObjectField *field, int index, double scale, bool isLimited); ~WidgetBinding(); QString units() const; - UAVObject *object() const; + UAVObject *object() const; UAVObjectField *field() const; - int index() const; + int index() const; QList shadows() const; - void addShadow(QWidget* widget, int scale, bool isLimited); + void addShadow(QWidget *widget, double scale, bool isLimited); private: UAVObject *m_object; @@ -103,14 +103,18 @@ public: void addWidget(QWidget *widget); - void addWidgetBinding(QString object, QString field, QWidget *widget, int index = 0, double scale = 1, bool isLimited = false, QList *m_reloadGroups = 0, quint32 instID = 0); - void addWidgetBinding(UAVObject *obj, UAVObjectField *field, QWidget *widget, int index = 0, double scale = 1, bool isLimited = false, QList *m_reloadGroups = 0, quint32 instID = 0); + void addWidgetBinding(QString objectName, QString fieldName, QWidget *widget, int index = 0, double scale = 1, + bool isLimited = false, QList *reloadGroups = 0, quint32 instID = 0); + void addWidgetBinding(UAVObject *object, UAVObjectField *field, QWidget *widget, int index = 0, double scale = 1, + bool isLimited = false, QList *reloadGroups = 0, quint32 instID = 0); - void addWidgetBinding(QString object, QString field, QWidget *widget, QString element, double scale, bool isLimited = false, QList *m_reloadGroups = 0, quint32 instID = 0); - void addWidgetBinding(UAVObject *obj, UAVObjectField *field, QWidget *widget, QString element, double scale, bool isLimited = false, QList *m_reloadGroups = 0, quint32 instID = 0); + void addWidgetBinding(QString objectName, QString fieldName, QWidget *widget, QString elementName, double scale, + bool isLimited = false, QList *reloadGroups = 0, quint32 instID = 0); + void addWidgetBinding(UAVObject *object, UAVObjectField *field, QWidget *widget, QString elementName, double scale, + bool isLimited = false, QList *reloadGroups = 0, quint32 instID = 0); - void addWidgetBinding(QString object, QString field, QWidget *widget, QString index); - void addWidgetBinding(UAVObject *obj, UAVObjectField *field, QWidget *widget, QString index); + void addWidgetBinding(QString objectName, QString fieldName, QWidget *widget, QString elementName); + void addWidgetBinding(UAVObject *object, UAVObjectField *field, QWidget *widget, QString elementName); void addApplySaveButtons(QPushButton *update, QPushButton *save); void addReloadButton(QPushButton *button, int buttonGroup); @@ -118,9 +122,8 @@ public: void addWidgetToReloadGroups(QWidget *widget, QList *groups); - bool addShadowWidgetBinding(QWidget *masterWidget, QWidget *shadowWidget, double shadowScale = 1, bool shadowIsLimited = false); - bool addShadowWidgetBinding(QString object, QString field, QWidget *widget, int index = 0, double scale = 1, bool isLimited = false, - QList *m_reloadGroups = NULL, quint32 instID = 0); + bool addShadowWidgetBinding(QString objectName, QString fieldName, QWidget *widget, int index = 0, double scale = 1, + bool isLimited = false, QList *m_reloadGroups = NULL, quint32 instID = 0); void autoLoadWidgets(); @@ -214,8 +217,9 @@ private: void disconnectWidgetUpdatesToSlot(QWidget *widget, const char *function); void loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, double sclale); - virtual UAVObject* getObject(const QString name, quint32 instId = 0); + virtual UAVObject *getObject(const QString name, quint32 instId = 0); + int fieldIndexFromElementName(QString objectName, QString fieldName, QString elementName); protected slots: virtual void disableObjectUpdates(); virtual void enableObjectUpdates(); From c24753603aa13a2eec95c47db1b009a84fbdec49 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Mon, 6 Jan 2014 11:54:34 +0100 Subject: [PATCH 27/45] OP-984 Adding support for multiple bindings per widget. --- .../uavobjectwidgetutils/configtaskwidget.cpp | 169 +++++++++--------- .../uavobjectwidgetutils/configtaskwidget.h | 27 +-- 2 files changed, 105 insertions(+), 91 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index 903bbc360..b31055916 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -58,13 +58,13 @@ void ConfigTaskWidget::addUAVObject(UAVObject *objectName, QList *reloadGro addUAVObject(objectName ? objectName->getName() : QString(""), reloadGroups); } -int ConfigTaskWidget::fieldIndexFromElementName(QString objectName, QString fieldName, QString elementName) { - - if(elementName.isEmpty()) { +int ConfigTaskWidget::fieldIndexFromElementName(QString objectName, QString fieldName, QString elementName) +{ + if (elementName.isEmpty()) { return 0; } - UAVObject *object = getObject(objectName); + UAVObject *object = getObject(objectName); Q_ASSERT(object); UAVObjectField *field = object->getField(fieldName); @@ -84,34 +84,34 @@ void ConfigTaskWidget::addWidgetBinding(UAVObject *object, UAVObjectField *field } void ConfigTaskWidget::addWidgetBinding(QString objectName, QString fieldName, QWidget *widget, QString elementName, double scale, - bool isLimited, QList *reloadGroups, quint32 instID) + bool isLimited, QList *reloadGroupIDs, quint32 instID) { addWidgetBinding(objectName, fieldName, widget, fieldIndexFromElementName(objectName, fieldName, elementName), - scale, isLimited, reloadGroups, instID); + scale, isLimited, reloadGroupIDs, instID); } void ConfigTaskWidget::addWidgetBinding(UAVObject *object, UAVObjectField *field, QWidget *widget, QString elementName, double scale, - bool isLimited, QList *reloadGroups, quint32 instID) + bool isLimited, QList *reloadGroupIDs, quint32 instID) { addWidgetBinding(object ? object->getName() : QString(""), field ? field->getName() : QString(""), widget, elementName, scale, - isLimited, reloadGroups, instID); + isLimited, reloadGroupIDs, instID); } void ConfigTaskWidget::addWidgetBinding(UAVObject *object, UAVObjectField *field, QWidget *widget, int index, double scale, - bool isLimited, QList *reloadGroups, quint32 instID) + bool isLimited, QList *reloadGroupIDs, quint32 instID) { addWidgetBinding(object ? object->getName() : QString(""), field ? field->getName() : QString(""), widget, index, scale, - isLimited, reloadGroups, instID); + isLimited, reloadGroupIDs, instID); } void ConfigTaskWidget::addWidgetBinding(QString objectName, QString fieldName, QWidget *widget, int index, double scale, - bool isLimited, QList *reloadGroups, quint32 instID) + bool isLimited, QList *reloadGroupIDs, quint32 instID) { - if (addShadowWidgetBinding(objectName, fieldName, widget, index, scale, isLimited, reloadGroups, instID)) { + if (addShadowWidgetBinding(objectName, fieldName, widget, index, scale, isLimited, reloadGroupIDs, instID)) { return; } - UAVObject *object = NULL; + UAVObject *object = NULL; UAVObjectField *field = NULL; if (!objectName.isEmpty()) { object = getObject(QString(objectName), instID); @@ -126,29 +126,27 @@ void ConfigTaskWidget::addWidgetBinding(QString objectName, QString fieldName, Q } WidgetBinding *binding = new WidgetBinding(widget, object, field, index, scale, isLimited); - m_widgetBindings.append(binding); + m_widgetBindingsPerWidget.insert(widget, binding); - if (object && m_saveButton) { - m_saveButton->addObject((UAVDataObject *)object); + + if (object) { + m_widgetBindingsPerObject.insert(object, binding); + if(m_saveButton) { + m_saveButton->addObject((UAVDataObject *)object); + } } if (!widget) { - if (reloadGroups && object) { - foreach(int i, *reloadGroups) { - if (this->m_reloadGroups.contains(i)) { - this->m_reloadGroups.value(i)->append(binding); - } else { - this->m_reloadGroups.insert(i, new QList()); - this->m_reloadGroups.value(i)->append(binding); - } + if (reloadGroupIDs && object) { + foreach(int groupId, *reloadGroupIDs) { + m_reloadGroups.insert(groupId, binding); } } } else { connectWidgetUpdatesToSlot(widget, SLOT(widgetsContentsChanged())); - if (reloadGroups) { - addWidgetToReloadGroups(widget, reloadGroups); + if (reloadGroupIDs) { + addWidgetToReloadGroups(widget, reloadGroupIDs); } - m_shadowBindings.insert(widget, binding); loadWidgetLimits(widget, field, index, isLimited, scale); } } @@ -158,12 +156,7 @@ ConfigTaskWidget::~ConfigTaskWidget() if (m_saveButton) { delete m_saveButton; } - foreach(QList *reloadGroup, m_reloadGroups.values()) { - if (reloadGroup) { - delete reloadGroup; - } - } - foreach(WidgetBinding * binding, m_widgetBindings) { + foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { if (binding) { delete binding; } @@ -242,7 +235,10 @@ void ConfigTaskWidget::onAutopilotConnect() } invalidateObjects(); m_isConnected = true; - foreach(WidgetBinding * binding, m_widgetBindings) { + foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { + if(!binding->isEnabled()) { + continue; + } loadWidgetLimits(binding->widget(), binding->field(), binding->index(), binding->isLimited(), binding->scale()); } setDirty(false); @@ -255,8 +251,8 @@ void ConfigTaskWidget::populateWidgets() bool dirtyBack = m_isDirty; emit populateWidgetsRequested(); - foreach(WidgetBinding * binding, m_widgetBindings) { - if (binding->object() != NULL && binding->field() != NULL && binding->widget() != NULL) { + foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { + if (binding->isEnabled() && binding->object() != NULL && binding->field() != NULL && binding->widget() != NULL) { setWidgetFromField(binding->widget(), binding->field(), binding->index(), binding->scale(), binding->isLimited()); } } @@ -271,8 +267,8 @@ void ConfigTaskWidget::refreshWidgetsValues(UAVObject *obj) bool dirtyBack = m_isDirty; emit refreshWidgetsValuesRequested(); - foreach(WidgetBinding * binding, m_widgetBindings) { - if (binding->object() == obj && binding->field() != NULL && binding->widget() != NULL) { + foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { + if (binding->isEnabled() && binding->object() == obj && binding->field() != NULL && binding->widget() != NULL) { setWidgetFromField(binding->widget(), binding->field(), binding->index(), binding->scale(), binding->isLimited()); } } @@ -283,8 +279,8 @@ void ConfigTaskWidget::updateObjectsFromWidgets() { emit updateObjectsFromWidgetsRequested(); - foreach(WidgetBinding * binding, m_widgetBindings) { - if (binding->object() != NULL && binding->field() != NULL) { + foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { + if (binding->isEnabled() && binding->object() != NULL && binding->field() != NULL) { setFieldFromWidget(binding->widget(), binding->field(), binding->index(), binding->scale()); } } @@ -315,10 +311,8 @@ void ConfigTaskWidget::addApplySaveButtons(QPushButton *update, QPushButton *sav } else if (save) { m_saveButton->addSaveButton(save); } - if (m_widgetBindings.count() > 0) { - foreach(WidgetBinding * binding, m_widgetBindings) { - m_saveButton->addObject((UAVDataObject *)binding->object()); - } + foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { + m_saveButton->addObject((UAVDataObject *)binding->object()); } updateEnableControls(); } @@ -333,8 +327,8 @@ void ConfigTaskWidget::enableControls(bool enable) button->setEnabled(enable); } - foreach(WidgetBinding * binding, m_widgetBindings) { - if (binding->widget()) { + foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { + if (binding->isEnabled() && binding->widget()) { binding->widget()->setEnabled(enable); foreach(ShadowWidgetBinding * shadow, binding->shadows()) { shadow->widget()->setEnabled(enable); @@ -351,7 +345,7 @@ bool ConfigTaskWidget::shouldObjectBeSaved(UAVObject *object) void ConfigTaskWidget::forceShadowUpdates() { - foreach(WidgetBinding * binding, m_widgetBindings) { + foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { QVariant widgetValue = getVariantFromWidget(binding->widget(), binding->scale(), binding->units()); foreach(ShadowWidgetBinding * shadow, binding->shadows()) { @@ -372,7 +366,7 @@ void ConfigTaskWidget::widgetsContentsChanged() QWidget *emitter = ((QWidget *)sender()); emit widgetContentsChanged(emitter); double scale; - WidgetBinding *binding = m_shadowBindings.value(emitter, NULL); + WidgetBinding *binding = m_widgetBindingsPerWidget.value(emitter, NULL); if (binding) { if (binding->widget() == emitter) { @@ -439,7 +433,7 @@ bool ConfigTaskWidget::isDirty() void ConfigTaskWidget::disableObjectUpdates() { m_isWidgetUpdatesAllowed = false; - foreach(WidgetBinding * binding, m_widgetBindings) { + foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { if (binding->object()) { disconnect(binding->object(), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(refreshWidgetsValues(UAVObject *))); } @@ -449,7 +443,7 @@ void ConfigTaskWidget::disableObjectUpdates() void ConfigTaskWidget::enableObjectUpdates() { m_isWidgetUpdatesAllowed = true; - foreach(WidgetBinding * binding, m_widgetBindings) { + foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { if (binding->object()) { connect(binding->object(), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(refreshWidgetsValues(UAVObject *)), Qt::UniqueConnection); } @@ -501,17 +495,14 @@ void ConfigTaskWidget::save() bool ConfigTaskWidget::addShadowWidgetBinding(QString objectName, QString fieldName, QWidget *widget, int index, double scale, bool isLimited, QList *defaultReloadGroups, quint32 instID) { - foreach(WidgetBinding * binding, m_widgetBindings) { - if (!binding->object() || !binding->widget() || !binding->field()) { + foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { + if (!binding->isEnabled() || !binding->object() || !binding->widget() || !binding->field()) { continue; } - if (binding->object()->getName() == objectName && - binding->field()->getName() == fieldName && - binding->index() == index && - binding->object()->getInstID() == instID) { + if (binding->matches(objectName, fieldName, index, instID)) { binding->addShadow(widget, scale, isLimited); - m_shadowBindings.insert(widget, binding); + m_widgetBindingsPerWidget.insert(widget, binding); connectWidgetUpdatesToSlot(widget, SLOT(widgetsContentsChanged())); if (defaultReloadGroups) { addWidgetToReloadGroups(widget, defaultReloadGroups); @@ -626,12 +617,13 @@ void ConfigTaskWidget::autoLoadWidgets() } refreshWidgetsValues(); forceShadowUpdates(); - foreach(WidgetBinding * binding, m_widgetBindings) { + foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { if (binding->widget()) { - qDebug() << "Binding :" << binding->widget()->objectName(); - qDebug() << " Object:" << binding->object()->getName(); - qDebug() << " Field :" << binding->field()->getName(); - qDebug() << " Scale :" << binding->scale(); + qDebug() << "Binding :" << binding->widget()->objectName(); + qDebug() << " Object :" << binding->object()->getName(); + qDebug() << " Field :" << binding->field()->getName(); + qDebug() << " Scale :" << binding->scale(); + qDebug() << " Enabled:" << binding->isEnabled(); } foreach(ShadowWidgetBinding * shadow, binding->shadows()) { if (shadow->widget()) { @@ -642,9 +634,9 @@ void ConfigTaskWidget::autoLoadWidgets() } } -void ConfigTaskWidget::addWidgetToReloadGroups(QWidget *widget, QList *groups) +void ConfigTaskWidget::addWidgetToReloadGroups(QWidget *widget, QList *reloadGroupIDs) { - foreach(WidgetBinding * binding, m_widgetBindings) { + foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { bool addBinding = false; if (binding->widget() == widget) { @@ -657,13 +649,8 @@ void ConfigTaskWidget::addWidgetToReloadGroups(QWidget *widget, QList *grou } } if (addBinding) { - foreach(int i, *groups) { - if (m_reloadGroups.contains(i)) { - m_reloadGroups.value(i)->append(binding); - } else { - m_reloadGroups.insert(i, new QList()); - m_reloadGroups.value(i)->append(binding); - } + foreach(int groupID, *reloadGroupIDs) { + m_reloadGroups.insert(groupID, binding); } } } @@ -684,11 +671,11 @@ void ConfigTaskWidget::addReloadButton(QPushButton *button, int buttonGroup) void ConfigTaskWidget::defaultButtonClicked() { - int group = sender()->property("group").toInt(); - emit defaultRequested(group); + int groupID = sender()->property("group").toInt(); + emit defaultRequested(groupID); - QList *bindings = m_reloadGroups.value(group); - foreach(WidgetBinding * binding, *bindings) { + QList bindings = m_reloadGroups.values(groupID); + foreach(WidgetBinding * binding, bindings) { if (!binding->object() || !binding->field()) { continue; } @@ -702,9 +689,9 @@ void ConfigTaskWidget::reloadButtonClicked() if (m_realtimeUpdateTimer) { return; } - int group = sender()->property("group").toInt(); - QList *bindings = m_reloadGroups.value(group, NULL); - if (!bindings) { + int groupID = sender()->property("group").toInt(); + QList bindings = m_reloadGroups.values(groupID); + if (!bindings.isEmpty()) { return; } ObjectPersistence *objper = dynamic_cast(getObjectManager()->getObject(ObjectPersistence::NAME)); @@ -714,7 +701,7 @@ void ConfigTaskWidget::reloadButtonClicked() connect(objper, SIGNAL(objectUpdated(UAVObject *)), eventLoop, SLOT(quit())); QList temp; - foreach(WidgetBinding * binding, *bindings) { + foreach(WidgetBinding * binding, bindings) { if (binding->object() != NULL) { objectComparator value; value.objid = binding->object()->getObjID(); @@ -905,7 +892,7 @@ bool ConfigTaskWidget::setWidgetFromField(QWidget *widget, UAVObjectField *field qDebug() << field->getName() << ":" << index; QVariant value = field->getValue(index); checkWidgetsLimits(widget, field, index, hasLimits, value, scale); - bool result = setWidgetFromVariant(widget, value, scale, field->getUnits()); + bool result = setWidgetFromVariant(widget, value, scale, field->getUnits()); if (result) { return true; } else { @@ -1048,7 +1035,7 @@ bool ConfigTaskWidget::eventFilter(QObject *obj, QEvent *evt) } WidgetBinding::WidgetBinding(QWidget *widget, UAVObject *object, UAVObjectField *field, int index, double scale, bool isLimited) : - ShadowWidgetBinding(widget, scale, isLimited) + ShadowWidgetBinding(widget, scale, isLimited), m_isEnabled(true) { m_object = object; m_field = field; @@ -1103,6 +1090,26 @@ void WidgetBinding::addShadow(QWidget *widget, double scale, bool isLimited) m_shadows.append(shadow); } +bool WidgetBinding::matches(QString objectName, QString fieldName, int index, quint32 instanceId) +{ + if (m_object && m_field) { + return m_object->getName() == objectName && m_object->getInstID() == instanceId && + m_field->getName() == fieldName && m_index == index; + } else { + return false; + } +} +bool WidgetBinding::isEnabled() const +{ + return m_isEnabled; +} + +void WidgetBinding::setIsEnabled(bool isEnabled) +{ + m_isEnabled = isEnabled; +} + + ShadowWidgetBinding::ShadowWidgetBinding(QWidget *widget, double scale, bool isLimited) { m_widget = widget; diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index 23e78ba54..70697eb07 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -75,11 +75,16 @@ public: QList shadows() const; void addShadow(QWidget *widget, double scale, bool isLimited); + bool matches(QString objectName, QString fieldName, int index, quint32 instanceId); + + bool isEnabled() const; + void setIsEnabled(bool isEnabled); private: UAVObject *m_object; UAVObjectField *m_field; int m_index; + bool m_isEnabled; QList m_shadows; }; @@ -104,14 +109,14 @@ public: void addWidget(QWidget *widget); void addWidgetBinding(QString objectName, QString fieldName, QWidget *widget, int index = 0, double scale = 1, - bool isLimited = false, QList *reloadGroups = 0, quint32 instID = 0); + bool isLimited = false, QList *reloadGroupIDs = 0, quint32 instID = 0); void addWidgetBinding(UAVObject *object, UAVObjectField *field, QWidget *widget, int index = 0, double scale = 1, - bool isLimited = false, QList *reloadGroups = 0, quint32 instID = 0); + bool isLimited = false, QList *reloadGroupIDs = 0, quint32 instID = 0); void addWidgetBinding(QString objectName, QString fieldName, QWidget *widget, QString elementName, double scale, - bool isLimited = false, QList *reloadGroups = 0, quint32 instID = 0); + bool isLimited = false, QList *reloadGroupIDs = 0, quint32 instID = 0); void addWidgetBinding(UAVObject *object, UAVObjectField *field, QWidget *widget, QString elementName, double scale, - bool isLimited = false, QList *reloadGroups = 0, quint32 instID = 0); + bool isLimited = false, QList *reloadGroupIDs = 0, quint32 instID = 0); void addWidgetBinding(QString objectName, QString fieldName, QWidget *widget, QString elementName); void addWidgetBinding(UAVObject *object, UAVObjectField *field, QWidget *widget, QString elementName); @@ -120,7 +125,7 @@ public: void addReloadButton(QPushButton *button, int buttonGroup); void addDefaultButton(QPushButton *button, int buttonGroup); - void addWidgetToReloadGroups(QWidget *widget, QList *groups); + void addWidgetToReloadGroups(QWidget *widget, QList *reloadGroupIDs); bool addShadowWidgetBinding(QString objectName, QString fieldName, QWidget *widget, int index = 0, double scale = 1, bool isLimited = false, QList *m_reloadGroups = NULL, quint32 instID = 0); @@ -193,14 +198,16 @@ private: bool m_isConnected; bool m_isWidgetUpdatesAllowed; QStringList m_objects; - QList m_widgetBindings; + + QMultiHash m_reloadGroups; + QMultiHash m_widgetBindingsPerWidget; + QMultiHash m_widgetBindingsPerObject; + ExtensionSystem::PluginManager *m_pluginManager; UAVObjectUtilManager *m_objectUtilManager; SmartSaveButton *m_saveButton; - QMap m_updatedObjects; - QMap *> m_reloadGroups; - QMap m_shadowBindings; - QMap m_helpButtons; + QHash m_updatedObjects; + QHash m_helpButtons; QList m_reloadButtons; bool m_isDirty; QString m_outOfLimitsStyle; From 3ed61a37d0568d9411ff1e48ea9f2ae01639e739 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Mon, 6 Jan 2014 12:56:30 +0100 Subject: [PATCH 28/45] OP-984 More refactoring. --- .../uavobjectwidgetutils/configtaskwidget.cpp | 16 ++++++++++++++-- .../uavobjectwidgetutils/configtaskwidget.h | 4 ++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index b31055916..a3fd51f38 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -105,6 +105,15 @@ void ConfigTaskWidget::addWidgetBinding(UAVObject *object, UAVObjectField *field } void ConfigTaskWidget::addWidgetBinding(QString objectName, QString fieldName, QWidget *widget, int index, double scale, + bool isLimited, QList *reloadGroupIDs, quint32 instID) { + + // If object name is comma separated list of objects, call one time per objectName + foreach(QString singleObjectName, objectName.split(",")) { + doAddWidgetBinding(singleObjectName, fieldName, widget, index, scale, isLimited, reloadGroupIDs, instID); + } +} + +void ConfigTaskWidget::doAddWidgetBinding(QString objectName, QString fieldName, QWidget *widget, int index, double scale, bool isLimited, QList *reloadGroupIDs, quint32 instID) { if (addShadowWidgetBinding(objectName, fieldName, widget, index, scale, isLimited, reloadGroupIDs, instID)) { @@ -126,12 +135,14 @@ void ConfigTaskWidget::addWidgetBinding(QString objectName, QString fieldName, Q } WidgetBinding *binding = new WidgetBinding(widget, object, field, index, scale, isLimited); + // Only the first binding per widget can be enabled. + binding->setIsEnabled(m_widgetBindingsPerWidget.count(widget) == 0); m_widgetBindingsPerWidget.insert(widget, binding); if (object) { m_widgetBindingsPerObject.insert(object, binding); - if(m_saveButton) { + if (m_saveButton) { m_saveButton->addObject((UAVDataObject *)object); } } @@ -236,7 +247,7 @@ void ConfigTaskWidget::onAutopilotConnect() invalidateObjects(); m_isConnected = true; foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { - if(!binding->isEnabled()) { + if (!binding->isEnabled()) { continue; } loadWidgetLimits(binding->widget(), binding->field(), binding->index(), binding->isLimited(), binding->scale()); @@ -617,6 +628,7 @@ void ConfigTaskWidget::autoLoadWidgets() } refreshWidgetsValues(); forceShadowUpdates(); + foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { if (binding->widget()) { qDebug() << "Binding :" << binding->widget()->objectName(); diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index 70697eb07..ffec13970 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -227,6 +227,10 @@ private: virtual UAVObject *getObject(const QString name, quint32 instId = 0); int fieldIndexFromElementName(QString objectName, QString fieldName, QString elementName); + + void doAddWidgetBinding(QString objectName, QString fieldName, QWidget *widget, int index = 0, double scale = 1, + bool isLimited = false, QList *reloadGroupIDs = 0, quint32 instID = 0); + protected slots: virtual void disableObjectUpdates(); virtual void enableObjectUpdates(); From f8714de85bfab2825ee1b1d1f3f235cd09da1d2b Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Mon, 6 Jan 2014 13:33:22 +0100 Subject: [PATCH 29/45] OP-984 Fixed a double dispose issue in destructor. --- .../src/plugins/uavobjectwidgetutils/configtaskwidget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index a3fd51f38..e6af06247 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -167,7 +167,8 @@ ConfigTaskWidget::~ConfigTaskWidget() if (m_saveButton) { delete m_saveButton; } - foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { + QSet deleteSet = m_widgetBindingsPerWidget.values().toSet(); + foreach(WidgetBinding * binding, deleteSet) { if (binding) { delete binding; } From a2e0158bfbd2ae0b6d9f08a709bd55d6e8a1731e Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Mon, 6 Jan 2014 17:25:39 +0100 Subject: [PATCH 30/45] OP-984 Closing in... --- .../src/plugins/config/stabilization.ui | 108 ++++++++-------- .../uavobjectwidgetutils/configtaskwidget.cpp | 117 ++++++++++-------- 2 files changed, 116 insertions(+), 109 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/stabilization.ui b/ground/openpilotgcs/src/plugins/config/stabilization.ui index 6b6bb6bf0..416e26590 100644 --- a/ground/openpilotgcs/src/plugins/config/stabilization.ui +++ b/ground/openpilotgcs/src/plugins/config/stabilization.ui @@ -1312,7 +1312,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:RollMax haslimits:no scale:1 @@ -1346,7 +1346,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:ManualRate element:Roll haslimits:no @@ -1394,7 +1394,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:ManualRate element:Roll haslimits:no @@ -2583,7 +2583,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:RollMax haslimits:no scale:1 @@ -2617,7 +2617,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:ManualRate element:Yaw haslimits:no @@ -2668,7 +2668,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:ManualRate element:Yaw haslimits:no @@ -4448,7 +4448,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:RollRatePID element:Kp haslimits:yes @@ -4487,7 +4487,7 @@ Then lower the value by 5 or so. - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:RollRatePID element:Kp haslimits:yes @@ -4562,7 +4562,7 @@ Then lower the value by 5 or so. - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:YawRatePID element:Kp haslimits:yes @@ -4612,7 +4612,7 @@ Then lower the value by 5 or so. - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:PitchRatePID element:Kp haslimits:yes @@ -4651,7 +4651,7 @@ Then lower the value by 5 or so. - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:PitchRatePID element:Kp haslimits:yes @@ -4690,7 +4690,7 @@ Then lower the value by 5 or so. - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:YawRatePID element:Kp haslimits:yes @@ -4740,7 +4740,7 @@ Then lower the value by 5 or so. - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:RollRatePID element:Ki haslimits:yes @@ -4798,7 +4798,7 @@ value as the Kp. - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:RollRatePID element:Ki haslimits:yes @@ -4837,7 +4837,7 @@ value as the Kp. - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:YawRatePID element:Ki haslimits:yes @@ -4887,7 +4887,7 @@ value as the Kp. - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:YawRatePID element:Ki haslimits:yes @@ -4937,7 +4937,7 @@ value as the Kp. - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:PitchRatePID element:Ki haslimits:yes @@ -4976,7 +4976,7 @@ value as the Kp. - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:PitchRatePID element:Ki haslimits:yes @@ -8349,7 +8349,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:RollPI element:Kp scale:0.1 @@ -8384,7 +8384,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:RollPI element:Kp scale:0.1 @@ -8434,7 +8434,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:PitchPI element:Kp scale:0.1 @@ -8469,7 +8469,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:PitchPI element:Kp scale:0.1 @@ -8519,7 +8519,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:YawPI element:Kp scale:0.1 @@ -8554,7 +8554,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:YawPI element:Kp scale:0.1 @@ -9989,7 +9989,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:PitchMax haslimits:no scale:1 @@ -10072,7 +10072,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:MaximumRate element:Roll haslimits:no @@ -10141,7 +10141,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:ManualRate element:Yaw haslimits:no @@ -10194,7 +10194,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:YawMax haslimits:no scale:1 @@ -10246,7 +10246,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:MaximumRate element:Pitch haslimits:no @@ -11456,7 +11456,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:ManualRate element:Pitch haslimits:no @@ -12075,7 +12075,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:ManualRate element:Roll haslimits:no @@ -12131,7 +12131,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:RollMax haslimits:no scale:1 @@ -12183,7 +12183,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:MaximumRate element:Yaw haslimits:no @@ -13352,7 +13352,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:PitchRatePID element:Kd haslimits:no @@ -13971,7 +13971,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:YawRatePID element:Ki haslimits:no @@ -14021,7 +14021,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:PitchRatePID element:Ki haslimits:no @@ -14071,7 +14071,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:YawRatePID element:Kp haslimits:no @@ -14121,7 +14121,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:YawRatePID element:Kd haslimits:no @@ -15328,7 +15328,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:RollRatePID element:Kp haslimits:no @@ -15394,7 +15394,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:RollRatePID element:Ki haslimits:no @@ -15475,7 +15475,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:PitchRatePID element:Kp haslimits:no @@ -15525,7 +15525,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:RollRatePID element:Kd haslimits:no @@ -18378,7 +18378,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:RollPI element:Kp haslimits:no @@ -18428,7 +18428,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:PitchPI element:Kp haslimits:no @@ -18478,7 +18478,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:YawPI element:Kp haslimits:no @@ -18563,7 +18563,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:RollPI element:Ki haslimits:no @@ -18629,7 +18629,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:PitchPI element:Ki haslimits:no @@ -18695,7 +18695,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:YawPI element:Ki haslimits:no @@ -21937,7 +21937,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:PitchRatePID element:ILimit haslimits:no @@ -21990,7 +21990,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:RollRatePID element:ILimit haslimits:no @@ -23140,7 +23140,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:YawPI element:ILimit haslimits:no @@ -23221,7 +23221,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:PitchPI element:ILimit haslimits:no @@ -23331,7 +23331,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:RollPI element:ILimit haslimits:no @@ -23947,7 +23947,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1 + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 fieldname:YawRatePID element:ILimit haslimits:no diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index e6af06247..1ac4a2c34 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -60,11 +60,12 @@ void ConfigTaskWidget::addUAVObject(UAVObject *objectName, QList *reloadGro int ConfigTaskWidget::fieldIndexFromElementName(QString objectName, QString fieldName, QString elementName) { - if (elementName.isEmpty()) { + if (elementName.isEmpty() || objectName.isEmpty()) { return 0; } - UAVObject *object = getObject(objectName); + QString singleObjectName = objectName.split(",").at(0); + UAVObject *object = getObject(singleObjectName); Q_ASSERT(object); UAVObjectField *field = object->getField(fieldName); @@ -153,12 +154,14 @@ void ConfigTaskWidget::doAddWidgetBinding(QString objectName, QString fieldName, m_reloadGroups.insert(groupId, binding); } } - } else { + } else { connectWidgetUpdatesToSlot(widget, SLOT(widgetsContentsChanged())); if (reloadGroupIDs) { addWidgetToReloadGroups(widget, reloadGroupIDs); } - loadWidgetLimits(widget, field, index, isLimited, scale); + if(binding->isEnabled()) { + loadWidgetLimits(widget, field, index, isLimited, scale); + } } } @@ -247,7 +250,7 @@ void ConfigTaskWidget::onAutopilotConnect() } invalidateObjects(); m_isConnected = true; - foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { + foreach(WidgetBinding * binding, m_widgetBindingsPerObject) { if (!binding->isEnabled()) { continue; } @@ -263,7 +266,7 @@ void ConfigTaskWidget::populateWidgets() bool dirtyBack = m_isDirty; emit populateWidgetsRequested(); - foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { + foreach(WidgetBinding * binding, m_widgetBindingsPerObject) { if (binding->isEnabled() && binding->object() != NULL && binding->field() != NULL && binding->widget() != NULL) { setWidgetFromField(binding->widget(), binding->field(), binding->index(), binding->scale(), binding->isLimited()); } @@ -279,8 +282,8 @@ void ConfigTaskWidget::refreshWidgetsValues(UAVObject *obj) bool dirtyBack = m_isDirty; emit refreshWidgetsValuesRequested(); - foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { - if (binding->isEnabled() && binding->object() == obj && binding->field() != NULL && binding->widget() != NULL) { + foreach(WidgetBinding * binding, m_widgetBindingsPerObject.values(obj)) { + if (binding->isEnabled() && binding->field() != NULL && binding->widget() != NULL) { setWidgetFromField(binding->widget(), binding->field(), binding->index(), binding->scale(), binding->isLimited()); } } @@ -291,7 +294,7 @@ void ConfigTaskWidget::updateObjectsFromWidgets() { emit updateObjectsFromWidgetsRequested(); - foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { + foreach(WidgetBinding * binding, m_widgetBindingsPerObject) { if (binding->isEnabled() && binding->object() != NULL && binding->field() != NULL) { setFieldFromWidget(binding->widget(), binding->field(), binding->index(), binding->scale()); } @@ -339,7 +342,7 @@ void ConfigTaskWidget::enableControls(bool enable) button->setEnabled(enable); } - foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { + foreach(WidgetBinding * binding, m_widgetBindingsPerObject) { if (binding->isEnabled() && binding->widget()) { binding->widget()->setEnabled(enable); foreach(ShadowWidgetBinding * shadow, binding->shadows()) { @@ -357,7 +360,10 @@ bool ConfigTaskWidget::shouldObjectBeSaved(UAVObject *object) void ConfigTaskWidget::forceShadowUpdates() { - foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { + foreach(WidgetBinding * binding, m_widgetBindingsPerObject) { + if(!binding->isEnabled()) { + continue; + } QVariant widgetValue = getVariantFromWidget(binding->widget(), binding->scale(), binding->units()); foreach(ShadowWidgetBinding * shadow, binding->shadows()) { @@ -378,42 +384,43 @@ void ConfigTaskWidget::widgetsContentsChanged() QWidget *emitter = ((QWidget *)sender()); emit widgetContentsChanged(emitter); double scale; - WidgetBinding *binding = m_widgetBindingsPerWidget.value(emitter, NULL); + foreach(WidgetBinding *binding ,m_widgetBindingsPerWidget.values(emitter)) { - if (binding) { - if (binding->widget() == emitter) { - scale = binding->scale(); - checkWidgetsLimits(emitter, binding->field(), binding->index(), binding->isLimited(), - getVariantFromWidget(emitter, binding->scale(), binding->units()), binding->scale()); - } else { - foreach(ShadowWidgetBinding * shadow, binding->shadows()) { - if (shadow->widget() == emitter) { - scale = shadow->scale(); - checkWidgetsLimits(emitter, binding->field(), binding->index(), shadow->isLimited(), - getVariantFromWidget(emitter, shadow->scale(), binding->units()), scale); + if (binding && binding->isEnabled()) { + if (binding->widget() == emitter) { + scale = binding->scale(); + checkWidgetsLimits(emitter, binding->field(), binding->index(), binding->isLimited(), + getVariantFromWidget(emitter, binding->scale(), binding->units()), binding->scale()); + } else { + foreach(ShadowWidgetBinding * shadow, binding->shadows()) { + if (shadow->widget() == emitter) { + scale = shadow->scale(); + checkWidgetsLimits(emitter, binding->field(), binding->index(), shadow->isLimited(), + getVariantFromWidget(emitter, shadow->scale(), binding->units()), scale); + } } } - } - if (binding->widget() != emitter) { - disconnectWidgetUpdatesToSlot(binding->widget(), SLOT(widgetsContentsChanged())); + if (binding->widget() != emitter) { + disconnectWidgetUpdatesToSlot(binding->widget(), SLOT(widgetsContentsChanged())); - checkWidgetsLimits(binding->widget(), binding->field(), binding->index(), binding->isLimited(), - getVariantFromWidget(emitter, scale, binding->units()), binding->scale()); - setWidgetFromVariant(binding->widget(), getVariantFromWidget(emitter, scale, binding->units()), binding->scale()); - emit widgetContentsChanged(binding->widget()); + checkWidgetsLimits(binding->widget(), binding->field(), binding->index(), binding->isLimited(), + getVariantFromWidget(emitter, scale, binding->units()), binding->scale()); + setWidgetFromVariant(binding->widget(), getVariantFromWidget(emitter, scale, binding->units()), binding->scale()); + emit widgetContentsChanged(binding->widget()); - connectWidgetUpdatesToSlot(binding->widget(), SLOT(widgetsContentsChanged())); - } - foreach(ShadowWidgetBinding * shadow, binding->shadows()) { - if (shadow->widget() != emitter) { - disconnectWidgetUpdatesToSlot(shadow->widget(), SLOT(widgetsContentsChanged())); + connectWidgetUpdatesToSlot(binding->widget(), SLOT(widgetsContentsChanged())); + } + foreach(ShadowWidgetBinding * shadow, binding->shadows()) { + if (shadow->widget() != emitter) { + disconnectWidgetUpdatesToSlot(shadow->widget(), SLOT(widgetsContentsChanged())); - checkWidgetsLimits(shadow->widget(), binding->field(), binding->index(), shadow->isLimited(), - getVariantFromWidget(emitter, scale, binding->units()), shadow->scale()); - setWidgetFromVariant(shadow->widget(), getVariantFromWidget(emitter, scale, binding->units()), shadow->scale()); - emit widgetContentsChanged(shadow->widget()); + checkWidgetsLimits(shadow->widget(), binding->field(), binding->index(), shadow->isLimited(), + getVariantFromWidget(emitter, scale, binding->units()), shadow->scale()); + setWidgetFromVariant(shadow->widget(), getVariantFromWidget(emitter, scale, binding->units()), shadow->scale()); + emit widgetContentsChanged(shadow->widget()); - connectWidgetUpdatesToSlot(shadow->widget(), SLOT(widgetsContentsChanged())); + connectWidgetUpdatesToSlot(shadow->widget(), SLOT(widgetsContentsChanged())); + } } } } @@ -508,7 +515,7 @@ bool ConfigTaskWidget::addShadowWidgetBinding(QString objectName, QString fieldN QList *defaultReloadGroups, quint32 instID) { foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { - if (!binding->isEnabled() || !binding->object() || !binding->widget() || !binding->field()) { + if (!binding->object() || !binding->widget() || !binding->field()) { continue; } if (binding->matches(objectName, fieldName, index, instID)) { @@ -519,7 +526,9 @@ bool ConfigTaskWidget::addShadowWidgetBinding(QString objectName, QString fieldN if (defaultReloadGroups) { addWidgetToReloadGroups(widget, defaultReloadGroups); } - loadWidgetLimits(widget, binding->field(), binding->index(), isLimited, scale); + if(!binding->isEnabled()) { + loadWidgetLimits(widget, binding->field(), binding->index(), isLimited, scale); + } return true; } } @@ -630,7 +639,7 @@ void ConfigTaskWidget::autoLoadWidgets() refreshWidgetsValues(); forceShadowUpdates(); - foreach(WidgetBinding * binding, m_widgetBindingsPerWidget) { + foreach(WidgetBinding * binding, m_widgetBindingsPerObject) { if (binding->widget()) { qDebug() << "Binding :" << binding->widget()->objectName(); qDebug() << " Object :" << binding->object()->getName(); @@ -689,7 +698,7 @@ void ConfigTaskWidget::defaultButtonClicked() QList bindings = m_reloadGroups.values(groupID); foreach(WidgetBinding * binding, bindings) { - if (!binding->object() || !binding->field()) { + if (!binding->isEnabled() || !binding->object() || !binding->field()) { continue; } UAVDataObject *temp = ((UAVDataObject *)binding->object())->dirtyClone(); @@ -715,7 +724,7 @@ void ConfigTaskWidget::reloadButtonClicked() QList temp; foreach(WidgetBinding * binding, bindings) { - if (binding->object() != NULL) { + if (binding->isEnabled() && binding->object() != NULL) { objectComparator value; value.objid = binding->object()->getObjID(); value.objinstid = binding->object()->getInstID(); @@ -758,21 +767,21 @@ void ConfigTaskWidget::connectWidgetUpdatesToSlot(QWidget *widget, const char *f return; } if (QComboBox * cb = qobject_cast(widget)) { - connect(cb, SIGNAL(currentIndexChanged(int)), this, function); + connect(cb, SIGNAL(currentIndexChanged(int)), this, function, Qt::UniqueConnection); } else if (QSlider * cb = qobject_cast(widget)) { - connect(cb, SIGNAL(valueChanged(int)), this, function); + connect(cb, SIGNAL(valueChanged(int)), this, function, Qt::UniqueConnection); } else if (MixerCurveWidget * cb = qobject_cast(widget)) { - connect(cb, SIGNAL(curveUpdated()), this, function); + connect(cb, SIGNAL(curveUpdated()), this, function, Qt::UniqueConnection); } else if (QTableWidget * cb = qobject_cast(widget)) { - connect(cb, SIGNAL(cellChanged(int, int)), this, function); + connect(cb, SIGNAL(cellChanged(int, int)), this, function, Qt::UniqueConnection); } else if (QSpinBox * cb = qobject_cast(widget)) { - connect(cb, SIGNAL(valueChanged(int)), this, function); + connect(cb, SIGNAL(valueChanged(int)), this, function, Qt::UniqueConnection); } else if (QDoubleSpinBox * cb = qobject_cast(widget)) { - connect(cb, SIGNAL(valueChanged(double)), this, function); + connect(cb, SIGNAL(valueChanged(double)), this, function, Qt::UniqueConnection); } else if (QCheckBox * cb = qobject_cast(widget)) { - connect(cb, SIGNAL(stateChanged(int)), this, function); + connect(cb, SIGNAL(stateChanged(int)), this, function, Qt::UniqueConnection); } else if (QPushButton * cb = qobject_cast(widget)) { - connect(cb, SIGNAL(clicked()), this, function); + connect(cb, SIGNAL(clicked()), this, function, Qt::UniqueConnection); } else { qDebug() << __FUNCTION__ << "widget binding not implemented" << widget->metaObject()->className(); } @@ -847,7 +856,6 @@ QVariant ConfigTaskWidget::getVariantFromWidget(QWidget *widget, double scale, Q bool ConfigTaskWidget::setWidgetFromVariant(QWidget *widget, QVariant value, double scale, QString units) { - qDebug() << widget->objectName() << "=" << value; if (QComboBox * cb = qobject_cast(widget)) { cb->setCurrentIndex(cb->findText(value.toString())); return true; @@ -902,7 +910,6 @@ bool ConfigTaskWidget::setWidgetFromField(QWidget *widget, UAVObjectField *field loadWidgetLimits(cb, field, index, hasLimits, scale); } } - qDebug() << field->getName() << ":" << index; QVariant value = field->getValue(index); checkWidgetsLimits(widget, field, index, hasLimits, value, scale); bool result = setWidgetFromVariant(widget, value, scale, field->getUnits()); From 69e5f0c1868304f9b1defd4e65532f45775ced34 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Mon, 6 Jan 2014 22:25:38 +0100 Subject: [PATCH 31/45] OP-984 Minor fixes before actual gui changes. --- .../src/plugins/config/stabilization.ui | 26 +++++++++---------- .../uavobjectwidgetutils/configtaskwidget.cpp | 4 +-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/stabilization.ui b/ground/openpilotgcs/src/plugins/config/stabilization.ui index 416e26590..4ded74648 100644 --- a/ground/openpilotgcs/src/plugins/config/stabilization.ui +++ b/ground/openpilotgcs/src/plugins/config/stabilization.ui @@ -27631,7 +27631,7 @@ border-radius: 5; objname:AltitudeHoldSettings button:default - buttongroup:99 + buttongroup:98 @@ -28182,7 +28182,7 @@ border-radius: 5; fieldname:Kp scale:0.001 haslimits:yes - buttongroup:99 + buttongroup:98 @@ -28207,7 +28207,7 @@ border-radius: 5; fieldname:Ki scale:0.001 haslimits:yes - buttongroup:99 + buttongroup:98 @@ -28232,7 +28232,7 @@ border-radius: 5; fieldname:Kd scale:0.001 haslimits:yes - buttongroup:99 + buttongroup:98 @@ -28844,7 +28844,7 @@ border-radius: 5; fieldname:Kp scale:0.001 haslimits:yes - buttongroup:99 + buttongroup:98 @@ -28890,7 +28890,7 @@ border-radius: 5; fieldname:Ki scale:0.001 haslimits:yes - buttongroup:99 + buttongroup:98 @@ -28936,7 +28936,7 @@ border-radius: 5; fieldname:Kd scale:0.001 haslimits:yes - buttongroup:99 + buttongroup:98 @@ -29960,7 +29960,7 @@ border-radius: 5; - 10 + 5 1 @@ -29969,7 +29969,7 @@ border-radius: 5; 1 - 5 + 3 Qt::Horizontal @@ -29985,7 +29985,7 @@ border-radius: 5; objname:AltitudeHoldSettings fieldname:ThrottleRate haslimits:no - scale:0.5 + scale:1 buttongroup:99 @@ -30139,16 +30139,16 @@ border-radius: 5; Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - 1 + 0 5.000000000000000 - 0.100000000000000 + 1.000000000000000 - 2.500000000000000 + 3.000000000000000 diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index 1ac4a2c34..4a9f538d1 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -390,13 +390,13 @@ void ConfigTaskWidget::widgetsContentsChanged() if (binding->widget() == emitter) { scale = binding->scale(); checkWidgetsLimits(emitter, binding->field(), binding->index(), binding->isLimited(), - getVariantFromWidget(emitter, binding->scale(), binding->units()), binding->scale()); + getVariantFromWidget(emitter, scale, binding->units()), scale); } else { foreach(ShadowWidgetBinding * shadow, binding->shadows()) { if (shadow->widget() == emitter) { scale = shadow->scale(); checkWidgetsLimits(emitter, binding->field(), binding->index(), shadow->isLimited(), - getVariantFromWidget(emitter, shadow->scale(), binding->units()), scale); + getVariantFromWidget(emitter, scale, binding->units()), scale); } } } From 15cf91aa5350ae3556faa0ac1128583101facb5a Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Mon, 6 Jan 2014 23:31:46 +0100 Subject: [PATCH 32/45] OP-984 UI changes. --- .../src/plugins/config/stabilization.ui | 14535 ++++++++-------- 1 file changed, 7310 insertions(+), 7225 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/stabilization.ui b/ground/openpilotgcs/src/plugins/config/stabilization.ui index 4ded74648..0d708d8c2 100644 --- a/ground/openpilotgcs/src/plugins/config/stabilization.ui +++ b/ground/openpilotgcs/src/plugins/config/stabilization.ui @@ -7,7 +7,7 @@ 0 0 820 - 736 + 785 @@ -443,6 +443,9 @@ false + + + 30 @@ -628,7 +631,7 @@ 0 0 796 - 659 + 708 @@ -639,2138 +642,76 @@ - 9 + 0 9 - - - - - - - - - Responsiveness - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - true - - - - 9 - - - 9 - - - 9 - - - 9 - - - - - - 0 - 0 - - - - Reset all values to GCS defaults - - - Default - - - - objname:StabilizationSettings - button:default - buttongroup:6 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QGroupBox{border: 0px;} - - - - - - true - - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 14 - 200 - 14 - - - - - 6 - 150 - 6 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 14 - 200 - 14 - - - - - 6 - 150 - 6 - - - - - - - - - - - 14 - 200 - 14 - - - - - 6 - 150 - 6 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 14 - 200 - 14 - - - - - 6 - 150 - 6 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 14 - 200 - 14 - - - - - 6 - 150 - 6 - - - - - - - - - - - 14 - 200 - 14 - - - - - 6 - 150 - 6 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 14 - 200 - 14 - - - - - 6 - 150 - 6 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 14 - 200 - 14 - - - - - 6 - 150 - 6 - - - - - - - - - - - 14 - 200 - 14 - - - - - 6 - 150 - 6 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - This thing really can preform, it is a lot more responsive this way - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(14, 200, 14, 255), stop:0.78607 rgba(6, 150, 6 , 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Snappy - - - Qt::AlignCenter - - - - - - - - 50 - 22 - - - - - 50 - 22 - - - - 10 - - - 180 - - - 83 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:RollMax - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - <html><head/><body><p>The Rate mode slider can be adjusted to value ranges whose responsiveness is represented by the Moderate / Snappy / Insane bar</p></body></html> - - - 100 - - - 800 - - - 400 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 25 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:ManualRate - element:Roll - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 50 - 22 - - - - - 50 - 22 - - - - 100 - - - 800 - - - 400 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:ManualRate - element:Roll - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - Lazy Sunday afternoon flying, fly's nice and stable - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(34, 34, 200, 255), stop:0.78607 rgba(6, 6, 150, 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Moderate - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 200 - 14 - 14 - - - - - 160 - 6 - 6 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 200 - 14 - 14 - - - - - 160 - 6 - 6 - - - - - - - - - - - 200 - 14 - 14 - - - - - 160 - 6 - 6 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 200 - 14 - 14 - - - - - 160 - 6 - 6 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 200 - 14 - 14 - - - - - 160 - 6 - 6 - - - - - - - - - - - 200 - 14 - 14 - - - - - 160 - 6 - 6 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 200 - 14 - 14 - - - - - 160 - 6 - 6 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 200 - 14 - 14 - - - - - 160 - 6 - 6 - - - - - - - - - - - 200 - 14 - 14 - - - - - 160 - 6 - 6 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - Damn this is insane how quick it moves. Mostly used by the Pro's - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(200, 14, 14, 255), stop:0.78607 rgba(160 , 6, 6 , 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Insane - - - Qt::AlignCenter - - - - - - - - 78 - 16 - - - - Attitude mode - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 78 - 16 - - - - Rate mode - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - <html><head/><body><p>The Attitude Mode slider can be adjusted to value ranges whose responsivness is represented by the Moderate / Snappy / Insane bar</p></body></html> - - - 10 - - - 180 - - - 1 - - - 83 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 25 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:RollMax - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - <html><head/><body><p>The Rate mode Yaw slider can be adjusted to value ranges whose responsiveness is represented by the Moderate / Snappy / Insane bar</p></body></html> - - - 100 - - - 800 - - - 400 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 25 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:ManualRate - element:Yaw - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - - 78 - 16 - - - - Rate mode yaw - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 50 - 22 - - - - - 50 - 22 - - - - 100 - - - 800 - - - 400 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:ManualRate - element:Yaw - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - - - - - + - + 0 0 - - - 0 - 0 - - 16777215 - 195 + 21 - - Rate Stabilization (Inner Loop) + + border-bottom: 0px - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + QTabWidget::Rounded - - false + + 0 - - - 9 - - - 9 - - - 9 - - - 9 - - - 6 - - - + + true + + + + PID Bank 1 + + + + + PID Bank 2 + + + + + PID Bank 3 + + + + + + + + ArrowCursor + + + #pidBankFrame{ + color: rgb(180, 180, 180); +margin-top: -1px +} + + + QFrame::Box + + + QFrame::Plain + + + + - - 0 - 0 - - - - Qt::StrongFocus - - - <html><head/><body><p>Link roll &amp; pitch sliders to move together, thus giving same value for both roll &amp; pitch when setting up a symetrical vehicle that requires both to be the same</p></body></html> - - - - - - Link Roll and Pitch - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 497 - 20 - - - - - - - - + 0 0 @@ -2784,33 +725,2864 @@ border-radius: 5; 16777215 - 16777215 + 195 - - Reset all values to GCS defaults + + Rate Stabilization (Inner Loop) - + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + false - - - - - Default - - - - button:default - buttongroup:1 - - + + + 9 + + + 9 + + + 9 + + + 9 + + + 6 + + + + + + 0 + 0 + + + + Qt::StrongFocus + + + <html><head/><body><p>Link roll &amp; pitch sliders to move together, thus giving same value for both roll &amp; pitch when setting up a symetrical vehicle that requires both to be the same</p></body></html> + + + + + + Link Roll and Pitch + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 497 + 20 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Reset all values to GCS defaults + + + false + + + + + + Default + + + + button:default + buttongroup:1 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 251 + 251 + 251 + + + + + + + 124 + 124 + 124 + + + + + + + 165 + 165 + 165 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 251 + 251 + 251 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 251 + 251 + 251 + + + + + + + 124 + 124 + 124 + + + + + + + 165 + 165 + 165 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 251 + 251 + 251 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 124 + 124 + 124 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 251 + 251 + 251 + + + + + + + 124 + 124 + 124 + + + + + + + 165 + 165 + 165 + + + + + + + 124 + 124 + 124 + + + + + + + 255 + 255 + 255 + + + + + + + 124 + 124 + 124 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 248 + 248 + 248 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 50 + false + false + true + + + + false + + + QGroupBox{border: 0px;} + + + + + + true + + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Yaw + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Pitch + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much leveling stability is set into Rate mode (inner loop). Too much will make your vehicle oscillate in Rate mode.</p></body></html> + + + + + + 100 + + + 51 + + + 51 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 25 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:RollRatePID + element:Kp + haslimits:yes + scale:0.0001 + buttongroup:1,10 + + + + + + + + + 50 + 22 + + + + + 50 + 22 + + + + Qt::StrongFocus + + + Slowly raise Proportional until you start seeing clear oscillations when you fly. +Then lower the value by 5 or so. + + + 200 + + + 200 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:RollRatePID + element:Kp + haslimits:yes + scale:0.0001 + buttongroup:1,10 + + + + + + + + + 0 + 0 + + + + + 78 + 16 + + + + + + + Proportional + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much leveling stability is set into Rate mode (inner loop). Too much will make your vehicle oscillate in Rate mode.</p></body></html> + + + + + + 100 + + + 50 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 25 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:YawRatePID + element:Kp + haslimits:yes + scale:0.0001 + buttongroup:1,10 + + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much leveling stability is set into Rate mode (inner loop). Too much will make your vehicle oscillate in Rate mode.</p></body></html> + + + + + + 100 + + + 50 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 25 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:PitchRatePID + element:Kp + haslimits:yes + scale:0.0001 + buttongroup:1,10 + + + + + + + + + 50 + 22 + + + + + 50 + 22 + + + + Qt::StrongFocus + + + Slowly raise Proportional until you start seeing clear oscillations when you fly. +Then lower the value by 5 or so. + + + 200 + + + 200 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:PitchRatePID + element:Kp + haslimits:yes + scale:0.0001 + buttongroup:1,10 + + + + + + + + + 50 + 22 + + + + + 50 + 22 + + + + Qt::StrongFocus + + + Slowly raise Proportional until you start seeing clear oscillations when you fly. +Then lower the value by 5 or so. + + + 200 + + + 200 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:YawRatePID + element:Kp + haslimits:yes + scale:0.0001 + buttongroup:1,10 + + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Rate mode. A good starting point for Integral is the same as Proportional</p></body></html> + + + + + + 100 + + + 50 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 25 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:RollRatePID + element:Ki + haslimits:yes + scale:0.0001 + buttongroup:1,10 + + + + + + + + + 0 + 0 + + + + + + + Integral + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 50 + 22 + + + + + 50 + 22 + + + + Qt::StrongFocus + + + As a rule of thumb, you can set the Integral at roughly the same +value as the Kp. + + + 200 + + + 200 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:RollRatePID + element:Ki + haslimits:yes + scale:0.0001 + buttongroup:1,10 + + + + + + + + + 50 + 22 + + + + + 50 + 22 + + + + Qt::StrongFocus + + + As a rule of thumb, you can set the Integral at roughly the same +value as the Kp. + + + 200 + + + 200 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:YawRatePID + element:Ki + haslimits:yes + scale:0.0001 + buttongroup:1,10 + + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Rate mode. A good starting point for Integral is the same as Proportional</p></body></html> + + + + + + 100 + + + 50 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 25 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:YawRatePID + element:Ki + haslimits:yes + scale:0.0001 + buttongroup:1,10 + + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Rate mode. A good starting point for Integral is the same as Proportional</p></body></html> + + + + + + 100 + + + 50 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 25 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:PitchRatePID + element:Ki + haslimits:yes + scale:0.0001 + buttongroup:1,10 + + + + + + + + + 50 + 22 + + + + + 50 + 22 + + + + Qt::StrongFocus + + + As a rule of thumb, you can set the Integral at roughly the same +value as the Kp. + + + 200 + + + 200 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:PitchRatePID + element:Ki + haslimits:yes + scale:0.0001 + buttongroup:1,10 + + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Roll + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + - - + + - + 0 0 @@ -2821,6 +3593,12 @@ border-radius: 5; 0 + + + 16777215 + 195 + + @@ -2834,12 +3612,23 @@ border-radius: 5; - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + @@ -2906,21 +3695,43 @@ border-radius: 5; - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + @@ -2971,12 +3782,23 @@ border-radius: 5; - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + @@ -3043,21 +3865,43 @@ border-radius: 5; - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + @@ -3108,12 +3952,23 @@ border-radius: 5; - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + @@ -3180,21 +4035,43 @@ border-radius: 5; - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + @@ -3236,1760 +4113,73 @@ border-radius: 5; - - - 50 - false - false - true - - false - - QGroupBox{border: 0px;} - - + Attitude Stabilization (Outer Loop) - - true + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - + - 0 + 9 + + + 9 - 0 + 9 - 0 + 9 + + + 6 - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Yaw - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Pitch - - - Qt::AlignCenter - - - - - + 0 0 - - - 0 - 25 - - Qt::StrongFocus - <html><head/><body><p>This adjusts how much leveling stability is set into Rate mode (inner loop). Too much will make your vehicle oscillate in Rate mode.</p></body></html> - - - - - - 100 - - - 51 - - - 51 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 25 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:RollRatePID - element:Kp - haslimits:yes - scale:0.0001 - buttongroup:1,10 - - - - - - - - - 50 - 22 - - - - - 50 - 22 - - - - Qt::StrongFocus - - - Slowly raise Proportional until you start seeing clear oscillations when you fly. -Then lower the value by 5 or so. - - - 200 - - - 200 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:RollRatePID - element:Kp - haslimits:yes - scale:0.0001 - buttongroup:1,10 - - - - - - - - - 0 - 0 - - - - - 78 - 16 - + <html><head/><body><p>Link roll &amp; pitch sliders to move together, thus giving same value for both roll &amp; pitch when setting up a symetrical vehicle that requires both to be the same.</p></body></html> - Proportional - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much leveling stability is set into Rate mode (inner loop). Too much will make your vehicle oscillate in Rate mode.</p></body></html> - - - - - - 100 - - - 50 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 25 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:YawRatePID - element:Kp - haslimits:yes - scale:0.0001 - buttongroup:1,10 - - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much leveling stability is set into Rate mode (inner loop). Too much will make your vehicle oscillate in Rate mode.</p></body></html> - - - - - - 100 - - - 50 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 25 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:PitchRatePID - element:Kp - haslimits:yes - scale:0.0001 - buttongroup:1,10 - - - - - - - - - 50 - 22 - - - - - 50 - 22 - - - - Qt::StrongFocus - - - Slowly raise Proportional until you start seeing clear oscillations when you fly. -Then lower the value by 5 or so. - - - 200 - - - 200 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:PitchRatePID - element:Kp - haslimits:yes - scale:0.0001 - buttongroup:1,10 - - - - - - - - - 50 - 22 - - - - - 50 - 22 - - - - Qt::StrongFocus - - - Slowly raise Proportional until you start seeing clear oscillations when you fly. -Then lower the value by 5 or so. - - - 200 - - - 200 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:YawRatePID - element:Kp - haslimits:yes - scale:0.0001 - buttongroup:1,10 - - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Rate mode. A good starting point for Integral is the same as Proportional</p></body></html> - - - - - - 100 - - - 50 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 25 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:RollRatePID - element:Ki - haslimits:yes - scale:0.0001 - buttongroup:1,10 - - - - - - - - - 0 - 0 - - - - - - - Integral - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 50 - 22 - - - - - 50 - 22 - - - - Qt::StrongFocus - - - As a rule of thumb, you can set the Integral at roughly the same -value as the Kp. - - - 200 - - - 200 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:RollRatePID - element:Ki - haslimits:yes - scale:0.0001 - buttongroup:1,10 - - - - - - - - - 50 - 22 - - - - - 50 - 22 - - - - Qt::StrongFocus - - - As a rule of thumb, you can set the Integral at roughly the same -value as the Kp. - - - 200 - - - 200 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:YawRatePID - element:Ki - haslimits:yes - scale:0.0001 - buttongroup:1,10 - - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Rate mode. A good starting point for Integral is the same as Proportional</p></body></html> - - - - - - 100 - - - 50 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 25 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:YawRatePID - element:Ki - haslimits:yes - scale:0.0001 - buttongroup:1,10 - - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Rate mode. A good starting point for Integral is the same as Proportional</p></body></html> - - - - - - 100 - - - 50 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 25 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:PitchRatePID - element:Ki - haslimits:yes - scale:0.0001 - buttongroup:1,10 - - - - - - - - - 50 - 22 - - - - - 50 - 22 - - - - Qt::StrongFocus - - - As a rule of thumb, you can set the Integral at roughly the same -value as the Kp. - - - 200 - - - 200 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:PitchRatePID - element:Ki - haslimits:yes - scale:0.0001 - buttongroup:1,10 - + Link Roll and Pitch - + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 497 + 20 + + + + + + - + 0 0 @@ -4997,7 +4187,38 @@ value as the Kp. 0 - 16 + 0 + + + + Reset all values to GCS defaults + + + + + + Default + + + + button:default + buttongroup:2 + + + + + + + + + 0 + 0 + + + + + 0 + 0 @@ -5006,74 +4227,63 @@ value as the Kp. - 255 - 255 - 255 + 0 + 0 + 0 - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - + + + 0 + 0 + 0 + - 58 - 58 - 58 + 255 + 255 + 255 - 48 - 48 - 48 + 251 + 251 + 251 - 19 - 19 - 19 + 124 + 124 + 124 - 26 - 26 - 26 + 165 + 165 + 165 - 255 - 255 - 255 + 0 + 0 + 0 @@ -5089,50 +4299,28 @@ value as the Kp. - 255 - 255 - 255 + 0 + 0 + 0 - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - + + + 0 + 0 + 0 + - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - + + + 0 + 0 + 0 + @@ -5147,9 +4335,9 @@ value as the Kp. - 19 - 19 - 19 + 251 + 251 + 251 @@ -5176,74 +4364,63 @@ value as the Kp. - 255 - 255 - 255 + 0 + 0 + 0 - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - + + + 0 + 0 + 0 + - 58 - 58 - 58 + 255 + 255 + 255 - 48 - 48 - 48 + 251 + 251 + 251 - 19 - 19 - 19 + 124 + 124 + 124 - 26 - 26 - 26 + 165 + 165 + 165 - 255 - 255 - 255 + 0 + 0 + 0 @@ -5259,50 +4436,28 @@ value as the Kp. - 255 - 255 - 255 + 0 + 0 + 0 - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - + + + 0 + 0 + 0 + - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - + + + 0 + 0 + 0 + @@ -5317,9 +4472,9 @@ value as the Kp. - 19 - 19 - 19 + 251 + 251 + 251 @@ -5346,74 +4501,63 @@ value as the Kp. - 255 - 255 - 255 + 124 + 124 + 124 - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - + + + 0 + 0 + 0 + - 58 - 58 - 58 + 255 + 255 + 255 - 48 - 48 - 48 + 251 + 251 + 251 - 19 - 19 - 19 + 124 + 124 + 124 - 26 - 26 - 26 + 165 + 165 + 165 - 255 - 255 - 255 + 124 + 124 + 124 @@ -5429,50 +4573,28 @@ value as the Kp. - 255 - 255 - 255 + 124 + 124 + 124 - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - + + + 0 + 0 + 0 + - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - + + + 0 + 0 + 0 + @@ -5487,9 +4609,9 @@ value as the Kp. - 39 - 39 - 39 + 248 + 248 + 248 @@ -5514,30 +4636,2087 @@ value as the Kp. - - - 75 - true - - false - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); + QGroupBox{border: 0px;} + + + + + + true + + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); color: rgb(255, 255, 255); border-radius: 5; + + + Roll + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Pitch + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Yaw + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 78 + 16 + + + + + + + Proportional + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much leveling stability is set into Attitude mode (outer loop). Too much will make your vehicle oscillate in Attitude Mode.</p></body></html> + + + + + + 100 + + + 50 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 25 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:RollPI + element:Kp + scale:0.1 + haslimits:yes + buttongroup:2,10 + + + + + + + + + 50 + 22 + + + + + 50 + 22 + + + + Qt::StrongFocus + + + 200 + + + 200 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:RollPI + element:Kp + scale:0.1 + haslimits:yes + buttongroup:2,10 + + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much leveling stability is set into Attitude mode (outer loop). Too much will make your vehicle oscillate in Attitude Mode.</p></body></html> + + + + + + 100 + + + 50 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 25 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:PitchPI + element:Kp + scale:0.1 + haslimits:yes + buttongroup:2,10 + + + + + + + + + 50 + 22 + + + + + 50 + 22 + + + + Qt::StrongFocus + + + 200 + + + 200 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:PitchPI + element:Kp + scale:0.1 + haslimits:yes + buttongroup:2,10 + + + + + + + + + 0 + 0 + + + + + 0 + 25 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much leveling stability is set into Attitude mode (outer loop). Too much will make your vehicle oscillate in Attitude Mode.</p></body></html> + + + + + + 100 + + + 50 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 25 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:YawPI + element:Kp + scale:0.1 + haslimits:yes + buttongroup:2,10 + + + + + + + + + 50 + 22 + + + + + 50 + 22 + + + + Qt::StrongFocus + + + 200 + + + 200 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:YawPI + element:Kp + scale:0.1 + haslimits:yes + buttongroup:2,10 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 1 + + + + + + + + + + + + + + + + + + + + Responsiveness + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + false + + + true + + + + 9 + + + 9 + + + 9 + + + 9 + + + + + + 0 + 0 + + + + Reset all values to GCS defaults - Roll + Default - - Qt::AlignCenter + + + objname:StabilizationSettings + button:default + buttongroup:6 + - - + + Qt::Horizontal @@ -5549,6 +6728,1974 @@ border-radius: 5; + + + + QGroupBox{border: 0px;} + + + + + + true + + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 14 + 200 + 14 + + + + + 6 + 150 + 6 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 14 + 200 + 14 + + + + + 6 + 150 + 6 + + + + + + + + + + + 14 + 200 + 14 + + + + + 6 + 150 + 6 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 14 + 200 + 14 + + + + + 6 + 150 + 6 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 14 + 200 + 14 + + + + + 6 + 150 + 6 + + + + + + + + + + + 14 + 200 + 14 + + + + + 6 + 150 + 6 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 14 + 200 + 14 + + + + + 6 + 150 + 6 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 14 + 200 + 14 + + + + + 6 + 150 + 6 + + + + + + + + + + + 14 + 200 + 14 + + + + + 6 + 150 + 6 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + This thing really can preform, it is a lot more responsive this way + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(14, 200, 14, 255), stop:0.78607 rgba(6, 150, 6 , 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Snappy + + + Qt::AlignCenter + + + + + + + + 50 + 22 + + + + + 50 + 22 + + + + 10 + + + 180 + + + 83 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:RollMax + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + <html><head/><body><p>The Rate mode slider can be adjusted to value ranges whose responsiveness is represented by the Moderate / Snappy / Insane bar</p></body></html> + + + 100 + + + 800 + + + 400 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 25 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:ManualRate + element:Roll + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 50 + 22 + + + + + 50 + 22 + + + + 100 + + + 800 + + + 400 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:ManualRate + element:Roll + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + Lazy Sunday afternoon flying, fly's nice and stable + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(34, 34, 200, 255), stop:0.78607 rgba(6, 6, 150, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Moderate + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 200 + 14 + 14 + + + + + 160 + 6 + 6 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 200 + 14 + 14 + + + + + 160 + 6 + 6 + + + + + + + + + + + 200 + 14 + 14 + + + + + 160 + 6 + 6 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 200 + 14 + 14 + + + + + 160 + 6 + 6 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 200 + 14 + 14 + + + + + 160 + 6 + 6 + + + + + + + + + + + 200 + 14 + 14 + + + + + 160 + 6 + 6 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 200 + 14 + 14 + + + + + 160 + 6 + 6 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 200 + 14 + 14 + + + + + 160 + 6 + 6 + + + + + + + + + + + 200 + 14 + 14 + + + + + 160 + 6 + 6 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + Damn this is insane how quick it moves. Mostly used by the Pro's + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(200, 14, 14, 255), stop:0.78607 rgba(160 , 6, 6 , 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Insane + + + Qt::AlignCenter + + + + + + + + 78 + 16 + + + + Attitude mode + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 78 + 16 + + + + Rate mode + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + <html><head/><body><p>The Attitude Mode slider can be adjusted to value ranges whose responsivness is represented by the Moderate / Snappy / Insane bar</p></body></html> + + + 10 + + + 180 + + + 1 + + + 83 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 25 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:RollMax + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + <html><head/><body><p>The Rate mode Yaw slider can be adjusted to value ranges whose responsiveness is represented by the Moderate / Snappy / Insane bar</p></body></html> + + + 100 + + + 800 + + + 400 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 25 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:ManualRate + element:Yaw + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + + 78 + 16 + + + + Rate mode yaw + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 50 + 22 + + + + + 50 + 22 + + + + 100 + + + 800 + + + 400 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:ManualRate + element:Yaw + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + @@ -5556,3084 +8703,20 @@ border-radius: 5; - - - - 0 - 0 - + + + Qt::Vertical - + + QSizePolicy::Fixed + + - 0 - 0 + 20 + 9 - - - 16777215 - 195 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 0 - 0 - 0 - - - - - - - 251 - 251 - 251 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 0 - 0 - 0 - - - - - - - 251 - 251 - 251 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 124 - 124 - 124 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 124 - 124 - 124 - - - - - - - 255 - 255 - 255 - - - - - - - 124 - 124 - 124 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 0 - 0 - 0 - - - - - - - 248 - 248 - 248 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - false - - - Attitude Stabilization (Outer Loop) - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - 9 - - - 9 - - - 9 - - - 9 - - - 6 - - - - - - 0 - 0 - - - - Qt::StrongFocus - - - <html><head/><body><p>Link roll &amp; pitch sliders to move together, thus giving same value for both roll &amp; pitch when setting up a symetrical vehicle that requires both to be the same.</p></body></html> - - - - - - Link Roll and Pitch - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 497 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Reset all values to GCS defaults - - - - - - Default - - - - button:default - buttongroup:2 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 251 - 251 - 251 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 251 - 251 - 251 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 124 - 124 - 124 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 124 - 124 - 124 - - - - - - - 255 - 255 - 255 - - - - - - - 124 - 124 - 124 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 248 - 248 - 248 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - false - - - QGroupBox{border: 0px;} - - - - - - true - - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Roll - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Pitch - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Yaw - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 78 - 16 - - - - - - - Proportional - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much leveling stability is set into Attitude mode (outer loop). Too much will make your vehicle oscillate in Attitude Mode.</p></body></html> - - - - - - 100 - - - 50 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 25 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:RollPI - element:Kp - scale:0.1 - haslimits:yes - buttongroup:2,10 - - - - - - - - - 50 - 22 - - - - - 50 - 22 - - - - Qt::StrongFocus - - - 200 - - - 200 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:RollPI - element:Kp - scale:0.1 - haslimits:yes - buttongroup:2,10 - - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much leveling stability is set into Attitude mode (outer loop). Too much will make your vehicle oscillate in Attitude Mode.</p></body></html> - - - - - - 100 - - - 50 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 25 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:PitchPI - element:Kp - scale:0.1 - haslimits:yes - buttongroup:2,10 - - - - - - - - - 50 - 22 - - - - - 50 - 22 - - - - Qt::StrongFocus - - - 200 - - - 200 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:PitchPI - element:Kp - scale:0.1 - haslimits:yes - buttongroup:2,10 - - - - - - - - - 0 - 0 - - - - - 0 - 25 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much leveling stability is set into Attitude mode (outer loop). Too much will make your vehicle oscillate in Attitude Mode.</p></body></html> - - - - - - 100 - - - 50 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 25 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:YawPI - element:Kp - scale:0.1 - haslimits:yes - buttongroup:2,10 - - - - - - - - - 50 - 22 - - - - - 50 - 22 - - - - Qt::StrongFocus - - - 200 - - - 200 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:YawPI - element:Kp - scale:0.1 - haslimits:yes - buttongroup:2,10 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 1 - - - - - - - - - + @@ -8766,6 +8849,8 @@ border-radius: 5; + pidBankFrame + tabWidget_2 @@ -8868,8 +8953,8 @@ border-radius: 5; 0 0 - 779 - 684 + 796 + 708 @@ -18909,7 +18994,7 @@ border-radius: 5; 0 0 796 - 659 + 708 @@ -27022,7 +27107,7 @@ border-radius: 5; 0 0 796 - 659 + 708 From 99cfa5339d8e6ecc561e0f8bd6e422b6c9fc726f Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Tue, 7 Jan 2014 23:04:32 +0100 Subject: [PATCH 33/45] OP-984 UI changes. Added TabBars to visually simulate PID bank change. --- .../config/configstabilizationwidget.cpp | 18 + .../config/configstabilizationwidget.h | 4 + .../src/plugins/config/stabilization.ui | 26582 ++++++++-------- 3 files changed, 13355 insertions(+), 13249 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp index e27b8542c..a6d8149f5 100644 --- a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -46,6 +47,16 @@ ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTa ui = new Ui_StabilizationWidget(); ui->setupUi(this); + m_pidTabBars.append(ui->basicPIDBankTabBar); + m_pidTabBars.append(ui->advancedPIDBankTabBar); + m_pidTabBars.append(ui->expertPIDBankTabBar); + foreach(QTabBar * tabBar, m_pidTabBars) { + for (int i = 1; i <= PID_BANKS; i++) { + tabBar->addTab(tr("PID Bank %1").arg(i)); + } + tabBar->setExpanding(false); + connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(pidBankChanged(int))); + } ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); Core::Internal::GeneralSettings *settings = pm->getObject(); @@ -205,6 +216,13 @@ void ConfigStabilizationWidget::onBoardConnected() ui->AltitudeHold->setEnabled((boardModel & 0xff00) == 0x0900); } +void ConfigStabilizationWidget::pidBankChanged(int index) +{ + foreach(QTabBar * tabBar, m_pidTabBars) { + tabBar->setCurrentIndex(index); + } +} + bool ConfigStabilizationWidget::shouldObjectBeSaved(UAVObject *object) { // AltitudeHoldSettings should only be saved for Revolution board to avoid error. diff --git a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h index f6b26a76e..e7944f382 100644 --- a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h @@ -48,10 +48,13 @@ public: private: Ui_StabilizationWidget *ui; QTimer *realtimeUpdates; + QList m_pidTabBars; // Milliseconds between automatic 'Instant Updates' static const int AUTOMATIC_UPDATE_RATE = 500; + static const int PID_BANKS = 3; + int boardModel; protected slots: @@ -62,6 +65,7 @@ private slots: void linkCheckBoxes(bool value); void processLinkedWidgets(QWidget *); void onBoardConnected(); + void pidBankChanged(int index); }; #endif // ConfigStabilizationWidget_H diff --git a/ground/openpilotgcs/src/plugins/config/stabilization.ui b/ground/openpilotgcs/src/plugins/config/stabilization.ui index 0d708d8c2..ec604645e 100644 --- a/ground/openpilotgcs/src/plugins/config/stabilization.ui +++ b/ground/openpilotgcs/src/plugins/config/stabilization.ui @@ -648,55 +648,15 @@ 9 - - - - 0 - 0 - - - - - 16777215 - 21 - - - - border-bottom: 0px - - - QTabWidget::Rounded - - - 0 - - - true - - - - PID Bank 1 - - - - - PID Bank 2 - - - - - PID Bank 3 - - - + - + ArrowCursor - #pidBankFrame{ + #basicPidBankFrame{ color: rgb(180, 180, 180); margin-top: -1px } @@ -708,6 +668,2046 @@ margin-top: -1px QFrame::Plain + + + + + + + + + + Responsiveness + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + false + + + true + + + + 9 + + + 9 + + + 9 + + + 9 + + + + + + 0 + 0 + + + + Reset all values to GCS defaults + + + Default + + + + objname:StabilizationSettings + button:default + buttongroup:6 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QGroupBox{border: 0px;} + + + + + + true + + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 14 + 200 + 14 + + + + + 6 + 150 + 6 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 14 + 200 + 14 + + + + + 6 + 150 + 6 + + + + + + + + + + + 14 + 200 + 14 + + + + + 6 + 150 + 6 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 14 + 200 + 14 + + + + + 6 + 150 + 6 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 14 + 200 + 14 + + + + + 6 + 150 + 6 + + + + + + + + + + + 14 + 200 + 14 + + + + + 6 + 150 + 6 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 14 + 200 + 14 + + + + + 6 + 150 + 6 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 14 + 200 + 14 + + + + + 6 + 150 + 6 + + + + + + + + + + + 14 + 200 + 14 + + + + + 6 + 150 + 6 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + This thing really can preform, it is a lot more responsive this way + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(14, 200, 14, 255), stop:0.78607 rgba(6, 150, 6 , 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Snappy + + + Qt::AlignCenter + + + + + + + + 50 + 22 + + + + + 50 + 22 + + + + 10 + + + 180 + + + 83 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:RollMax + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + <html><head/><body><p>The Rate mode slider can be adjusted to value ranges whose responsiveness is represented by the Moderate / Snappy / Insane bar</p></body></html> + + + 100 + + + 800 + + + 400 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 25 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:ManualRate + element:Roll + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 50 + 22 + + + + + 50 + 22 + + + + 100 + + + 800 + + + 400 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:ManualRate + element:Roll + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + + + 34 + 34 + 200 + + + + + 6 + 6 + 150 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + Lazy Sunday afternoon flying, fly's nice and stable + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(34, 34, 200, 255), stop:0.78607 rgba(6, 6, 150, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Moderate + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 200 + 14 + 14 + + + + + 160 + 6 + 6 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 200 + 14 + 14 + + + + + 160 + 6 + 6 + + + + + + + + + + + 200 + 14 + 14 + + + + + 160 + 6 + 6 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 200 + 14 + 14 + + + + + 160 + 6 + 6 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 200 + 14 + 14 + + + + + 160 + 6 + 6 + + + + + + + + + + + 200 + 14 + 14 + + + + + 160 + 6 + 6 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 200 + 14 + 14 + + + + + 160 + 6 + 6 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 200 + 14 + 14 + + + + + 160 + 6 + 6 + + + + + + + + + + + 200 + 14 + 14 + + + + + 160 + 6 + 6 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + Damn this is insane how quick it moves. Mostly used by the Pro's + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(200, 14, 14, 255), stop:0.78607 rgba(160 , 6, 6 , 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Insane + + + Qt::AlignCenter + + + + + + + + 78 + 16 + + + + Attitude mode + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 78 + 16 + + + + Rate mode + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + <html><head/><body><p>The Attitude Mode slider can be adjusted to value ranges whose responsivness is represented by the Moderate / Snappy / Insane bar</p></body></html> + + + 10 + + + 180 + + + 1 + + + 83 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 25 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:RollMax + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + <html><head/><body><p>The Rate mode Yaw slider can be adjusted to value ranges whose responsiveness is represented by the Moderate / Snappy / Insane bar</p></body></html> + + + 100 + + + 800 + + + 400 + + + Qt::Horizontal + + + QSlider::TicksBelow + + + 25 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:ManualRate + element:Yaw + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + + 78 + 16 + + + + Rate mode yaw + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 50 + 22 + + + + + 50 + 22 + + + + 100 + + + 800 + + + 400 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:ManualRate + element:Yaw + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + + + @@ -753,84 +2753,6 @@ margin-top: -1px 6 - - - - - 0 - 0 - - - - Qt::StrongFocus - - - <html><head/><body><p>Link roll &amp; pitch sliders to move together, thus giving same value for both roll &amp; pitch when setting up a symetrical vehicle that requires both to be the same</p></body></html> - - - - - - Link Roll and Pitch - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 497 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Reset all values to GCS defaults - - - false - - - - - - Default - - - - button:default - buttongroup:1 - - - - @@ -3576,6 +5498,84 @@ border-radius: 5; + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 497 + 20 + + + + + + + + + 0 + 0 + + + + Qt::StrongFocus + + + <html><head/><body><p>Link roll &amp; pitch sliders to move together, thus giving same value for both roll &amp; pitch when setting up a symetrical vehicle that requires both to be the same</p></body></html> + + + + + + Link Roll and Pitch + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Reset all values to GCS defaults + + + false + + + + + + Default + + + + button:default + buttongroup:1 + + + + @@ -6659,2046 +8659,6 @@ border-radius: 5; - - - - - - - - - - Responsiveness - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - true - - - - 9 - - - 9 - - - 9 - - - 9 - - - - - - 0 - 0 - - - - Reset all values to GCS defaults - - - Default - - - - objname:StabilizationSettings - button:default - buttongroup:6 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QGroupBox{border: 0px;} - - - - - - true - - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 14 - 200 - 14 - - - - - 6 - 150 - 6 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 14 - 200 - 14 - - - - - 6 - 150 - 6 - - - - - - - - - - - 14 - 200 - 14 - - - - - 6 - 150 - 6 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 14 - 200 - 14 - - - - - 6 - 150 - 6 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 14 - 200 - 14 - - - - - 6 - 150 - 6 - - - - - - - - - - - 14 - 200 - 14 - - - - - 6 - 150 - 6 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 14 - 200 - 14 - - - - - 6 - 150 - 6 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 14 - 200 - 14 - - - - - 6 - 150 - 6 - - - - - - - - - - - 14 - 200 - 14 - - - - - 6 - 150 - 6 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - This thing really can preform, it is a lot more responsive this way - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(14, 200, 14, 255), stop:0.78607 rgba(6, 150, 6 , 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Snappy - - - Qt::AlignCenter - - - - - - - - 50 - 22 - - - - - 50 - 22 - - - - 10 - - - 180 - - - 83 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:RollMax - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - <html><head/><body><p>The Rate mode slider can be adjusted to value ranges whose responsiveness is represented by the Moderate / Snappy / Insane bar</p></body></html> - - - 100 - - - 800 - - - 400 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 25 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:ManualRate - element:Roll - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 50 - 22 - - - - - 50 - 22 - - - - 100 - - - 800 - - - 400 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:ManualRate - element:Roll - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - - - 34 - 34 - 200 - - - - - 6 - 6 - 150 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - Lazy Sunday afternoon flying, fly's nice and stable - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(34, 34, 200, 255), stop:0.78607 rgba(6, 6, 150, 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Moderate - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 200 - 14 - 14 - - - - - 160 - 6 - 6 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 200 - 14 - 14 - - - - - 160 - 6 - 6 - - - - - - - - - - - 200 - 14 - 14 - - - - - 160 - 6 - 6 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 200 - 14 - 14 - - - - - 160 - 6 - 6 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 200 - 14 - 14 - - - - - 160 - 6 - 6 - - - - - - - - - - - 200 - 14 - 14 - - - - - 160 - 6 - 6 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 200 - 14 - 14 - - - - - 160 - 6 - 6 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 200 - 14 - 14 - - - - - 160 - 6 - 6 - - - - - - - - - - - 200 - 14 - 14 - - - - - 160 - 6 - 6 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - Damn this is insane how quick it moves. Mostly used by the Pro's - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(200, 14, 14, 255), stop:0.78607 rgba(160 , 6, 6 , 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Insane - - - Qt::AlignCenter - - - - - - - - 78 - 16 - - - - Attitude mode - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 78 - 16 - - - - Rate mode - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - <html><head/><body><p>The Attitude Mode slider can be adjusted to value ranges whose responsivness is represented by the Moderate / Snappy / Insane bar</p></body></html> - - - 10 - - - 180 - - - 1 - - - 83 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 25 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:RollMax - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - <html><head/><body><p>The Rate mode Yaw slider can be adjusted to value ranges whose responsiveness is represented by the Moderate / Snappy / Insane bar</p></body></html> - - - 100 - - - 800 - - - 400 - - - Qt::Horizontal - - - QSlider::TicksBelow - - - 25 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:ManualRate - element:Yaw - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - - 78 - 16 - - - - Rate mode yaw - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 50 - 22 - - - - - 50 - 22 - - - - 100 - - - 800 - - - 400 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:ManualRate - element:Yaw - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - - - @@ -8849,8 +8809,6 @@ border-radius: 5; - pidBankFrame - tabWidget_2 @@ -8961,588 +8919,31 @@ border-radius: 5; true + + 0 + - - - - 0 - 0 - + + + + + + #advancedPidBankFrame{ + color: rgb(180, 180, 180); + margin-top: -1px; +} - - - 0 - 0 - + + QFrame::Box - - - 16777215 - 16777215 - + + QFrame::Plain - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 0 - 0 - 0 - - - - - - - 251 - 251 - 251 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 0 - 0 - 0 - - - - - - - 251 - 251 - 251 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 124 - 124 - 124 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 124 - 124 - 124 - - - - - - - 255 - 255 - 255 - - - - - - - 124 - 124 - 124 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 0 - 0 - 0 - - - - - - - 248 - 248 - 248 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - Responsiveness - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - false - - - - 9 - - - 9 - - - 9 - - - 9 - - - 6 - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 632 - 20 - - - - - - + + + - + 0 0 @@ -9559,38 +8960,6 @@ border-radius: 5; 16777215 - - Reset all values to GCS defaults - - - - - - Default - - - - objname:StabilizationSettings - button:default - buttongroup:6 - - - - - - - - - 0 - 0 - - - - - 0 - 140 - - @@ -9604,12 +8973,23 @@ border-radius: 5; - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + @@ -9676,21 +9056,43 @@ border-radius: 5; - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + @@ -9741,12 +9143,23 @@ border-radius: 5; - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + @@ -9813,21 +9226,43 @@ border-radius: 5; - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + @@ -9878,12 +9313,23 @@ border-radius: 5; - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + @@ -9950,21 +9396,43 @@ border-radius: 5; - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + @@ -10006,4770 +9474,61 @@ border-radius: 5; - - false - - - QGroupBox{border: 0px;} - - + Rate Stabilization (Inner Loop) + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - true + false - + - 0 + 9 + + + 9 - 0 + 9 - 0 + 9 - - 0 + + 6 - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This sets the maximum deg your vehicle will tilt at full stick input when in Attitude mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 0 - - - 180.000000000000000 - - - 1.000000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:PitchMax - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - - 0 - 0 - - - - - 128 - 16 - - - - - 16777215 - 16777215 - - - - - - - Max rate attitude (deg/s) - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This sets the maximum rotation rate in degrees per second on an axis.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 0 - - - 1000000.000000000000000 - - - 1.000000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:MaximumRate - element:Roll - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 10 - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This sets the degrees per second that your vehicle will tilt/rotate at full stick input when in all modes except Attitude.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 0 - - - 1000000.000000000000000 - - - 1.000000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:ManualRate - element:Yaw - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This sets the maximum deg your vehicle will tilt at full stick input when in Attitude mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 0 - - - 180.000000000000000 - - - 1.000000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:YawMax - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This sets the maximum rotation rate in degrees per second on an axis.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 0 - - - 1000000.000000000000000 - - - 1.000000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:MaximumRate - element:Pitch - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Yaw - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 10 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 10 - - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Pitch - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 69 - 16 - - - - - - - Attitude mode response (deg) - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This sets the degrees per second that your vehicle will tilt/rotate at full stick input when in all modes except Attitude.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 0 - - - 1000000.000000000000000 - - - 1.000000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:ManualRate - element:Pitch - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 140 - 16 - - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Roll - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This sets the degrees per second that your vehicle will tilt/rotate at full stick input when in all modes except Attitude.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 0 - - - 1000000.000000000000000 - - - 1.000000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:ManualRate - element:Roll - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This sets the maximum deg your vehicle will tilt at full stick input when in Attitude mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - QAbstractSpinBox::UpDownArrows - - - 0 - - - 180.000000000000000 - - - 1.000000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:RollMax - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This sets the maximum rotation rate in degrees per second on an axis.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 0 - - - 1000000.000000000000000 - - - 1.000000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:MaximumRate - element:Yaw - haslimits:no - scale:1 - buttongroup:6,20 - - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - Rate mode response (deg/s) - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - + + Qt::Horizontal - 20 + 497 20 - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 0 - 0 - 0 - - - - - - - 251 - 251 - 251 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 0 - 0 - 0 - - - - - - - 251 - 251 - 251 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 124 - 124 - 124 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 124 - 124 - 124 - - - - - - - 255 - 255 - 255 - - - - - - - 124 - 124 - 124 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 0 - 0 - 0 - - - - - - - 248 - 248 - 248 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - Rate Stabilization (Inner Loop) - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - 9 - - - 9 - - - 9 - - - 9 - - - 6 - - - - - Qt::Horizontal - - - - 497 - 20 - - - - - - - - <html><head/><body><p>Link roll &amp; pitch values together, thus giving the same value for each when setting up a symetrical vehicle that requires both to be the same.</p></body></html> - - - - - - Link Roll and Pitch - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Reset all values to GCS defaults - - - - - - Default - - - - objname:StabilizationSettings - button:default - buttongroup:4 - - - - - - - - - 0 - 0 - - - - - 0 - 140 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 251 - 251 - 251 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 251 - 251 - 251 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 124 - 124 - 124 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 124 - 124 - 124 - - - - - - - 255 - 255 - 255 - - - - - - - 124 - 124 - 124 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 248 - 248 - 248 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - false - - - QGroupBox{border: 0px;} - - - - - - true - - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - + + - <html><head/><body><p>This - makes the control output respond faster with fast stick movements or external disturbance like wind gusts. It also acts like a dampener, thus allowing higher KP settings. Only affects Rate mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 6 - - - 0.000001000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:PitchRatePID - element:Kd - haslimits:no - scale:1 - buttongroup:4,20 - - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Yaw - - - Qt::AlignCenter - - - - - - - - 0 - 0 - + <html><head/><body><p>Link roll &amp; pitch values together, thus giving the same value for each when setting up a symetrical vehicle that requires both to be the same.</p></body></html> - Integral - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Rate mode. A good starting point for Integral is the same as Proportional.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 5 - - - 0.000100000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:YawRatePID - element:Ki - haslimits:no - scale:1 - buttongroup:4,20 - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Rate mode. A good starting point for Integral is the same as Proportional.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 5 - - - 0.000100000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:PitchRatePID - element:Ki - haslimits:no - scale:1 - buttongroup:4,20 - - - - - - - - - 0 - 0 - - - - - 85 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much leveling stability is set into Rate mode (inner loop). Too much will make your vehicle oscillate in Rate mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 5 - - - 0.000100000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:YawRatePID - element:Kp - haslimits:no - scale:1 - buttongroup:4,20 - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This makes the control output respond faster with fast stick movements or external disturbance like wind gusts. It also acts like a dampener, thus allowing higher KP settings. Only affects Rate mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 6 - - - 0.000001000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:YawRatePID - element:Kd - haslimits:no - scale:1 - buttongroup:4,20 - - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Pitch - - - Qt::AlignCenter + Link Roll and Pitch - + - + 0 0 @@ -14777,729 +9536,6 @@ border-radius: 5; 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Roll - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 10 - - - - - - - - - 0 - 0 - - - - - 69 - 16 - - - - - - - Proportional - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 10 - - - - - - - - - 0 - 0 - - - - - 85 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much leveling stability is set into Rate mode (inner loop). Too much will make your vehicle oscillate in Rate mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 5 - - - 0.000100000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:RollRatePID - element:Kp - haslimits:no - scale:1 - buttongroup:4,20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 140 - 13 - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Rate mode. A good starting point for Integral is the same as Proportional.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 5 - - - 0.000100000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:RollRatePID - element:Ki - haslimits:no - scale:1 - buttongroup:4,20 - - - - - - - - - 0 - 0 - - - - - 58 0 @@ -15509,69 +9545,26 @@ border-radius: 5; 16777215 + + Reset all values to GCS defaults + - Derivative - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 85 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much leveling stability is set into Rate mode (inner loop). Too much will make your vehicle oscillate in Rate mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 5 - - - 0.000100000000000 + Default - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:PitchRatePID - element:Kp - haslimits:no - scale:1 - buttongroup:4,20 + objname:StabilizationSettings + button:default + buttongroup:4 - - + + 0 @@ -15581,672 +9574,2709 @@ border-radius: 5; 0 - 22 + 140 - - - 16777215 - 22 - + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 251 + 251 + 251 + + + + + + + 124 + 124 + 124 + + + + + + + 165 + 165 + 165 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 251 + 251 + 251 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 251 + 251 + 251 + + + + + + + 124 + 124 + 124 + + + + + + + 165 + 165 + 165 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 251 + 251 + 251 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 124 + 124 + 124 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 251 + 251 + 251 + + + + + + + 124 + 124 + 124 + + + + + + + 165 + 165 + 165 + + + + + + + 124 + 124 + 124 + + + + + + + 255 + 255 + 255 + + + + + + + 124 + 124 + 124 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 248 + 248 + 248 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + - - Qt::StrongFocus - - - <html><head/><body><p>This makes the control output respond faster with fast stick movements or external disturbance like wind gusts.It also acts like a dampener, thus allowing higher KP settings. Only affects Rate mode.</p></body></html> + + false - + QGroupBox{border: 0px;} - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + - - 6 - - - 0.000001000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:RollRatePID - element:Kd - haslimits:no - scale:1 - buttongroup:4,20 - + + true + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This + makes the control output respond faster with fast stick movements or external disturbance like wind gusts. It also acts like a dampener, thus allowing higher KP settings. Only affects Rate mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 6 + + + 0.000001000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:PitchRatePID + element:Kd + haslimits:no + scale:1 + buttongroup:4,20 + + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Yaw + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + + + Integral + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Rate mode. A good starting point for Integral is the same as Proportional.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 5 + + + 0.000100000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:YawRatePID + element:Ki + haslimits:no + scale:1 + buttongroup:4,20 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Rate mode. A good starting point for Integral is the same as Proportional.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 5 + + + 0.000100000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:PitchRatePID + element:Ki + haslimits:no + scale:1 + buttongroup:4,20 + + + + + + + + + 0 + 0 + + + + + 85 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much leveling stability is set into Rate mode (inner loop). Too much will make your vehicle oscillate in Rate mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 5 + + + 0.000100000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:YawRatePID + element:Kp + haslimits:no + scale:1 + buttongroup:4,20 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This makes the control output respond faster with fast stick movements or external disturbance like wind gusts. It also acts like a dampener, thus allowing higher KP settings. Only affects Rate mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 6 + + + 0.000001000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:YawRatePID + element:Kd + haslimits:no + scale:1 + buttongroup:4,20 + + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Pitch + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Roll + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 10 + + + + + + + + + 0 + 0 + + + + + 69 + 16 + + + + + + + Proportional + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 10 + + + + + + + + + 0 + 0 + + + + + 85 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much leveling stability is set into Rate mode (inner loop). Too much will make your vehicle oscillate in Rate mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 5 + + + 0.000100000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:RollRatePID + element:Kp + haslimits:no + scale:1 + buttongroup:4,20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 140 + 13 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Rate mode. A good starting point for Integral is the same as Proportional.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 5 + + + 0.000100000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:RollRatePID + element:Ki + haslimits:no + scale:1 + buttongroup:4,20 + + + + + + + + + 0 + 0 + + + + + 58 + 0 + + + + + 16777215 + 16777215 + + + + + + + Derivative + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 85 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much leveling stability is set into Rate mode (inner loop). Too much will make your vehicle oscillate in Rate mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 5 + + + 0.000100000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:PitchRatePID + element:Kp + haslimits:no + scale:1 + buttongroup:4,20 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This makes the control output respond faster with fast stick movements or external disturbance like wind gusts.It also acts like a dampener, thus allowing higher KP settings. Only affects Rate mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 6 + + + 0.000001000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:RollRatePID + element:Kd + haslimits:no + scale:1 + buttongroup:4,20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 10 + + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 10 - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 0 - 0 - 0 - - - - - - - 251 - 251 - 251 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 0 - 0 - 0 - - - - - - - 251 - 251 - 251 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 124 - 124 - 124 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 124 - 124 - 124 - - - - - - - 255 - 255 - 255 - - - - - - - 124 - 124 - 124 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 0 - 0 - 0 - - - - - - - 248 - 248 - 248 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - false - - - Attitude Stabilization (Outer Loop) - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - 9 - - - 9 - - - 9 - - - 9 - - - 4 - - - - - <html><head/><body><p>Link roll &amp; pitch values together, thus giving the same value for each when setting up a symetrical vehicle that requires both to be the same.</p></body></html> - - - - - - Link Roll and Pitch - - - - - - - Qt::Horizontal - - - - 497 - 20 - - - - - - + + - + 0 0 @@ -16263,38 +12293,6 @@ border-radius: 5; 16777215 - - Reset all values to GCS defaults - - - - - - Default - - - - objname:StabilizationSettings - button:default - buttongroup:5 - - - - - - - - - 0 - 0 - - - - - 0 - 110 - - @@ -16308,12 +12306,23 @@ border-radius: 5; - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + @@ -16380,21 +12389,43 @@ border-radius: 5; - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + @@ -16445,12 +12476,23 @@ border-radius: 5; - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + @@ -16517,21 +12559,43 @@ border-radius: 5; - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + @@ -16582,12 +12646,23 @@ border-radius: 5; - - - 0 - 0 - 0 - + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + @@ -16654,23 +12729,3406 @@ border-radius: 5; + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + + + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + + - + 0 0 0 - + - + + 248 + 248 + 248 + + + + + + + 255 + 255 + 220 + + + + + + 0 0 0 + + + + + Responsiveness + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + false + + + + 9 + + + 9 + + + 9 + + + 9 + + + 6 + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 632 + 20 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Reset all values to GCS defaults + + + + + + Default + + + + objname:StabilizationSettings + button:default + buttongroup:6 + + + + + + + + + 0 + 0 + + + + + 0 + 140 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 251 + 251 + 251 + + + + + + + 124 + 124 + 124 + + + + + + + 165 + 165 + 165 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 251 + 251 + 251 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 251 + 251 + 251 + + + + + + + 124 + 124 + 124 + + + + + + + 165 + 165 + 165 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 251 + 251 + 251 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 124 + 124 + 124 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 251 + 251 + 251 + + + + + + + 124 + 124 + 124 + + + + + + + 165 + 165 + 165 + + + + + + + 124 + 124 + 124 + + + + + + + 255 + 255 + 255 + + + + + + + 124 + 124 + 124 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 248 + 248 + 248 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + false + + + QGroupBox{border: 0px;} + + + + + + true + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This sets the maximum deg your vehicle will tilt at full stick input when in Attitude mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 0 + + + 180.000000000000000 + + + 1.000000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:PitchMax + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + + 0 + 0 + + + + + 128 + 16 + + + + + 16777215 + 16777215 + + + + + + + Max rate attitude (deg/s) + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This sets the maximum rotation rate in degrees per second on an axis.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 0 + + + 1000000.000000000000000 + + + 1.000000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:MaximumRate + element:Roll + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 10 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This sets the degrees per second that your vehicle will tilt/rotate at full stick input when in all modes except Attitude.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 0 + + + 1000000.000000000000000 + + + 1.000000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:ManualRate + element:Yaw + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This sets the maximum deg your vehicle will tilt at full stick input when in Attitude mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 0 + + + 180.000000000000000 + + + 1.000000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:YawMax + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This sets the maximum rotation rate in degrees per second on an axis.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 0 + + + 1000000.000000000000000 + + + 1.000000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:MaximumRate + element:Pitch + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Yaw + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 10 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 10 + + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Pitch + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 69 + 16 + + + + + + + Attitude mode response (deg) + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This sets the degrees per second that your vehicle will tilt/rotate at full stick input when in all modes except Attitude.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 0 + + + 1000000.000000000000000 + + + 1.000000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:ManualRate + element:Pitch + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 140 + 16 + + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Roll + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This sets the degrees per second that your vehicle will tilt/rotate at full stick input when in all modes except Attitude.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 0 + + + 1000000.000000000000000 + + + 1.000000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:ManualRate + element:Roll + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This sets the maximum deg your vehicle will tilt at full stick input when in Attitude mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + QAbstractSpinBox::UpDownArrows + + + 0 + + + 180.000000000000000 + + + 1.000000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:RollMax + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This sets the maximum rotation rate in degrees per second on an axis.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 0 + + + 1000000.000000000000000 + + + 1.000000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:MaximumRate + element:Yaw + haslimits:no + scale:1 + buttongroup:6,20 + + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + Rate mode response (deg/s) + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + + + + + 0 + 0 + 0 + + + + + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + + + + + 255 + 255 + 255 + + + + + + + 251 + 251 + 251 + + + + + + + 124 + 124 + 124 + + + + + + + 165 + 165 + 165 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + + + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + + + + + 0 + 0 + 0 + + + + + + + 251 + 251 + 251 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + + + + + 255 + 255 + 255 + + + + + + + 251 + 251 + 251 + + + + + + + 124 + 124 + 124 + + + + + + + 165 + 165 + 165 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + + + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + + + + + 0 + 0 + 0 + + + + + + + 251 + 251 + 251 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 124 + 124 + 124 + + + + + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + + + + + 255 + 255 + 255 + + + + + + + 251 + 251 + 251 + + + + + + + 124 + 124 + 124 + + + + + + + 165 + 165 + 165 + + + + + + + 124 + 124 + 124 + + + + + + + 255 + 255 + 255 + + + + + + + 124 + 124 + 124 + + + + + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + + + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + @@ -16713,43 +16171,97 @@ border-radius: 5; false - - QGroupBox{border: 0px;} - - + Attitude Stabilization (Outer Loop) + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - true + false - + - 0 + 9 + + + 9 - 0 + 9 - 0 + 9 + + + 4 - + + + <html><head/><body><p>Link roll &amp; pitch values together, thus giving the same value for each when setting up a symetrical vehicle that requires both to be the same.</p></body></html> + + + + + + Link Roll and Pitch + + + + + Qt::Horizontal - - QSizePolicy::Fixed - - 137 - 13 + 497 + 20 - + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Reset all values to GCS defaults + + + + + + Default + + + + objname:StabilizationSettings + button:default + buttongroup:5 + + + + + + 0 @@ -16759,7 +16271,7 @@ border-radius: 5; 0 - 16 + 110 @@ -16768,74 +16280,63 @@ border-radius: 5; - 255 - 255 - 255 + 0 + 0 + 0 - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - + + + 0 + 0 + 0 + - 58 - 58 - 58 + 255 + 255 + 255 - 48 - 48 - 48 + 251 + 251 + 251 - 19 - 19 - 19 + 124 + 124 + 124 - 26 - 26 - 26 + 165 + 165 + 165 - 255 - 255 - 255 + 0 + 0 + 0 @@ -16851,50 +16352,28 @@ border-radius: 5; - 255 - 255 - 255 + 0 + 0 + 0 - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - + + + 0 + 0 + 0 + - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - + + + 0 + 0 + 0 + @@ -16909,9 +16388,9 @@ border-radius: 5; - 19 - 19 - 19 + 251 + 251 + 251 @@ -16938,74 +16417,63 @@ border-radius: 5; - 255 - 255 - 255 + 0 + 0 + 0 - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - + + + 0 + 0 + 0 + - 58 - 58 - 58 + 255 + 255 + 255 - 48 - 48 - 48 + 251 + 251 + 251 - 19 - 19 - 19 + 124 + 124 + 124 - 26 - 26 - 26 + 165 + 165 + 165 - 255 - 255 - 255 + 0 + 0 + 0 @@ -17021,50 +16489,28 @@ border-radius: 5; - 255 - 255 - 255 + 0 + 0 + 0 - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - + + + 0 + 0 + 0 + - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - + + + 0 + 0 + 0 + @@ -17079,9 +16525,9 @@ border-radius: 5; - 19 - 19 - 19 + 251 + 251 + 251 @@ -17108,74 +16554,63 @@ border-radius: 5; - 255 - 255 - 255 + 124 + 124 + 124 - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - + + + 0 + 0 + 0 + - 58 - 58 - 58 + 255 + 255 + 255 - 48 - 48 - 48 + 251 + 251 + 251 - 19 - 19 - 19 + 124 + 124 + 124 - 26 - 26 - 26 + 165 + 165 + 165 - 255 - 255 - 255 + 124 + 124 + 124 @@ -17191,50 +16626,28 @@ border-radius: 5; - 255 - 255 - 255 + 124 + 124 + 124 - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - + + + 0 + 0 + 0 + - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - + + + 0 + 0 + 0 + @@ -17249,9 +16662,9 @@ border-radius: 5; - 39 - 39 - 39 + 248 + 248 + 248 @@ -17276,1539 +16689,2124 @@ border-radius: 5; - - - 75 - true - - false - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); + QGroupBox{border: 0px;} + + + + + + true + + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 137 + 13 + + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); color: rgb(255, 255, 255); border-radius: 5; - - - Roll - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); + + + Roll + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); color: rgb(255, 255, 255); border-radius: 5; - - - Pitch - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); + + + Pitch + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); color: rgb(255, 255, 255); border-radius: 5; - - - Yaw - - - Qt::AlignCenter - + + + Yaw + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 69 + 16 + + + + + + + Proportional + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much leveling stability is set into Attitude mode (outer loop). Too much will make your vehicle oscillate in Attitude Mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 3 + + + 0.100000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:RollPI + element:Kp + haslimits:no + scale:1 + buttongroup:5,20 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much leveling stability is set into Attitude mode (outer loop). Too much will make your vehicle oscillate in Attitude Mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 3 + + + 0.100000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:PitchPI + element:Kp + haslimits:no + scale:1 + buttongroup:5,20 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much leveling stability is set into Attitude mode (outer loop). Too much will make your vehicle oscillate in Attitude Mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 3 + + + 0.100000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:YawPI + element:Kp + haslimits:no + scale:1 + buttongroup:5,20 + + + + + + + + + 0 + 0 + + + + + + + Integral + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 13 + 13 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Attitude Mode. Adding Ki in Attitude when Ki is present in Rate is not recommended.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 3 + + + 0.100000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:RollPI + element:Ki + haslimits:no + scale:1 + buttongroup:5,20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 13 + 13 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Attitude Mode. Adding Ki in Attitude when Ki is present in Rate is not recommended.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 3 + + + 0.100000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:PitchPI + element:Ki + haslimits:no + scale:1 + buttongroup:5,20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 13 + 13 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Attitude Mode. Adding Ki in Attitude when Ki is present in Rate is not recommended.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 3 + + + 0.100000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:YawPI + element:Ki + haslimits:no + scale:1 + buttongroup:5,20 + + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + - - - - - 0 - 0 - - - - - 69 - 16 - - - - - - - Proportional - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much leveling stability is set into Attitude mode (outer loop). Too much will make your vehicle oscillate in Attitude Mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 3 - - - 0.100000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:RollPI - element:Kp - haslimits:no - scale:1 - buttongroup:5,20 - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much leveling stability is set into Attitude mode (outer loop). Too much will make your vehicle oscillate in Attitude Mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 3 - - - 0.100000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:PitchPI - element:Kp - haslimits:no - scale:1 - buttongroup:5,20 - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much leveling stability is set into Attitude mode (outer loop). Too much will make your vehicle oscillate in Attitude Mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 3 - - - 0.100000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:YawPI - element:Kp - haslimits:no - scale:1 - buttongroup:5,20 - - - - - - - - - 0 - 0 - - - - - - - Integral - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 13 - 13 - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Attitude Mode. Adding Ki in Attitude when Ki is present in Rate is not recommended.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 3 - - - 0.100000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:RollPI - element:Ki - haslimits:no - scale:1 - buttongroup:5,20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 13 - 13 - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Attitude Mode. Adding Ki in Attitude when Ki is present in Rate is not recommended.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 3 - - - 0.100000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:PitchPI - element:Ki - haslimits:no - scale:1 - buttongroup:5,20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 13 - 13 - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Attitude Mode. Adding Ki in Attitude when Ki is present in Rate is not recommended.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 3 - - - 0.100000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:YawPI - element:Ki - haslimits:no - scale:1 - buttongroup:5,20 - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 9 + + + + @@ -18999,7 +18997,7 @@ border-radius: 5; - 9 + 0 9 @@ -19013,6 +19011,2481 @@ border-radius: 5; 9 + + + + + + + #expertPidBankFrame{ + color: rgb(180, 180, 180); + margin-top: -1px; +} + + + QFrame::Box + + + QFrame::Plain + + + 1 + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Integral Limits + + + + 9 + + + 9 + + + 9 + + + 9 + + + 6 + + + + + + 0 + 100 + + + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 125 + 125 + 125 + + + + + + + 166 + 166 + 166 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 69 + 69 + 69 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 125 + 125 + 125 + + + + + + + 166 + 166 + 166 + + + + + + + 69 + 69 + 69 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 125 + 125 + 125 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 125 + 125 + 125 + + + + + + + 166 + 166 + 166 + + + + + + + 125 + 125 + 125 + + + + + + + 125 + 125 + 125 + + + + + + + 0 + 0 + 0 + + + + + + + + QGroupBox{border: 0px;} + + + + + + true + + + + 0 + + + 9 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This sets the maximum value of the integral (KP) that is used in Rate mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 4 + + + 1.000000000000000 + + + 0.001000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:PitchRatePID + element:ILimit + haslimits:no + scale:1 + buttongroup:13 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This sets the maximum value of the integral (KP) that is used in Rate mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 4 + + + 1.000000000000000 + + + 0.001000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:RollRatePID + element:ILimit + haslimits:no + scale:1 + buttongroup:13 + + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Roll + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Yaw + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This sets the maximum value of the integral (KP) that is used in AttitudeMode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 2 + + + 0.100000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:YawPI + element:ILimit + haslimits:no + scale:1 + buttongroup:13 + + + + + + + + + 0 + 0 + + + + + 91 + 0 + + + + + 16777215 + 16777215 + + + + + + + ILimit Attitude + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This sets the maximum value of the integral (KP) that is used in AttitudeMode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 2 + + + 0.100000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:PitchPI + element:ILimit + haslimits:no + scale:1 + buttongroup:13 + + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 91 + 13 + + + + + + + + + 0 + 0 + + + + + 91 + 0 + + + + + 16777215 + 16777215 + + + + + + + ILimit Rate + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This sets the maximum value of the integral (KP) that is used in AttitudeMode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 2 + + + 0.100000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:RollPI + element:ILimit + haslimits:no + scale:1 + buttongroup:13 + + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Pitch + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This sets the maximum value of the integral (KP) that is used in Rate mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 4 + + + 1.000000000000000 + + + 0.001000000000000 + + + + objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + fieldname:YawRatePID + element:ILimit + haslimits:no + scale:1 + buttongroup:13 + + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + Qt::Horizontal + + + + 1 + 20 + + + + + + + + + + + Qt::Horizontal + + + + 632 + 20 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Reset all values to GCS defaults + + + + + + Default + + + + objname:StabilizationSettings + button:default + buttongroup:13 + + + + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 9 + + + + @@ -21640,2439 +24113,20 @@ border-radius: 5; - - - - 0 - 0 - + + + Qt::Vertical - + + QSizePolicy::Fixed + + - 0 - 0 + 20 + 9 - - Integral Limits - - - - 9 - - - 9 - - - 9 - - - 9 - - - 6 - - - - - Qt::Horizontal - - - - 632 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Reset all values to GCS defaults - - - - - - Default - - - - objname:StabilizationSettings - button:default - buttongroup:13 - - - - - - - - - 0 - 100 - - - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 125 - 125 - 125 - - - - - - - 166 - 166 - 166 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - - - 69 - 69 - 69 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 125 - 125 - 125 - - - - - - - 166 - 166 - 166 - - - - - - - 69 - 69 - 69 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - - - 125 - 125 - 125 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 125 - 125 - 125 - - - - - - - 166 - 166 - 166 - - - - - - - 125 - 125 - 125 - - - - - - - 125 - 125 - 125 - - - - - - - 0 - 0 - 0 - - - - - - - - QGroupBox{border: 0px;} - - - - - - true - - - - 0 - - - 9 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This sets the maximum value of the integral (KP) that is used in Rate mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 4 - - - 1.000000000000000 - - - 0.001000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:PitchRatePID - element:ILimit - haslimits:no - scale:1 - buttongroup:13 - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This sets the maximum value of the integral (KP) that is used in Rate mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 4 - - - 1.000000000000000 - - - 0.001000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:RollRatePID - element:ILimit - haslimits:no - scale:1 - buttongroup:13 - - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Roll - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Yaw - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This sets the maximum value of the integral (KP) that is used in AttitudeMode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 2 - - - 0.100000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:YawPI - element:ILimit - haslimits:no - scale:1 - buttongroup:13 - - - - - - - - - 0 - 0 - - - - - 91 - 0 - - - - - 16777215 - 16777215 - - - - - - - ILimit Attitude - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This sets the maximum value of the integral (KP) that is used in AttitudeMode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 2 - - - 0.100000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:PitchPI - element:ILimit - haslimits:no - scale:1 - buttongroup:13 - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 91 - 13 - - - - - - - - - 0 - 0 - - - - - 91 - 0 - - - - - 16777215 - 16777215 - - - - - - - ILimit Rate - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This sets the maximum value of the integral (KP) that is used in AttitudeMode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 2 - - - 0.100000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:RollPI - element:ILimit - haslimits:no - scale:1 - buttongroup:13 - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Pitch - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This sets the maximum value of the integral (KP) that is used in Rate mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 4 - - - 1.000000000000000 - - - 0.001000000000000 - - - - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 - fieldname:YawRatePID - element:ILimit - haslimits:no - scale:1 - buttongroup:13 - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - Qt::Horizontal - - - - 1 - 20 - - - - - - - - - + @@ -27011,6 +27065,22 @@ border-radius: 5; + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 40 + 9 + + + + @@ -27098,6 +27168,9 @@ border-radius: 5; QFrame::NoFrame + + 0 + true @@ -27111,6 +27184,9 @@ border-radius: 5; + + 9 + @@ -31137,6 +31213,14 @@ Useful if you have accidentally changed some settings. + + + QTabBar + QWidget +
qtabbar.h
+ 1 +
+
stabilizationReloadBoardData_6 saveStabilizationToRAM_6 From 958efa62e163cc58218f63ef7e4ee1e8bd128177 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Wed, 8 Jan 2014 00:33:45 +0100 Subject: [PATCH 34/45] OP-984 Added code to allow switching between pid banks by selecting tabs The tabs are now dynamically created from a constant. --- .../config/configstabilizationwidget.cpp | 25 +++- .../config/configstabilizationwidget.h | 3 + .../src/plugins/config/stabilization.ui | 108 +++++++++--------- .../uavobjectwidgetutils/configtaskwidget.cpp | 24 +++- .../uavobjectwidgetutils/configtaskwidget.h | 2 + 5 files changed, 104 insertions(+), 58 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp index a6d8149f5..346b339ac 100644 --- a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp @@ -47,17 +47,26 @@ ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTa ui = new Ui_StabilizationWidget(); ui->setupUi(this); + // Set up fake tab widget stuff for pid banks support m_pidTabBars.append(ui->basicPIDBankTabBar); m_pidTabBars.append(ui->advancedPIDBankTabBar); m_pidTabBars.append(ui->expertPIDBankTabBar); foreach(QTabBar * tabBar, m_pidTabBars) { - for (int i = 1; i <= PID_BANKS; i++) { - tabBar->addTab(tr("PID Bank %1").arg(i)); + for (int i = 0; i < PID_BANKS; i++) { + tabBar->addTab(tr("PID Bank %1").arg(i + 1)); + tabBar->setTabData(i, QString("StabilizationSettingsBank%1").arg(i + 1)); } tabBar->setExpanding(false); connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(pidBankChanged(int))); } + for (int i = 0; i < PID_BANKS; i++) { + if(i > 0) { + m_stabilizationObjectsString.append(","); + } + m_stabilizationObjectsString.append(m_pidTabBars.at(0)->tabData(i).toString()); + } + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); Core::Internal::GeneralSettings *settings = pm->getObject(); @@ -221,6 +230,10 @@ void ConfigStabilizationWidget::pidBankChanged(int index) foreach(QTabBar * tabBar, m_pidTabBars) { tabBar->setCurrentIndex(index); } + + for(int i = 0; i < m_pidTabBars.at(0)->count(); i++) { + setWidgetBindingObjectEnabled(m_pidTabBars.at(0)->tabData(i).toString(), index == i); + } } bool ConfigStabilizationWidget::shouldObjectBeSaved(UAVObject *object) @@ -232,3 +245,11 @@ bool ConfigStabilizationWidget::shouldObjectBeSaved(UAVObject *object) return true; } } + +QString ConfigStabilizationWidget::mapObjectName(const QString objectName) +{ + if(objectName == "StabilizationSettingsBankX") { + return m_stabilizationObjectsString; + } + return ConfigTaskWidget::mapObjectName(objectName); +} diff --git a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h index e7944f382..895654521 100644 --- a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h @@ -49,6 +49,7 @@ private: Ui_StabilizationWidget *ui; QTimer *realtimeUpdates; QList m_pidTabBars; + QString m_stabilizationObjectsString; // Milliseconds between automatic 'Instant Updates' static const int AUTOMATIC_UPDATE_RATE = 500; @@ -56,6 +57,8 @@ private: static const int PID_BANKS = 3; int boardModel; +protected: + QString mapObjectName(const QString objectName); protected slots: void refreshWidgetsValues(UAVObject *o = NULL); diff --git a/ground/openpilotgcs/src/plugins/config/stabilization.ui b/ground/openpilotgcs/src/plugins/config/stabilization.ui index ec604645e..7ef04f3d4 100644 --- a/ground/openpilotgcs/src/plugins/config/stabilization.ui +++ b/ground/openpilotgcs/src/plugins/config/stabilization.ui @@ -1336,7 +1336,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:RollMax haslimits:no scale:1 @@ -1370,7 +1370,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:ManualRate element:Roll haslimits:no @@ -1418,7 +1418,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:ManualRate element:Roll haslimits:no @@ -2607,7 +2607,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:RollMax haslimits:no scale:1 @@ -2641,7 +2641,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:ManualRate element:Yaw haslimits:no @@ -2692,7 +2692,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:ManualRate element:Yaw haslimits:no @@ -4394,7 +4394,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:RollRatePID element:Kp haslimits:yes @@ -4433,7 +4433,7 @@ Then lower the value by 5 or so. - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:RollRatePID element:Kp haslimits:yes @@ -4508,7 +4508,7 @@ Then lower the value by 5 or so. - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:YawRatePID element:Kp haslimits:yes @@ -4558,7 +4558,7 @@ Then lower the value by 5 or so. - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:PitchRatePID element:Kp haslimits:yes @@ -4597,7 +4597,7 @@ Then lower the value by 5 or so. - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:PitchRatePID element:Kp haslimits:yes @@ -4636,7 +4636,7 @@ Then lower the value by 5 or so. - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:YawRatePID element:Kp haslimits:yes @@ -4686,7 +4686,7 @@ Then lower the value by 5 or so. - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:RollRatePID element:Ki haslimits:yes @@ -4744,7 +4744,7 @@ value as the Kp. - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:RollRatePID element:Ki haslimits:yes @@ -4783,7 +4783,7 @@ value as the Kp. - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:YawRatePID element:Ki haslimits:yes @@ -4833,7 +4833,7 @@ value as the Kp. - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:YawRatePID element:Ki haslimits:yes @@ -4883,7 +4883,7 @@ value as the Kp. - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:PitchRatePID element:Ki haslimits:yes @@ -4922,7 +4922,7 @@ value as the Kp. - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:PitchRatePID element:Ki haslimits:yes @@ -8373,7 +8373,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:RollPI element:Kp scale:0.1 @@ -8408,7 +8408,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:RollPI element:Kp scale:0.1 @@ -8458,7 +8458,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:PitchPI element:Kp scale:0.1 @@ -8493,7 +8493,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:PitchPI element:Kp scale:0.1 @@ -8543,7 +8543,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:YawPI element:Kp scale:0.1 @@ -8578,7 +8578,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:YawPI element:Kp scale:0.1 @@ -10055,7 +10055,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:PitchRatePID element:Kd haslimits:no @@ -10674,7 +10674,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:YawRatePID element:Ki haslimits:no @@ -10724,7 +10724,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:PitchRatePID element:Ki haslimits:no @@ -10774,7 +10774,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:YawRatePID element:Kp haslimits:no @@ -10824,7 +10824,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:YawRatePID element:Kd haslimits:no @@ -12031,7 +12031,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:RollRatePID element:Kp haslimits:no @@ -12097,7 +12097,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:RollRatePID element:Ki haslimits:no @@ -12178,7 +12178,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:PitchRatePID element:Kp haslimits:no @@ -12228,7 +12228,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:RollRatePID element:Kd haslimits:no @@ -13386,7 +13386,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:PitchMax haslimits:no scale:1 @@ -13469,7 +13469,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:MaximumRate element:Roll haslimits:no @@ -13538,7 +13538,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:ManualRate element:Yaw haslimits:no @@ -13591,7 +13591,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:YawMax haslimits:no scale:1 @@ -13643,7 +13643,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:MaximumRate element:Pitch haslimits:no @@ -14853,7 +14853,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:ManualRate element:Pitch haslimits:no @@ -15472,7 +15472,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:ManualRate element:Roll haslimits:no @@ -15528,7 +15528,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:RollMax haslimits:no scale:1 @@ -15580,7 +15580,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:MaximumRate element:Yaw haslimits:no @@ -18442,7 +18442,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:RollPI element:Kp haslimits:no @@ -18492,7 +18492,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:PitchPI element:Kp haslimits:no @@ -18542,7 +18542,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:YawPI element:Kp haslimits:no @@ -18627,7 +18627,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:RollPI element:Ki haslimits:no @@ -18693,7 +18693,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:PitchPI element:Ki haslimits:no @@ -18759,7 +18759,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:YawPI element:Ki haslimits:no @@ -19364,7 +19364,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:PitchRatePID element:ILimit haslimits:no @@ -19417,7 +19417,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:RollRatePID element:ILimit haslimits:no @@ -20567,7 +20567,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:YawPI element:ILimit haslimits:no @@ -20648,7 +20648,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:PitchPI element:ILimit haslimits:no @@ -20758,7 +20758,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:RollPI element:ILimit haslimits:no @@ -21374,7 +21374,7 @@ border-radius: 5; - objname:StabilizationSettingsBank1,StabilizationSettingsBank2,StabilizationSettingsBank3 + objname:StabilizationSettingsBankX fieldname:YawRatePID element:ILimit haslimits:no diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index 4a9f538d1..69a31f45d 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -64,7 +64,7 @@ int ConfigTaskWidget::fieldIndexFromElementName(QString objectName, QString fiel return 0; } - QString singleObjectName = objectName.split(",").at(0); + QString singleObjectName = mapObjectName(objectName).split(",").at(0); UAVObject *object = getObject(singleObjectName); Q_ASSERT(object); @@ -108,8 +108,10 @@ void ConfigTaskWidget::addWidgetBinding(UAVObject *object, UAVObjectField *field void ConfigTaskWidget::addWidgetBinding(QString objectName, QString fieldName, QWidget *widget, int index, double scale, bool isLimited, QList *reloadGroupIDs, quint32 instID) { + QString mappedObjectName = mapObjectName(objectName); + // If object name is comma separated list of objects, call one time per objectName - foreach(QString singleObjectName, objectName.split(",")) { + foreach(QString singleObjectName, mappedObjectName.split(",")) { doAddWidgetBinding(singleObjectName, fieldName, widget, index, scale, isLimited, reloadGroupIDs, instID); } } @@ -165,6 +167,19 @@ void ConfigTaskWidget::doAddWidgetBinding(QString objectName, QString fieldName, } } +void ConfigTaskWidget::setWidgetBindingObjectEnabled(QString objectName, bool enabled) +{ + UAVObject* object = getObject(objectName); + Q_ASSERT(object); + + foreach(WidgetBinding* binding, m_widgetBindingsPerObject.values(object)) { + binding->setIsEnabled(enabled); + if(enabled) { + setWidgetFromField(binding->widget(), binding->field(), binding->index(), binding->scale(), binding->isLimited()); + } + } +} + ConfigTaskWidget::~ConfigTaskWidget() { if (m_saveButton) { @@ -1016,6 +1031,11 @@ UAVObject *ConfigTaskWidget::getObject(const QString name, quint32 instId) return m_pluginManager->getObject()->getObject(name, instId); } +QString ConfigTaskWidget::mapObjectName(const QString objectName) +{ + return objectName; +} + void ConfigTaskWidget::updateEnableControls() { TelemetryManager *telMngr = m_pluginManager->getObject(); diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index ffec13970..5707eeaf9 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -151,6 +151,7 @@ public slots: void invalidateObjects(); void apply(); void save(); + void setWidgetBindingObjectEnabled(QString objectName, bool enabled); signals: // fired when a widgets contents changes @@ -243,6 +244,7 @@ protected slots: protected: virtual void enableControls(bool enable); + virtual QString mapObjectName(const QString objectName); void checkWidgetsLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, QVariant value, double scale); void updateEnableControls(); From a3c03b0244c2d31af699989bd7d51171f3299cb3 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Thu, 9 Jan 2014 09:39:47 +0100 Subject: [PATCH 35/45] OP-984 Minor changes. --- .../src/plugins/config/configstabilizationwidget.cpp | 7 ++++++- .../src/plugins/config/configstabilizationwidget.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp index 346b339ac..50cf64115 100644 --- a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp @@ -36,13 +36,14 @@ #include #include #include +#include #include #include #include "altitudeholdsettings.h" ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTaskWidget(parent), - boardModel(0) + boardModel(0), m_currentPIDBank(0) { ui = new Ui_StabilizationWidget(); ui->setupUi(this); @@ -227,13 +228,17 @@ void ConfigStabilizationWidget::onBoardConnected() void ConfigStabilizationWidget::pidBankChanged(int index) { + foreach(QTabBar * tabBar, m_pidTabBars) { + disconnect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(pidBankChanged(int))); tabBar->setCurrentIndex(index); + connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(pidBankChanged(int))); } for(int i = 0; i < m_pidTabBars.at(0)->count(); i++) { setWidgetBindingObjectEnabled(m_pidTabBars.at(0)->tabData(i).toString(), index == i); } + m_currentPIDBank = index; } bool ConfigStabilizationWidget::shouldObjectBeSaved(UAVObject *object) diff --git a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h index 895654521..f5331137b 100644 --- a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h @@ -57,6 +57,7 @@ private: static const int PID_BANKS = 3; int boardModel; + int m_currentPIDBank; protected: QString mapObjectName(const QString objectName); From 088197ac695d014f6cad3f1c4d4416a82be86646 Mon Sep 17 00:00:00 2001 From: m_thread Date: Thu, 9 Jan 2014 13:02:03 +0100 Subject: [PATCH 36/45] OP-984 Added backing store for values when switching between uavos. --- .../config/configstabilizationwidget.cpp | 12 +++- .../config/configstabilizationwidget.h | 3 +- .../src/plugins/coreplugin/coreplugin.pro | 1 - .../uavobjectwidgetutils/configtaskwidget.cpp | 57 +++++++++++-------- .../uavobjectwidgetutils/configtaskwidget.h | 10 +++- 5 files changed, 50 insertions(+), 33 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp index 50cf64115..43f0e9470 100644 --- a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp @@ -41,19 +41,25 @@ #include #include #include "altitudeholdsettings.h" +#include "stabilizationsettings.h" ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTaskWidget(parent), - boardModel(0), m_currentPIDBank(0) + boardModel(0), m_pidBankCount(0), m_currentPIDBank(0) { ui = new Ui_StabilizationWidget(); ui->setupUi(this); + StabilizationSettings* stabSettings = qobject_cast(getObject("StabilizationSettings")); + Q_ASSERT(stabSettings); + + m_pidBankCount = stabSettings->getField("FlightModeMap")->getOptions().count(); + // Set up fake tab widget stuff for pid banks support m_pidTabBars.append(ui->basicPIDBankTabBar); m_pidTabBars.append(ui->advancedPIDBankTabBar); m_pidTabBars.append(ui->expertPIDBankTabBar); foreach(QTabBar * tabBar, m_pidTabBars) { - for (int i = 0; i < PID_BANKS; i++) { + for (int i = 0; i < m_pidBankCount; i++) { tabBar->addTab(tr("PID Bank %1").arg(i + 1)); tabBar->setTabData(i, QString("StabilizationSettingsBank%1").arg(i + 1)); } @@ -61,7 +67,7 @@ ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTa connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(pidBankChanged(int))); } - for (int i = 0; i < PID_BANKS; i++) { + for (int i = 0; i < m_pidBankCount; i++) { if(i > 0) { m_stabilizationObjectsString.append(","); } diff --git a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h index f5331137b..67c7e246a 100644 --- a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h @@ -54,8 +54,7 @@ private: // Milliseconds between automatic 'Instant Updates' static const int AUTOMATIC_UPDATE_RATE = 500; - static const int PID_BANKS = 3; - + int m_pidBankCount; int boardModel; int m_currentPIDBank; protected: diff --git a/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro b/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro index 40fb468ea..5c4269c69 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro +++ b/ground/openpilotgcs/src/plugins/coreplugin/coreplugin.pro @@ -129,7 +129,6 @@ HEADERS += mainwindow.h \ uavgadgetdecorator.h \ workspacesettings.h \ uavconfiginfo.h \ - authorsdialog.h \ iconfigurableplugin.h \ aboutdialog.h diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index 69a31f45d..ab619581c 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -278,7 +278,7 @@ void ConfigTaskWidget::onAutopilotConnect() void ConfigTaskWidget::populateWidgets() { - bool dirtyBack = m_isDirty; + bool dirtyBack = isDirty(); emit populateWidgetsRequested(); foreach(WidgetBinding * binding, m_widgetBindingsPerObject) { @@ -295,7 +295,7 @@ void ConfigTaskWidget::refreshWidgetsValues(UAVObject *obj) return; } - bool dirtyBack = m_isDirty; + bool dirtyBack = isDirty(); emit refreshWidgetsValuesRequested(); foreach(WidgetBinding * binding, m_widgetBindingsPerObject.values(obj)) { if (binding->isEnabled() && binding->field() != NULL && binding->widget() != NULL) { @@ -310,8 +310,9 @@ void ConfigTaskWidget::updateObjectsFromWidgets() emit updateObjectsFromWidgetsRequested(); foreach(WidgetBinding * binding, m_widgetBindingsPerObject) { - if (binding->isEnabled() && binding->object() != NULL && binding->field() != NULL) { - setFieldFromWidget(binding->widget(), binding->field(), binding->index(), binding->scale()); + if (binding->object() != NULL && binding->field() != NULL) { + binding->updateObjectFieldFromValue(); + //setFieldFromWidget(binding->widget(), binding->field(), binding->index(), binding->scale()); } } } @@ -399,6 +400,7 @@ void ConfigTaskWidget::widgetsContentsChanged() QWidget *emitter = ((QWidget *)sender()); emit widgetContentsChanged(emitter); double scale; + QVariant value; foreach(WidgetBinding *binding ,m_widgetBindingsPerWidget.values(emitter)) { if (binding && binding->isEnabled()) { @@ -415,12 +417,15 @@ void ConfigTaskWidget::widgetsContentsChanged() } } } + value = getVariantFromWidget(emitter, scale, binding->units()); + binding->setValue(value); + if (binding->widget() != emitter) { disconnectWidgetUpdatesToSlot(binding->widget(), SLOT(widgetsContentsChanged())); checkWidgetsLimits(binding->widget(), binding->field(), binding->index(), binding->isLimited(), - getVariantFromWidget(emitter, scale, binding->units()), binding->scale()); - setWidgetFromVariant(binding->widget(), getVariantFromWidget(emitter, scale, binding->units()), binding->scale()); + value, binding->scale()); + setWidgetFromVariant(binding->widget(), value, binding->scale()); emit widgetContentsChanged(binding->widget()); connectWidgetUpdatesToSlot(binding->widget(), SLOT(widgetsContentsChanged())); @@ -430,8 +435,8 @@ void ConfigTaskWidget::widgetsContentsChanged() disconnectWidgetUpdatesToSlot(shadow->widget(), SLOT(widgetsContentsChanged())); checkWidgetsLimits(shadow->widget(), binding->field(), binding->index(), shadow->isLimited(), - getVariantFromWidget(emitter, scale, binding->units()), shadow->scale()); - setWidgetFromVariant(shadow->widget(), getVariantFromWidget(emitter, scale, binding->units()), shadow->scale()); + value, shadow->scale()); + setWidgetFromVariant(shadow->widget(), value, shadow->scale()); emit widgetContentsChanged(shadow->widget()); connectWidgetUpdatesToSlot(shadow->widget(), SLOT(widgetsContentsChanged())); @@ -828,22 +833,6 @@ void ConfigTaskWidget::disconnectWidgetUpdatesToSlot(QWidget *widget, const char } } -bool ConfigTaskWidget::setFieldFromWidget(QWidget *widget, UAVObjectField *field, int index, double scale) -{ - if (!widget || !field) { - return false; - } - QVariant ret = getVariantFromWidget(widget, scale, field->getUnits()); - if (ret.isValid()) { - field->setValue(ret, index); - return true; - } - { - qDebug() << __FUNCTION__ << "widget to uavobject relation not implemented" << widget->metaObject()->className(); - return false; - } -} - QVariant ConfigTaskWidget::getVariantFromWidget(QWidget *widget, double scale, QString units) { if (QComboBox * cb = qobject_cast(widget)) { @@ -1139,6 +1128,7 @@ bool WidgetBinding::matches(QString objectName, QString fieldName, int index, qu return false; } } + bool WidgetBinding::isEnabled() const { return m_isEnabled; @@ -1149,6 +1139,25 @@ void WidgetBinding::setIsEnabled(bool isEnabled) m_isEnabled = isEnabled; } +QVariant WidgetBinding::value() const +{ + return m_value; +} + +void WidgetBinding::setValue(const QVariant &value) +{ + m_value = value; + if(m_object && m_field) { + qDebug() << "WidgetBinding" << m_object->getName() << ":" << m_field->getName() << "value =" << value.toString(); + } +} + +void WidgetBinding::updateObjectFieldFromValue() +{ + if (m_value.isValid()) { + m_field->setValue(m_value, m_index); + } +} ShadowWidgetBinding::ShadowWidgetBinding(QWidget *widget, double scale, bool isLimited) { diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index 5707eeaf9..408da0e7d 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -80,12 +80,18 @@ public: bool isEnabled() const; void setIsEnabled(bool isEnabled); + QVariant value() const; + void setValue(const QVariant &value); + + void updateObjectFieldFromValue(); + private: UAVObject *m_object; UAVObjectField *m_field; int m_index; bool m_isEnabled; QList m_shadows; + QVariant m_value; }; class UAVOBJECTWIDGETUTILS_EXPORT ConfigTaskWidget : public QWidget { @@ -214,7 +220,6 @@ private: QString m_outOfLimitsStyle; QTimer *m_realtimeUpdateTimer; - bool setFieldFromWidget(QWidget *widget, UAVObjectField *field, int index, double scale); bool setWidgetFromField(QWidget *widget, UAVObjectField *field, int index, double scale, bool hasLimits); QVariant getVariantFromWidget(QWidget *widget, double scale, const QString units); @@ -225,7 +230,6 @@ private: void disconnectWidgetUpdatesToSlot(QWidget *widget, const char *function); void loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, double sclale); - virtual UAVObject *getObject(const QString name, quint32 instId = 0); int fieldIndexFromElementName(QString objectName, QString fieldName, QString elementName); @@ -245,7 +249,7 @@ protected slots: protected: virtual void enableControls(bool enable); virtual QString mapObjectName(const QString objectName); - + virtual UAVObject *getObject(const QString name, quint32 instId = 0); void checkWidgetsLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, QVariant value, double scale); void updateEnableControls(); }; From 68573af7107b7021677f4c6cba1efe9def54b28b Mon Sep 17 00:00:00 2001 From: m_thread Date: Thu, 9 Jan 2014 13:34:11 +0100 Subject: [PATCH 37/45] OP-984 Feature complete. --- .../config/configstabilizationwidget.cpp | 5 ++- .../uavobjectwidgetutils/configtaskwidget.cpp | 34 +++++++++++-------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp index 43f0e9470..d74ebf9a0 100644 --- a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp @@ -242,8 +242,11 @@ void ConfigStabilizationWidget::pidBankChanged(int index) } for(int i = 0; i < m_pidTabBars.at(0)->count(); i++) { - setWidgetBindingObjectEnabled(m_pidTabBars.at(0)->tabData(i).toString(), index == i); + setWidgetBindingObjectEnabled(m_pidTabBars.at(0)->tabData(i).toString(), false); } + + setWidgetBindingObjectEnabled(m_pidTabBars.at(0)->tabData(index).toString(), true); + m_currentPIDBank = index; } diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index ab619581c..41a3223d0 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -106,8 +106,8 @@ void ConfigTaskWidget::addWidgetBinding(UAVObject *object, UAVObjectField *field } void ConfigTaskWidget::addWidgetBinding(QString objectName, QString fieldName, QWidget *widget, int index, double scale, - bool isLimited, QList *reloadGroupIDs, quint32 instID) { - + bool isLimited, QList *reloadGroupIDs, quint32 instID) +{ QString mappedObjectName = mapObjectName(objectName); // If object name is comma separated list of objects, call one time per objectName @@ -117,7 +117,7 @@ void ConfigTaskWidget::addWidgetBinding(QString objectName, QString fieldName, Q } void ConfigTaskWidget::doAddWidgetBinding(QString objectName, QString fieldName, QWidget *widget, int index, double scale, - bool isLimited, QList *reloadGroupIDs, quint32 instID) + bool isLimited, QList *reloadGroupIDs, quint32 instID) { if (addShadowWidgetBinding(objectName, fieldName, widget, index, scale, isLimited, reloadGroupIDs, instID)) { return; @@ -156,12 +156,12 @@ void ConfigTaskWidget::doAddWidgetBinding(QString objectName, QString fieldName, m_reloadGroups.insert(groupId, binding); } } - } else { + } else { connectWidgetUpdatesToSlot(widget, SLOT(widgetsContentsChanged())); if (reloadGroupIDs) { addWidgetToReloadGroups(widget, reloadGroupIDs); } - if(binding->isEnabled()) { + if (binding->isEnabled()) { loadWidgetLimits(widget, field, index, isLimited, scale); } } @@ -169,13 +169,20 @@ void ConfigTaskWidget::doAddWidgetBinding(QString objectName, QString fieldName, void ConfigTaskWidget::setWidgetBindingObjectEnabled(QString objectName, bool enabled) { - UAVObject* object = getObject(objectName); + UAVObject *object = getObject(objectName); + Q_ASSERT(object); - foreach(WidgetBinding* binding, m_widgetBindingsPerObject.values(object)) { + foreach(WidgetBinding * binding, m_widgetBindingsPerObject.values(object)) { binding->setIsEnabled(enabled); - if(enabled) { - setWidgetFromField(binding->widget(), binding->field(), binding->index(), binding->scale(), binding->isLimited()); + if (enabled) { + //disconnectWidgetUpdatesToSlot(binding->widget(), SLOT(widgetsContentsChanged())); + if (binding->value().isValid() && !binding->value().isNull()) { + setWidgetFromVariant(binding->widget(), binding->value(), binding->scale()); + } else { + setWidgetFromField(binding->widget(), binding->field(), binding->index(), binding->scale(), binding->isLimited()); + } + //connectWidgetUpdatesToSlot(binding->widget(), SLOT(widgetsContentsChanged())); } } } @@ -312,7 +319,6 @@ void ConfigTaskWidget::updateObjectsFromWidgets() foreach(WidgetBinding * binding, m_widgetBindingsPerObject) { if (binding->object() != NULL && binding->field() != NULL) { binding->updateObjectFieldFromValue(); - //setFieldFromWidget(binding->widget(), binding->field(), binding->index(), binding->scale()); } } } @@ -377,7 +383,7 @@ bool ConfigTaskWidget::shouldObjectBeSaved(UAVObject *object) void ConfigTaskWidget::forceShadowUpdates() { foreach(WidgetBinding * binding, m_widgetBindingsPerObject) { - if(!binding->isEnabled()) { + if (!binding->isEnabled()) { continue; } QVariant widgetValue = getVariantFromWidget(binding->widget(), binding->scale(), binding->units()); @@ -401,8 +407,8 @@ void ConfigTaskWidget::widgetsContentsChanged() emit widgetContentsChanged(emitter); double scale; QVariant value; - foreach(WidgetBinding *binding ,m_widgetBindingsPerWidget.values(emitter)) { + foreach(WidgetBinding * binding, m_widgetBindingsPerWidget.values(emitter)) { if (binding && binding->isEnabled()) { if (binding->widget() == emitter) { scale = binding->scale(); @@ -546,7 +552,7 @@ bool ConfigTaskWidget::addShadowWidgetBinding(QString objectName, QString fieldN if (defaultReloadGroups) { addWidgetToReloadGroups(widget, defaultReloadGroups); } - if(!binding->isEnabled()) { + if (!binding->isEnabled()) { loadWidgetLimits(widget, binding->field(), binding->index(), isLimited, scale); } return true; @@ -1147,7 +1153,7 @@ QVariant WidgetBinding::value() const void WidgetBinding::setValue(const QVariant &value) { m_value = value; - if(m_object && m_field) { + if (m_object && m_field) { qDebug() << "WidgetBinding" << m_object->getName() << ":" << m_field->getName() << "value =" << value.toString(); } } From 41506803e6cf4934c9f9343dfc5390def2e21115 Mon Sep 17 00:00:00 2001 From: m_thread Date: Thu, 9 Jan 2014 19:00:24 +0100 Subject: [PATCH 38/45] OP-984 Some gui fiddling. --- .../src/libs/utils/mytabbedstackwidget.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp b/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp index ed094d16f..1212aa93f 100644 --- a/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp +++ b/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp @@ -38,7 +38,6 @@ MyTabbedStackWidget::MyTabbedStackWidget(QWidget *parent, bool isVertical, bool { m_listWidget = new QListWidget(); m_stackWidget = new QStackedWidget(); - m_stackWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding); QBoxLayout *toplevelLayout; if (m_vertical) { @@ -62,12 +61,18 @@ MyTabbedStackWidget::MyTabbedStackWidget(QWidget *parent, bool isVertical, bool m_listWidget->setWrapping(false); } - toplevelLayout->setSpacing(0); - toplevelLayout->setContentsMargins(0, 0, 0, 0); m_listWidget->setContentsMargins(0, 0, 0, 0); m_listWidget->setSpacing(0); m_listWidget->setViewMode(QListView::IconMode); + m_listWidget->setMovement(QListView::Static); + m_listWidget->setUniformItemSizes(true); + m_listWidget->setStyleSheet("border: 0px; margin: 9px; margin-right: 0px; background-color: transparent; "); + + m_stackWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding); m_stackWidget->setContentsMargins(0, 0, 0, 0); + + toplevelLayout->setSpacing(0); + toplevelLayout->setContentsMargins(0, 0, 0, 0); setLayout(toplevelLayout); connect(m_listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(showWidget(int)), Qt::QueuedConnection); From 3d8e3eb823ac8b144c723b2b895e0ddbf9d088b0 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Thu, 9 Jan 2014 19:52:56 +0100 Subject: [PATCH 39/45] OP-984 Uncrustify. --- .../src/plugins/config/configstabilizationwidget.cpp | 9 ++++----- .../src/plugins/config/configstabilizationwidget.h | 2 +- .../plugins/uavobjectwidgetutils/configtaskwidget.cpp | 4 ++-- .../src/plugins/uavobjectwidgetutils/configtaskwidget.h | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp index d74ebf9a0..ebc148c19 100644 --- a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp @@ -49,7 +49,7 @@ ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTa ui = new Ui_StabilizationWidget(); ui->setupUi(this); - StabilizationSettings* stabSettings = qobject_cast(getObject("StabilizationSettings")); + StabilizationSettings *stabSettings = qobject_cast(getObject("StabilizationSettings")); Q_ASSERT(stabSettings); m_pidBankCount = stabSettings->getField("FlightModeMap")->getOptions().count(); @@ -68,7 +68,7 @@ ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTa } for (int i = 0; i < m_pidBankCount; i++) { - if(i > 0) { + if (i > 0) { m_stabilizationObjectsString.append(","); } m_stabilizationObjectsString.append(m_pidTabBars.at(0)->tabData(i).toString()); @@ -234,14 +234,13 @@ void ConfigStabilizationWidget::onBoardConnected() void ConfigStabilizationWidget::pidBankChanged(int index) { - foreach(QTabBar * tabBar, m_pidTabBars) { disconnect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(pidBankChanged(int))); tabBar->setCurrentIndex(index); connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(pidBankChanged(int))); } - for(int i = 0; i < m_pidTabBars.at(0)->count(); i++) { + for (int i = 0; i < m_pidTabBars.at(0)->count(); i++) { setWidgetBindingObjectEnabled(m_pidTabBars.at(0)->tabData(i).toString(), false); } @@ -262,7 +261,7 @@ bool ConfigStabilizationWidget::shouldObjectBeSaved(UAVObject *object) QString ConfigStabilizationWidget::mapObjectName(const QString objectName) { - if(objectName == "StabilizationSettingsBankX") { + if (objectName == "StabilizationSettingsBankX") { return m_stabilizationObjectsString; } return ConfigTaskWidget::mapObjectName(objectName); diff --git a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h index 67c7e246a..c2ae524b8 100644 --- a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.h @@ -48,7 +48,7 @@ public: private: Ui_StabilizationWidget *ui; QTimer *realtimeUpdates; - QList m_pidTabBars; + QList m_pidTabBars; QString m_stabilizationObjectsString; // Milliseconds between automatic 'Instant Updates' diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index 41a3223d0..c79b5fdd1 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -176,13 +176,13 @@ void ConfigTaskWidget::setWidgetBindingObjectEnabled(QString objectName, bool en foreach(WidgetBinding * binding, m_widgetBindingsPerObject.values(object)) { binding->setIsEnabled(enabled); if (enabled) { - //disconnectWidgetUpdatesToSlot(binding->widget(), SLOT(widgetsContentsChanged())); + // disconnectWidgetUpdatesToSlot(binding->widget(), SLOT(widgetsContentsChanged())); if (binding->value().isValid() && !binding->value().isNull()) { setWidgetFromVariant(binding->widget(), binding->value(), binding->scale()); } else { setWidgetFromField(binding->widget(), binding->field(), binding->index(), binding->scale(), binding->isLimited()); } - //connectWidgetUpdatesToSlot(binding->widget(), SLOT(widgetsContentsChanged())); + // connectWidgetUpdatesToSlot(binding->widget(), SLOT(widgetsContentsChanged())); } } } diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index 408da0e7d..14db4b4c2 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -234,7 +234,7 @@ private: int fieldIndexFromElementName(QString objectName, QString fieldName, QString elementName); void doAddWidgetBinding(QString objectName, QString fieldName, QWidget *widget, int index = 0, double scale = 1, - bool isLimited = false, QList *reloadGroupIDs = 0, quint32 instID = 0); + bool isLimited = false, QList *reloadGroupIDs = 0, quint32 instID = 0); protected slots: virtual void disableObjectUpdates(); From 2e030419ca75bab2ac6c5b488d58dd4e24ccd137 Mon Sep 17 00:00:00 2001 From: Les Newell Date: Fri, 10 Jan 2014 22:16:50 +0000 Subject: [PATCH 40/45] OP-984 Fixed bad merge of stabilization.c --- flight/modules/Stabilization/stabilization.c | 45 +++++--------------- 1 file changed, 10 insertions(+), 35 deletions(-) diff --git a/flight/modules/Stabilization/stabilization.c b/flight/modules/Stabilization/stabilization.c index a6d292cad..0187eb75b 100644 --- a/flight/modules/Stabilization/stabilization.c +++ b/flight/modules/Stabilization/stabilization.c @@ -684,38 +684,6 @@ static float stab_powf(float x, uint8_t p) } -static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) -{ - StabilizationBankData bank, oldBank; - StabilizationBankGet(&oldBank); - - if(flight_mode < 0) return; - - switch(cast_struct_to_array(settings.FlightModeMap, settings.FlightModeMap.Stabilized1)[flight_mode]) - { - case 0: - StabilizationSettingsBank1Get((StabilizationSettingsBank1Data *) &bank); - break; - - case 1: - StabilizationSettingsBank2Get((StabilizationSettingsBank2Data *) &bank); - break; - - case 2: - StabilizationSettingsBank3Get((StabilizationSettingsBank3Data *) &bank); - break; - - default: - memset(&bank, 0, sizeof(StabilizationBankDataPacked)); -// return; //bank number is invalid. All we can do is ignore it. - } - -//Need to do this to prevent an infinite loop - if(memcmp(&oldBank, &bank, sizeof(StabilizationBankDataPacked)) != 0) - { - StabilizationBankSet(&bank); - } -} static void SettingsBankUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) { @@ -743,7 +711,7 @@ static void SettingsBankUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) // return; //bank number is invalid. All we can do is ignore it. } -//Need to do this to prevent an infinite loop + //Need to do this to prevent an infinite loop if(memcmp(&oldBank, &bank, sizeof(StabilizationBankDataPacked)) != 0) { StabilizationBankSet(&bank); @@ -848,6 +816,12 @@ static void BankUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) bank.YawRatePID.Ki, bank.YawRatePID.Kd, bank.YawRatePID.ILimit); +} + + +static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) +{ + StabilizationSettingsGet(&settings); // Set up the derivative term pid_configure_derivative(settings.DerivativeCutoff, settings.DerivativeGamma); @@ -882,13 +856,14 @@ static void BankUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) // Compute time constant for vbar decay term based on a tau vbar_decay = expf(-fakeDt / settings.VbarTau); - flight_mode = -1; //force flight mode update + + //force flight mode update + flight_mode = -1; // Rattitude flight mode anti-windup factor rattitude_anti_windup = settings.RattitudeAntiWindup; } - /** * @} * @} From b14c8bd4d28d3ae68166af6ea3e70f1705a069cf Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Sat, 11 Jan 2014 15:23:11 +0100 Subject: [PATCH 41/45] OP-984 Gui fixes --- .../src/libs/utils/mytabbedstackwidget.cpp | 10 +- .../src/libs/utils/mytabbedstackwidget.h | 3 + .../src/plugins/config/stabilization.ui | 7156 +++++++++-------- 3 files changed, 3608 insertions(+), 3561 deletions(-) diff --git a/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp b/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp index 1212aa93f..98311bfee 100644 --- a/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp +++ b/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp @@ -30,6 +30,7 @@ #include #include #include +#include MyTabbedStackWidget::MyTabbedStackWidget(QWidget *parent, bool isVertical, bool iconAbove) : QWidget(parent), @@ -37,6 +38,7 @@ MyTabbedStackWidget::MyTabbedStackWidget(QWidget *parent, bool isVertical, bool m_iconAbove(iconAbove) { m_listWidget = new QListWidget(); + m_listWidget->setObjectName("list"); m_stackWidget = new QStackedWidget(); QBoxLayout *toplevelLayout; @@ -66,7 +68,7 @@ MyTabbedStackWidget::MyTabbedStackWidget(QWidget *parent, bool isVertical, bool m_listWidget->setViewMode(QListView::IconMode); m_listWidget->setMovement(QListView::Static); m_listWidget->setUniformItemSizes(true); - m_listWidget->setStyleSheet("border: 0px; margin: 9px; margin-right: 0px; background-color: transparent; "); + m_listWidget->setStyleSheet("#list {border: 0px; margin-left: 9px; margin-top: 9px; background-color: transparent; }"); m_stackWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding); m_stackWidget->setContentsMargins(0, 0, 0, 0); @@ -132,6 +134,12 @@ void MyTabbedStackWidget::showWidget(int index) } } +void MyTabbedStackWidget::resizeEvent(QResizeEvent *event) +{ + QWidget::resizeEvent(event); + m_listWidget->setFixedWidth(m_listWidget->verticalScrollBar()->isVisible() ? 100 : 80); +} + void MyTabbedStackWidget::insertCornerWidget(int index, QWidget *widget) { Q_UNUSED(index); diff --git a/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.h b/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.h index c865ae141..cbfd11e74 100644 --- a/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.h +++ b/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.h @@ -76,6 +76,9 @@ private: QStackedWidget *m_stackWidget; bool m_vertical; bool m_iconAbove; + +protected: + void resizeEvent(QResizeEvent * event); }; #endif // MYTABBEDSTACKWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/stabilization.ui b/ground/openpilotgcs/src/plugins/config/stabilization.ui index 7ef04f3d4..6a4fa8186 100644 --- a/ground/openpilotgcs/src/plugins/config/stabilization.ui +++ b/ground/openpilotgcs/src/plugins/config/stabilization.ui @@ -537,88 +537,9 @@ - - - 0 - 0 - - - - - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 240 - 240 - 240 - - - - - - - - - 255 - 255 - 255 - - - - - - - 240 - 240 - 240 - - - - - - - - - 240 - 240 - 240 - - - - - - - 240 - 240 - 240 - - - - - - QFrame::NoFrame - - QFrame::Sunken - 0 @@ -634,12 +555,6 @@ 708 - - - 0 - 0 - - 0 @@ -8833,70 +8748,6 @@ border-radius: 5; - - - - - - - 255 - 255 - 255 - - - - - - - 240 - 240 - 240 - - - - - - - - - 255 - 255 - 255 - - - - - - - 240 - 240 - 240 - - - - - - - - - 240 - 240 - 240 - - - - - - - 240 - 240 - 240 - - - - - - QFrame::NoFrame @@ -8940,3339 +8791,9 @@ border-radius: 5; QFrame::Plain - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 0 - 0 - 0 - - - - - - - 251 - 251 - 251 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 0 - 0 - 0 - - - - - - - 251 - 251 - 251 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 124 - 124 - 124 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 124 - 124 - 124 - - - - - - - 255 - 255 - 255 - - - - - - - 124 - 124 - 124 - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - - - 243 - 243 - 243 - - - - - 250 - 250 - 250 - - - - - - - - - 0 - 0 - 0 - - - - - - - 248 - 248 - 248 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - Rate Stabilization (Inner Loop) - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - - 9 - - - 9 - - - 9 - - - 9 - - - 6 - - - - - Qt::Horizontal - - - - 497 - 20 - - - - - - - - <html><head/><body><p>Link roll &amp; pitch values together, thus giving the same value for each when setting up a symetrical vehicle that requires both to be the same.</p></body></html> - - - - - - Link Roll and Pitch - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Reset all values to GCS defaults - - - - - - Default - - - - objname:StabilizationSettings - button:default - buttongroup:4 - - - - - - - - - 0 - 0 - - - - - 0 - 140 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 251 - 251 - 251 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 251 - 251 - 251 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 124 - 124 - 124 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 251 - 251 - 251 - - - - - - - 124 - 124 - 124 - - - - - - - 165 - 165 - 165 - - - - - - - 124 - 124 - 124 - - - - - - - 255 - 255 - 255 - - - - - - - 124 - 124 - 124 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 248 - 248 - 248 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - false - - - QGroupBox{border: 0px;} - - - - - - true - - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This - makes the control output respond faster with fast stick movements or external disturbance like wind gusts. It also acts like a dampener, thus allowing higher KP settings. Only affects Rate mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 6 - - - 0.000001000000000 - - - - objname:StabilizationSettingsBankX - fieldname:PitchRatePID - element:Kd - haslimits:no - scale:1 - buttongroup:4,20 - - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Yaw - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - - - Integral - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Rate mode. A good starting point for Integral is the same as Proportional.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 5 - - - 0.000100000000000 - - - - objname:StabilizationSettingsBankX - fieldname:YawRatePID - element:Ki - haslimits:no - scale:1 - buttongroup:4,20 - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Rate mode. A good starting point for Integral is the same as Proportional.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 5 - - - 0.000100000000000 - - - - objname:StabilizationSettingsBankX - fieldname:PitchRatePID - element:Ki - haslimits:no - scale:1 - buttongroup:4,20 - - - - - - - - - 0 - 0 - - - - - 85 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much leveling stability is set into Rate mode (inner loop). Too much will make your vehicle oscillate in Rate mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 5 - - - 0.000100000000000 - - - - objname:StabilizationSettingsBankX - fieldname:YawRatePID - element:Kp - haslimits:no - scale:1 - buttongroup:4,20 - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This makes the control output respond faster with fast stick movements or external disturbance like wind gusts. It also acts like a dampener, thus allowing higher KP settings. Only affects Rate mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 6 - - - 0.000001000000000 - - - - objname:StabilizationSettingsBankX - fieldname:YawRatePID - element:Kd - haslimits:no - scale:1 - buttongroup:4,20 - - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Pitch - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 19 - 19 - 19 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 58 - 58 - 58 - - - - - - - 48 - 48 - 48 - - - - - - - 19 - 19 - 19 - - - - - - - 26 - 26 - 26 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - - - 74 - 74 - 74 - - - - - 36 - 36 - 36 - - - - - - - - - 0 - 0 - 0 - - - - - - - 39 - 39 - 39 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 75 - true - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; - - - Roll - - - Qt::AlignCenter - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 10 - - - - - - - - - 0 - 0 - - - - - 69 - 16 - - - - - - - Proportional - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 10 - - - - - - - - - 0 - 0 - - - - - 85 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much leveling stability is set into Rate mode (inner loop). Too much will make your vehicle oscillate in Rate mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 5 - - - 0.000100000000000 - - - - objname:StabilizationSettingsBankX - fieldname:RollRatePID - element:Kp - haslimits:no - scale:1 - buttongroup:4,20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 140 - 13 - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Rate mode. A good starting point for Integral is the same as Proportional.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 5 - - - 0.000100000000000 - - - - objname:StabilizationSettingsBankX - fieldname:RollRatePID - element:Ki - haslimits:no - scale:1 - buttongroup:4,20 - - - - - - - - - 0 - 0 - - - - - 58 - 0 - - - - - 16777215 - 16777215 - - - - - - - Derivative - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 85 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This adjusts how much leveling stability is set into Rate mode (inner loop). Too much will make your vehicle oscillate in Rate mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 5 - - - 0.000100000000000 - - - - objname:StabilizationSettingsBankX - fieldname:PitchRatePID - element:Kp - haslimits:no - scale:1 - buttongroup:4,20 - - - - - - - - - 0 - 0 - - - - - 0 - 22 - - - - - 16777215 - 22 - - - - Qt::StrongFocus - - - <html><head/><body><p>This makes the control output respond faster with fast stick movements or external disturbance like wind gusts.It also acts like a dampener, thus allowing higher KP settings. Only affects Rate mode.</p></body></html> - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 6 - - - 0.000001000000000 - - - - objname:StabilizationSettingsBankX - fieldname:RollRatePID - element:Kd - haslimits:no - scale:1 - buttongroup:4,20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 10 - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - - + + 9 + @@ -15634,6 +12155,3339 @@ border-radius: 5; + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + + + + + 0 + 0 + 0 + + + + + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + + + + + 255 + 255 + 255 + + + + + + + 251 + 251 + 251 + + + + + + + 124 + 124 + 124 + + + + + + + 165 + 165 + 165 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + + + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + + + + + 0 + 0 + 0 + + + + + + + 251 + 251 + 251 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + + + + + 255 + 255 + 255 + + + + + + + 251 + 251 + 251 + + + + + + + 124 + 124 + 124 + + + + + + + 165 + 165 + 165 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + + + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + + + + + 0 + 0 + 0 + + + + + + + 251 + 251 + 251 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 124 + 124 + 124 + + + + + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + + + + + 255 + 255 + 255 + + + + + + + 251 + 251 + 251 + + + + + + + 124 + 124 + 124 + + + + + + + 165 + 165 + 165 + + + + + + + 124 + 124 + 124 + + + + + + + 255 + 255 + 255 + + + + + + + 124 + 124 + 124 + + + + + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + + + + + + + 243 + 243 + 243 + + + + + 250 + 250 + 250 + + + + + + + + + 0 + 0 + 0 + + + + + + + 248 + 248 + 248 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + Rate Stabilization (Inner Loop) + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + false + + + + 9 + + + 9 + + + 9 + + + 9 + + + 6 + + + + + Qt::Horizontal + + + + 497 + 20 + + + + + + + + <html><head/><body><p>Link roll &amp; pitch values together, thus giving the same value for each when setting up a symetrical vehicle that requires both to be the same.</p></body></html> + + + + + + Link Roll and Pitch + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Reset all values to GCS defaults + + + + + + Default + + + + objname:StabilizationSettings + button:default + buttongroup:4 + + + + + + + + + 0 + 0 + + + + + 0 + 140 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 251 + 251 + 251 + + + + + + + 124 + 124 + 124 + + + + + + + 165 + 165 + 165 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 251 + 251 + 251 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 251 + 251 + 251 + + + + + + + 124 + 124 + 124 + + + + + + + 165 + 165 + 165 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 251 + 251 + 251 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 124 + 124 + 124 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 251 + 251 + 251 + + + + + + + 124 + 124 + 124 + + + + + + + 165 + 165 + 165 + + + + + + + 124 + 124 + 124 + + + + + + + 255 + 255 + 255 + + + + + + + 124 + 124 + 124 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 248 + 248 + 248 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + false + + + QGroupBox{border: 0px;} + + + + + + true + + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This + makes the control output respond faster with fast stick movements or external disturbance like wind gusts. It also acts like a dampener, thus allowing higher KP settings. Only affects Rate mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 6 + + + 0.000001000000000 + + + + objname:StabilizationSettingsBankX + fieldname:PitchRatePID + element:Kd + haslimits:no + scale:1 + buttongroup:4,20 + + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Yaw + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + + + Integral + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Rate mode. A good starting point for Integral is the same as Proportional.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 5 + + + 0.000100000000000 + + + + objname:StabilizationSettingsBankX + fieldname:YawRatePID + element:Ki + haslimits:no + scale:1 + buttongroup:4,20 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Rate mode. A good starting point for Integral is the same as Proportional.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 5 + + + 0.000100000000000 + + + + objname:StabilizationSettingsBankX + fieldname:PitchRatePID + element:Ki + haslimits:no + scale:1 + buttongroup:4,20 + + + + + + + + + 0 + 0 + + + + + 85 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much leveling stability is set into Rate mode (inner loop). Too much will make your vehicle oscillate in Rate mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 5 + + + 0.000100000000000 + + + + objname:StabilizationSettingsBankX + fieldname:YawRatePID + element:Kp + haslimits:no + scale:1 + buttongroup:4,20 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This makes the control output respond faster with fast stick movements or external disturbance like wind gusts. It also acts like a dampener, thus allowing higher KP settings. Only affects Rate mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 6 + + + 0.000001000000000 + + + + objname:StabilizationSettingsBankX + fieldname:YawRatePID + element:Kd + haslimits:no + scale:1 + buttongroup:4,20 + + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Pitch + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 19 + 19 + 19 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 58 + 58 + 58 + + + + + + + 48 + 48 + 48 + + + + + + + 19 + 19 + 19 + + + + + + + 26 + 26 + 26 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + + + 74 + 74 + 74 + + + + + 36 + 36 + 36 + + + + + + + + + 0 + 0 + 0 + + + + + + + 39 + 39 + 39 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 75 + true + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Roll + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 10 + + + + + + + + + 0 + 0 + + + + + 69 + 16 + + + + + + + Proportional + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 10 + + + + + + + + + 0 + 0 + + + + + 85 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much leveling stability is set into Rate mode (inner loop). Too much will make your vehicle oscillate in Rate mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 5 + + + 0.000100000000000 + + + + objname:StabilizationSettingsBankX + fieldname:RollRatePID + element:Kp + haslimits:no + scale:1 + buttongroup:4,20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 140 + 13 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much stability your vehicle will have when flying tilted (ie forward flight) in Rate mode. A good starting point for Integral is the same as Proportional.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 5 + + + 0.000100000000000 + + + + objname:StabilizationSettingsBankX + fieldname:RollRatePID + element:Ki + haslimits:no + scale:1 + buttongroup:4,20 + + + + + + + + + 0 + 0 + + + + + 58 + 0 + + + + + 16777215 + 16777215 + + + + + + + Derivative + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 85 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This adjusts how much leveling stability is set into Rate mode (inner loop). Too much will make your vehicle oscillate in Rate mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 5 + + + 0.000100000000000 + + + + objname:StabilizationSettingsBankX + fieldname:PitchRatePID + element:Kp + haslimits:no + scale:1 + buttongroup:4,20 + + + + + + + + + 0 + 0 + + + + + 0 + 22 + + + + + 16777215 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>This makes the control output respond faster with fast stick movements or external disturbance like wind gusts.It also acts like a dampener, thus allowing higher KP settings. Only affects Rate mode.</p></body></html> + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 6 + + + 0.000001000000000 + + + + objname:StabilizationSettingsBankX + fieldname:RollRatePID + element:Kd + haslimits:no + scale:1 + buttongroup:4,20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 10 + + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + + @@ -18825,6 +18679,9 @@ border-radius: 5; Instant Update + + 9 + @@ -18886,12 +18743,6 @@ border-radius: 5; - - - 0 - 0 - - Expert @@ -18910,76 +18761,9 @@ border-radius: 5; - - - - - - - 255 - 255 - 255 - - - - - - - 240 - 240 - 240 - - - - - - - - - 255 - 255 - 255 - - - - - - - 240 - 240 - 240 - - - - - - - - - 240 - 240 - 240 - - - - - - - 240 - 240 - 240 - - - - - - QFrame::NoFrame - - QFrame::Sunken - 0 @@ -27146,6 +26930,258 @@ border-radius: 5; + + + Misc + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + 0 + + + true + + + + + 0 + 0 + 796 + 708 + + + + + 0 + + + + + Rattitude + + + + 9 + + + 9 + + + 9 + + + 9 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Default + + + + objname:StabilizationSettings + button:default + buttongroup:15 + + + + + + + + QGroupBox{border: 0px;} + + + true + + + + 0 + + + 9 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 90 + 11 + + + + + + + + + 0 + 0 + + + + + 5 + 22 + + + + + 175 + 22 + + + + Qt::StrongFocus + + + <html><head/><body><p>Higher values will keep larger Ki terms and limits from winding up at partial stick. Consider increasing this if you have high Ki values and limits and a sudden stick motion from one aircraft bank angle to another causes the aircraft to rotate and then slowly change rotation.</p></body></html> + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 0 + + + 0.000000000000000 + + + 31.000000000000000 + + + 10.000000000000000 + + + + objname:StabilizationSettings + fieldname:RattitudeAntiWindup + haslimits:no + scale:1 + buttongroup:15 + + + + + + + + + 0 + 0 + + + + + 144 + 16 + + + + + 175 + 16777215 + + + + + 75 + true + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; + + + Anti-Windup + + + Qt::AlignCenter + + + + + + + Qt::Horizontal + + + + 300 + 20 + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Altitude Hold @@ -27183,11 +27219,11 @@ border-radius: 5; 708 - + 9 - + @@ -29108,7 +29144,7 @@ border-radius: 5; - + @@ -30954,7 +30990,7 @@ border-radius: 5; - + @@ -31000,7 +31036,7 @@ border-radius: 5; - + Qt::Vertical From 38a709a0da9729183daf099c39f50f0c4e9bd339 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Sat, 11 Jan 2014 15:44:07 +0100 Subject: [PATCH 42/45] OP-984 Fixed false dirty indication. Added some constant. --- ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp | 4 ++-- ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.h | 1 + .../src/plugins/uavobjectwidgetutils/configtaskwidget.cpp | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp b/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp index 98311bfee..e465b50f9 100644 --- a/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp +++ b/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.cpp @@ -59,7 +59,7 @@ MyTabbedStackWidget::MyTabbedStackWidget(QWidget *parent, bool isVertical, bool } if (m_iconAbove && m_vertical) { - m_listWidget->setFixedWidth(80); // this should be computed instead + m_listWidget->setFixedWidth(LIST_VIEW_WIDTH); // this should be computed instead m_listWidget->setWrapping(false); } @@ -137,7 +137,7 @@ void MyTabbedStackWidget::showWidget(int index) void MyTabbedStackWidget::resizeEvent(QResizeEvent *event) { QWidget::resizeEvent(event); - m_listWidget->setFixedWidth(m_listWidget->verticalScrollBar()->isVisible() ? 100 : 80); + m_listWidget->setFixedWidth(m_listWidget->verticalScrollBar()->isVisible() ? LIST_VIEW_WIDTH + 20 : LIST_VIEW_WIDTH); } void MyTabbedStackWidget::insertCornerWidget(int index, QWidget *widget) diff --git a/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.h b/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.h index cbfd11e74..4b0777e4e 100644 --- a/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.h +++ b/ground/openpilotgcs/src/libs/utils/mytabbedstackwidget.h @@ -76,6 +76,7 @@ private: QStackedWidget *m_stackWidget; bool m_vertical; bool m_iconAbove; + static const int LIST_VIEW_WIDTH = 80; protected: void resizeEvent(QResizeEvent * event); diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index c79b5fdd1..00fc4250f 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -173,18 +173,19 @@ void ConfigTaskWidget::setWidgetBindingObjectEnabled(QString objectName, bool en Q_ASSERT(object); + bool dirtyBack = isDirty(); + foreach(WidgetBinding * binding, m_widgetBindingsPerObject.values(object)) { binding->setIsEnabled(enabled); if (enabled) { - // disconnectWidgetUpdatesToSlot(binding->widget(), SLOT(widgetsContentsChanged())); if (binding->value().isValid() && !binding->value().isNull()) { setWidgetFromVariant(binding->widget(), binding->value(), binding->scale()); } else { setWidgetFromField(binding->widget(), binding->field(), binding->index(), binding->scale(), binding->isLimited()); } - // connectWidgetUpdatesToSlot(binding->widget(), SLOT(widgetsContentsChanged())); } } + setDirty(dirtyBack); } ConfigTaskWidget::~ConfigTaskWidget() From b43cf9a7fe043a768a51e9ba9d57509615521b63 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Sat, 11 Jan 2014 16:14:12 +0100 Subject: [PATCH 43/45] OP-984 Commented out some annoying debug prints. --- .../src/plugins/uavobjectwidgetutils/configtaskwidget.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index 00fc4250f..12f58a50e 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -666,6 +666,7 @@ void ConfigTaskWidget::autoLoadWidgets() refreshWidgetsValues(); forceShadowUpdates(); + /* foreach(WidgetBinding * binding, m_widgetBindingsPerObject) { if (binding->widget()) { qDebug() << "Binding :" << binding->widget()->objectName(); @@ -681,6 +682,7 @@ void ConfigTaskWidget::autoLoadWidgets() } } } + */ } void ConfigTaskWidget::addWidgetToReloadGroups(QWidget *widget, QList *reloadGroupIDs) @@ -1154,9 +1156,11 @@ QVariant WidgetBinding::value() const void WidgetBinding::setValue(const QVariant &value) { m_value = value; + /* if (m_object && m_field) { qDebug() << "WidgetBinding" << m_object->getName() << ":" << m_field->getName() << "value =" << value.toString(); } + */ } void WidgetBinding::updateObjectFieldFromValue() From 3b0525c4abd92e7173d1bff287ff3661e49bf093 Mon Sep 17 00:00:00 2001 From: Les Newell Date: Tue, 14 Jan 2014 19:03:42 +0000 Subject: [PATCH 44/45] OP-984 Uncrustified --- flight/modules/ManualControl/manualcontrol.c | 51 +- flight/modules/Stabilization/stabilization.c | 146 +- flight/modules/TxPID/txpid.c | 18 +- flight/pios/common/pios_rfm22b.c | 42536 ++++++++++++++++- 4 files changed, 40458 insertions(+), 2293 deletions(-) diff --git a/flight/modules/ManualControl/manualcontrol.c b/flight/modules/ManualControl/manualcontrol.c index 324869077..a8df27c2b 100644 --- a/flight/modules/ManualControl/manualcontrol.c +++ b/flight/modules/ManualControl/manualcontrol.c @@ -691,26 +691,26 @@ static void updateStabilizationDesired(ManualControlCommandData *cmd, ManualCont } stabilization.Roll = - (stab_settings[0] == STABILIZATIONDESIRED_STABILIZATIONMODE_NONE) ? cmd->Roll : - (stab_settings[0] == STABILIZATIONDESIRED_STABILIZATIONMODE_RATE) ? cmd->Roll * stabSettings.ManualRate.Roll : - (stab_settings[0] == STABILIZATIONDESIRED_STABILIZATIONMODE_WEAKLEVELING) ? cmd->Roll * stabSettings.ManualRate.Roll : - (stab_settings[0] == STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDE) ? cmd->Roll * stabSettings.RollMax : - (stab_settings[0] == STABILIZATIONDESIRED_STABILIZATIONMODE_AXISLOCK) ? cmd->Roll * stabSettings.ManualRate.Roll : - (stab_settings[0] == STABILIZATIONDESIRED_STABILIZATIONMODE_VIRTUALBAR) ? cmd->Roll : - (stab_settings[0] == STABILIZATIONDESIRED_STABILIZATIONMODE_RATTITUDE) ? cmd->Roll : - (stab_settings[0] == STABILIZATIONDESIRED_STABILIZATIONMODE_RELAYRATE) ? cmd->Roll * stabSettings.ManualRate.Roll : + (stab_settings[0] == STABILIZATIONDESIRED_STABILIZATIONMODE_NONE) ? cmd->Roll : + (stab_settings[0] == STABILIZATIONDESIRED_STABILIZATIONMODE_RATE) ? cmd->Roll * stabSettings.ManualRate.Roll : + (stab_settings[0] == STABILIZATIONDESIRED_STABILIZATIONMODE_WEAKLEVELING) ? cmd->Roll * stabSettings.ManualRate.Roll : + (stab_settings[0] == STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDE) ? cmd->Roll * stabSettings.RollMax : + (stab_settings[0] == STABILIZATIONDESIRED_STABILIZATIONMODE_AXISLOCK) ? cmd->Roll * stabSettings.ManualRate.Roll : + (stab_settings[0] == STABILIZATIONDESIRED_STABILIZATIONMODE_VIRTUALBAR) ? cmd->Roll : + (stab_settings[0] == STABILIZATIONDESIRED_STABILIZATIONMODE_RATTITUDE) ? cmd->Roll : + (stab_settings[0] == STABILIZATIONDESIRED_STABILIZATIONMODE_RELAYRATE) ? cmd->Roll * stabSettings.ManualRate.Roll : (stab_settings[0] == STABILIZATIONDESIRED_STABILIZATIONMODE_RELAYATTITUDE) ? cmd->Roll * stabSettings.RollMax : 0; // this is an invalid mode stabilization.Pitch = - (stab_settings[1] == STABILIZATIONDESIRED_STABILIZATIONMODE_NONE) ? cmd->Pitch : - (stab_settings[1] == STABILIZATIONDESIRED_STABILIZATIONMODE_RATE) ? cmd->Pitch * stabSettings.ManualRate.Pitch : - (stab_settings[1] == STABILIZATIONDESIRED_STABILIZATIONMODE_WEAKLEVELING) ? cmd->Pitch * stabSettings.ManualRate.Pitch : - (stab_settings[1] == STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDE) ? cmd->Pitch * stabSettings.PitchMax : - (stab_settings[1] == STABILIZATIONDESIRED_STABILIZATIONMODE_AXISLOCK) ? cmd->Pitch * stabSettings.ManualRate.Pitch : - (stab_settings[1] == STABILIZATIONDESIRED_STABILIZATIONMODE_VIRTUALBAR) ? cmd->Pitch : - (stab_settings[1] == STABILIZATIONDESIRED_STABILIZATIONMODE_RATTITUDE) ? cmd->Pitch : - (stab_settings[1] == STABILIZATIONDESIRED_STABILIZATIONMODE_RELAYRATE) ? cmd->Pitch * stabSettings.ManualRate.Pitch : + (stab_settings[1] == STABILIZATIONDESIRED_STABILIZATIONMODE_NONE) ? cmd->Pitch : + (stab_settings[1] == STABILIZATIONDESIRED_STABILIZATIONMODE_RATE) ? cmd->Pitch * stabSettings.ManualRate.Pitch : + (stab_settings[1] == STABILIZATIONDESIRED_STABILIZATIONMODE_WEAKLEVELING) ? cmd->Pitch * stabSettings.ManualRate.Pitch : + (stab_settings[1] == STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDE) ? cmd->Pitch * stabSettings.PitchMax : + (stab_settings[1] == STABILIZATIONDESIRED_STABILIZATIONMODE_AXISLOCK) ? cmd->Pitch * stabSettings.ManualRate.Pitch : + (stab_settings[1] == STABILIZATIONDESIRED_STABILIZATIONMODE_VIRTUALBAR) ? cmd->Pitch : + (stab_settings[1] == STABILIZATIONDESIRED_STABILIZATIONMODE_RATTITUDE) ? cmd->Pitch : + (stab_settings[1] == STABILIZATIONDESIRED_STABILIZATIONMODE_RELAYRATE) ? cmd->Pitch * stabSettings.ManualRate.Pitch : (stab_settings[1] == STABILIZATIONDESIRED_STABILIZATIONMODE_RELAYATTITUDE) ? cmd->Pitch * stabSettings.PitchMax : 0; // this is an invalid mode @@ -722,18 +722,17 @@ static void updateStabilizationDesired(ManualControlCommandData *cmd, ManualCont if (stab_settings[2] == STABILIZATIONDESIRED_STABILIZATIONMODE_RATTITUDE) { stabilization.StabilizationMode.Yaw = STABILIZATIONDESIRED_STABILIZATIONMODE_RATE; stabilization.Yaw = cmd->Yaw * stabSettings.ManualRate.Yaw; - } - else { + } else { stabilization.StabilizationMode.Yaw = stab_settings[2]; stabilization.Yaw = - (stab_settings[2] == STABILIZATIONDESIRED_STABILIZATIONMODE_NONE) ? cmd->Yaw : - (stab_settings[2] == STABILIZATIONDESIRED_STABILIZATIONMODE_RATE) ? cmd->Yaw * stabSettings.ManualRate.Yaw : - (stab_settings[2] == STABILIZATIONDESIRED_STABILIZATIONMODE_WEAKLEVELING) ? cmd->Yaw * stabSettings.ManualRate.Yaw : - (stab_settings[2] == STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDE) ? cmd->Yaw * stabSettings.YawMax : - (stab_settings[2] == STABILIZATIONDESIRED_STABILIZATIONMODE_AXISLOCK) ? cmd->Yaw * stabSettings.ManualRate.Yaw : - (stab_settings[2] == STABILIZATIONDESIRED_STABILIZATIONMODE_VIRTUALBAR) ? cmd->Yaw : - (stab_settings[2] == STABILIZATIONDESIRED_STABILIZATIONMODE_RATTITUDE) ? cmd->Yaw : - (stab_settings[2] == STABILIZATIONDESIRED_STABILIZATIONMODE_RELAYRATE) ? cmd->Yaw * stabSettings.ManualRate.Yaw : + (stab_settings[2] == STABILIZATIONDESIRED_STABILIZATIONMODE_NONE) ? cmd->Yaw : + (stab_settings[2] == STABILIZATIONDESIRED_STABILIZATIONMODE_RATE) ? cmd->Yaw * stabSettings.ManualRate.Yaw : + (stab_settings[2] == STABILIZATIONDESIRED_STABILIZATIONMODE_WEAKLEVELING) ? cmd->Yaw * stabSettings.ManualRate.Yaw : + (stab_settings[2] == STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDE) ? cmd->Yaw * stabSettings.YawMax : + (stab_settings[2] == STABILIZATIONDESIRED_STABILIZATIONMODE_AXISLOCK) ? cmd->Yaw * stabSettings.ManualRate.Yaw : + (stab_settings[2] == STABILIZATIONDESIRED_STABILIZATIONMODE_VIRTUALBAR) ? cmd->Yaw : + (stab_settings[2] == STABILIZATIONDESIRED_STABILIZATIONMODE_RATTITUDE) ? cmd->Yaw : + (stab_settings[2] == STABILIZATIONDESIRED_STABILIZATIONMODE_RELAYRATE) ? cmd->Yaw * stabSettings.ManualRate.Yaw : (stab_settings[2] == STABILIZATIONDESIRED_STABILIZATIONMODE_RELAYATTITUDE) ? cmd->Yaw * stabSettings.YawMax : 0; // this is an invalid mode } diff --git a/flight/modules/Stabilization/stabilization.c b/flight/modules/Stabilization/stabilization.c index 0187eb75b..b2b930c70 100644 --- a/flight/modules/Stabilization/stabilization.c +++ b/flight/modules/Stabilization/stabilization.c @@ -80,8 +80,8 @@ // The PID_RATEA_ROLL set is used by Rattitude mode because it needs to maintain // - two independant rate PIDs because it does rate and attitude simultaneously enum { PID_RATE_ROLL, PID_RATE_PITCH, PID_RATE_YAW, PID_ROLL, PID_PITCH, PID_YAW, PID_RATEA_ROLL, PID_RATEA_PITCH, PID_RATEA_YAW, PID_MAX }; -enum{RATE_P, RATE_I, RATE_D, RATE_LIMIT, RATE_OFFSET}; -enum{ATT_P, ATT_I, ATT_LIMIT, ATT_OFFSET}; +enum { RATE_P, RATE_I, RATE_D, RATE_LIMIT, RATE_OFFSET }; +enum { ATT_P, ATT_I, ATT_LIMIT, ATT_OFFSET }; // Private variables static xTaskHandle taskHandle; @@ -98,7 +98,7 @@ bool lowThrottleZeroAxis[MAX_AXES]; float vbar_decay = 0.991f; struct pid pids[PID_MAX]; -int flight_mode = -1; +int flight_mode = -1; static uint8_t rattitude_anti_windup; @@ -224,7 +224,7 @@ static void stabilizationTask(__attribute__((unused)) void *parameters) RateDesiredGet(&rateDesired); #endif - if(flight_mode != flightStatus.FlightMode){ + if (flight_mode != flightStatus.FlightMode) { flight_mode = flightStatus.FlightMode; SettingsBankUpdatedCb(NULL); } @@ -284,9 +284,9 @@ static void stabilizationTask(__attribute__((unused)) void *parameters) #else /* if defined(PIOS_QUATERNION_STABILIZATION) */ // Simpler algorithm for CC, less memory - float local_error[3] = { stabDesired.Roll - attitudeState.Roll, + float local_error[3] = { stabDesired.Roll - attitudeState.Roll, stabDesired.Pitch - attitudeState.Pitch, - stabDesired.Yaw - attitudeState.Yaw }; + stabDesired.Yaw - attitudeState.Yaw }; // find shortest way float modulo = fmodf(local_error[2] + 180.0f, 360.0f); if (modulo < 0) { @@ -352,15 +352,15 @@ static void stabilizationTask(__attribute__((unused)) void *parameters) break; case STABILIZATIONDESIRED_STABILIZATIONMODE_RATTITUDE: - // A parameterization from Attitude mode at center stick - // - to Rate mode at full stick - // This is done by parameterizing to use the rotation rate that Attitude mode - // - would use at center stick to using the rotation rate that Rate mode - // - would use at full stick in a weighted average sort of way. + // A parameterization from Attitude mode at center stick + // - to Rate mode at full stick + // This is done by parameterizing to use the rotation rate that Attitude mode + // - would use at center stick to using the rotation rate that Rate mode + // - would use at full stick in a weighted average sort of way. { if (reinit) { - pids[PID_ROLL + i].iAccumulator = 0; - pids[PID_RATE_ROLL + i].iAccumulator = 0; + pids[PID_ROLL + i].iAccumulator = 0; + pids[PID_RATE_ROLL + i].iAccumulator = 0; pids[PID_RATEA_ROLL + i].iAccumulator = 0; } @@ -368,7 +368,7 @@ static void stabilizationTask(__attribute__((unused)) void *parameters) // Save Rate's rate in a temp for later merging with Attitude's rate float rateDesiredAxisRate; rateDesiredAxisRate = bound(stabDesiredAxis[i], 1.0f) - * cast_struct_to_array(stabBank.ManualRate, stabBank.ManualRate.Roll)[i]; + * cast_struct_to_array(stabBank.ManualRate, stabBank.ManualRate.Roll)[i]; // Compute what Attitude mode would give for this stick angle's rate @@ -377,8 +377,8 @@ static void stabilizationTask(__attribute__((unused)) void *parameters) // - subtract off the actual angle to get the angle error // This is what local_error[] holds for Attitude mode float attitude_error = stabDesiredAxis[i] - * cast_struct_to_array(stabBank.RollMax, stabBank.RollMax)[i] - - cast_struct_to_array(attitudeState.Roll, attitudeState.Roll)[i]; + * cast_struct_to_array(stabBank.RollMax, stabBank.RollMax)[i] + - cast_struct_to_array(attitudeState.Roll, attitudeState.Roll)[i]; // Compute the outer loop just like Attitude mode does float rateDesiredAxisAttitude; @@ -395,14 +395,14 @@ static void stabilizationTask(__attribute__((unused)) void *parameters) // magnitude = sqrt(stabDesired.Roll*stabDesired.Roll + stabDesired.Pitch*stabDesired.Pitch); float magnitude; magnitude = fmaxf(fabsf(stabDesired.Roll), fabsf(stabDesired.Pitch)); - rateDesiredAxis[i] = (1.0f-magnitude) * rateDesiredAxisAttitude - + magnitude * rateDesiredAxisRate; + rateDesiredAxis[i] = (1.0f - magnitude) * rateDesiredAxisAttitude + + magnitude * rateDesiredAxisRate; // Compute the inner loop for both Rate mode and Attitude mode // actuatorDesiredAxis[i] is the weighted average of the two PIDs from the two rates actuatorDesiredAxis[i] = - (1.0f-magnitude) * pid_apply_setpoint(&pids[PID_RATEA_ROLL + i], speedScaleFactor, rateDesiredAxis[i], gyro_filtered[i], dT) - + magnitude * pid_apply_setpoint(&pids[PID_RATE_ROLL + i], speedScaleFactor, rateDesiredAxis[i], gyro_filtered[i], dT); + (1.0f - magnitude) * pid_apply_setpoint(&pids[PID_RATEA_ROLL + i], speedScaleFactor, rateDesiredAxis[i], gyro_filtered[i], dT) + + magnitude * pid_apply_setpoint(&pids[PID_RATE_ROLL + i], speedScaleFactor, rateDesiredAxis[i], gyro_filtered[i], dT); actuatorDesiredAxis[i] = bound(actuatorDesiredAxis[i], 1.0f); // settings.RattitudeAntiWindup controls the iAccumulator zeroing @@ -440,28 +440,28 @@ static void stabilizationTask(__attribute__((unused)) void *parameters) // the 7.966 and 17.668 cancel the default PID value and dT given to log2f() // if these are non-default, tweaking is thus done so the user doesn't have to readjust // the default value of 10 for UAVO RattitudeAntiWindup gives a power of 22 - // these calculations are for magnitude = 0.5, so 22 corresponds to the number of bits - // used in the mantissa of the float - // i.e. 1.0-(0.5^22) almost underflows + // these calculations are for magnitude = 0.5, so 22 corresponds to the number of bits + // used in the mantissa of the float + // i.e. 1.0-(0.5^22) almost underflows // This may only be useful for aircraft with large Ki values and limits if (dT > 0.0f && rattitude_anti_windup > 0.0f) { float factor; // At magnitudes close to one, the Attitude accumulators gets zeroed - if (pids[PID_ROLL+i].i > 0.0f) { - factor = 1.0f - stab_powf(magnitude, ((uint8_t) (32.1f - 7.966f - stab_log2f(dT * pids[PID_ROLL+i].i))) - rattitude_anti_windup); - pids[PID_ROLL+i].iAccumulator *= factor; + if (pids[PID_ROLL + i].i > 0.0f) { + factor = 1.0f - stab_powf(magnitude, ((uint8_t)(32.1f - 7.966f - stab_log2f(dT * pids[PID_ROLL + i].i))) - rattitude_anti_windup); + pids[PID_ROLL + i].iAccumulator *= factor; } - if (pids[PID_RATEA_ROLL+i].i > 0.0f) { - factor = 1.0f - stab_powf(magnitude, ((uint8_t) (32.1f - 17.668f - stab_log2f(dT * pids[PID_RATEA_ROLL+i].i))) - rattitude_anti_windup); - pids[PID_RATEA_ROLL+i].iAccumulator *= factor; + if (pids[PID_RATEA_ROLL + i].i > 0.0f) { + factor = 1.0f - stab_powf(magnitude, ((uint8_t)(32.1f - 17.668f - stab_log2f(dT * pids[PID_RATEA_ROLL + i].i))) - rattitude_anti_windup); + pids[PID_RATEA_ROLL + i].iAccumulator *= factor; } // At magnitudes close to zero, the Rate accumulator gets zeroed - if (pids[PID_RATE_ROLL+i].i > 0.0f) { - factor = 1.0f - stab_powf(1.0f-magnitude, ((uint8_t) (32.1f - 17.668f - stab_log2f(dT * pids[PID_RATE_ROLL+i].i))) - rattitude_anti_windup); - pids[PID_RATE_ROLL+i].iAccumulator *= factor; + if (pids[PID_RATE_ROLL + i].i > 0.0f) { + factor = 1.0f - stab_powf(1.0f - magnitude, ((uint8_t)(32.1f - 17.668f - stab_log2f(dT * pids[PID_RATE_ROLL + i].i))) - rattitude_anti_windup); + pids[PID_RATE_ROLL + i].iAccumulator *= factor; } } @@ -479,12 +479,12 @@ static void stabilizationTask(__attribute__((unused)) void *parameters) break; case STABILIZATIONDESIRED_STABILIZATIONMODE_WEAKLEVELING: - // FIXME: local_error[] is rate - attitude for Weak Leveling - // The only ramifications are: - // Weak Leveling Kp is off by a factor of 3 to 12 and may need a different default in GCS - // Changing Rate mode max rate currently requires a change to Kp - // That would be changed to Attitude mode max angle affecting Kp - // Also does not take dT into account + // FIXME: local_error[] is rate - attitude for Weak Leveling + // The only ramifications are: + // Weak Leveling Kp is off by a factor of 3 to 12 and may need a different default in GCS + // Changing Rate mode max rate currently requires a change to Kp + // That would be changed to Attitude mode max angle affecting Kp + // Also does not take dT into account { if (reinit) { pids[PID_RATE_ROLL + i].iAccumulator = 0; @@ -649,71 +649,68 @@ static float bound(float val, float range) // x small (0.0 < x < .01) so interpolation of fractional part is reasonable static float stab_log2f(float x) { - union - { - volatile float f; - volatile uint32_t i; - volatile unsigned char c[4]; - } __attribute__((packed)) u1, u2; + union { + volatile float f; + volatile uint32_t i; + volatile unsigned char c[4]; + } __attribute__((packed)) u1, u2; - u2.f = u1.f = x; - u1.i <<= 1; - u2.i &= 0xff800000; + u2.f = u1.f = x; + u1.i <<= 1; + u2.i &= 0xff800000; - // get and unbias the exponent, add in a linear interpolation of the fractional part - return (float) (u1.c[3] - 127) + (x / u2.f) - 1.0f; + // get and unbias the exponent, add in a linear interpolation of the fractional part + return (float)(u1.c[3] - 127) + (x / u2.f) - 1.0f; } // 0<=x<=1, 0<=p<=31 static float stab_powf(float x, uint8_t p) { - float retval = 1.0f; + float retval = 1.0f; - while (p) - { - if (p&1) - { - retval *= x; + while (p) { + if (p & 1) { + retval *= x; + } + x *= x; + p >>= 1; } - x *= x; - p >>= 1; - } - return retval; + return retval; } - static void SettingsBankUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) { StabilizationBankData bank, oldBank; + StabilizationBankGet(&oldBank); - if(flight_mode < 0) return; + if (flight_mode < 0) { + return; + } - switch(cast_struct_to_array(settings.FlightModeMap, settings.FlightModeMap.Stabilized1)[flight_mode]) - { + switch (cast_struct_to_array(settings.FlightModeMap, settings.FlightModeMap.Stabilized1)[flight_mode]) { case 0: - StabilizationSettingsBank1Get((StabilizationSettingsBank1Data *) &bank); + StabilizationSettingsBank1Get((StabilizationSettingsBank1Data *)&bank); break; case 1: - StabilizationSettingsBank2Get((StabilizationSettingsBank2Data *) &bank); + StabilizationSettingsBank2Get((StabilizationSettingsBank2Data *)&bank); break; case 2: - StabilizationSettingsBank3Get((StabilizationSettingsBank3Data *) &bank); + StabilizationSettingsBank3Get((StabilizationSettingsBank3Data *)&bank); break; default: memset(&bank, 0, sizeof(StabilizationBankDataPacked)); -// return; //bank number is invalid. All we can do is ignore it. +// return; //bank number is invalid. All we can do is ignore it. } - //Need to do this to prevent an infinite loop - if(memcmp(&oldBank, &bank, sizeof(StabilizationBankDataPacked)) != 0) - { + // Need to do this to prevent an infinite loop + if (memcmp(&oldBank, &bank, sizeof(StabilizationBankDataPacked)) != 0) { StabilizationBankSet(&bank); } } @@ -721,9 +718,10 @@ static void SettingsBankUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) static void BankUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) { StabilizationBankData bank; + StabilizationBankGet(&bank); -//this code will be needed if any other modules alter stabilizationbank +// this code will be needed if any other modules alter stabilizationbank /* StabilizationBankData curBank; if(flight_mode < 0) return; @@ -757,7 +755,7 @@ static void BankUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) default: return; //invalid bank number } -*/ + */ // Set the roll rate PID constants @@ -855,9 +853,9 @@ static void SettingsUpdatedCb(__attribute__((unused)) UAVObjEvent *ev) } // Compute time constant for vbar decay term based on a tau - vbar_decay = expf(-fakeDt / settings.VbarTau); + vbar_decay = expf(-fakeDt / settings.VbarTau); - //force flight mode update + // force flight mode update flight_mode = -1; // Rattitude flight mode anti-windup factor diff --git a/flight/modules/TxPID/txpid.c b/flight/modules/TxPID/txpid.c index 117349e2d..f0c269c01 100644 --- a/flight/modules/TxPID/txpid.c +++ b/flight/modules/TxPID/txpid.c @@ -168,18 +168,17 @@ static void updatePIDs(UAVObjEvent *ev) } StabilizationBankData bank; - switch(inst.BankNumber) - { + switch (inst.BankNumber) { case 0: - StabilizationSettingsBank1Get((StabilizationSettingsBank1Data *) &bank); + StabilizationSettingsBank1Get((StabilizationSettingsBank1Data *)&bank); break; case 1: - StabilizationSettingsBank2Get((StabilizationSettingsBank2Data *) &bank); + StabilizationSettingsBank2Get((StabilizationSettingsBank2Data *)&bank); break; case 2: - StabilizationSettingsBank2Get((StabilizationSettingsBank2Data *) &bank); + StabilizationSettingsBank2Get((StabilizationSettingsBank2Data *)&bank); break; default: @@ -317,18 +316,17 @@ static void updatePIDs(UAVObjEvent *ev) StabilizationSettingsSet(&stab); } if (needsUpdateBank) { - switch(inst.BankNumber) - { + switch (inst.BankNumber) { case 0: - StabilizationSettingsBank1Set((StabilizationSettingsBank1Data *) &bank); + StabilizationSettingsBank1Set((StabilizationSettingsBank1Data *)&bank); break; case 1: - StabilizationSettingsBank2Set((StabilizationSettingsBank2Data *) &bank); + StabilizationSettingsBank2Set((StabilizationSettingsBank2Data *)&bank); break; case 2: - StabilizationSettingsBank2Set((StabilizationSettingsBank2Data *) &bank); + StabilizationSettingsBank2Set((StabilizationSettingsBank2Data *)&bank); break; default: diff --git a/flight/pios/common/pios_rfm22b.c b/flight/pios/common/pios_rfm22b.c index c663da70d..603743cf0 100644 --- a/flight/pios/common/pios_rfm22b.c +++ b/flight/pios/common/pios_rfm22b.c @@ -1,57 +1,321 @@ /** - ****************************************************************************** - * @addtogroup PIOS PIOS Core hardware abstraction layer - * @{ - * @addtogroup PIOS_RFM22B Radio Functions - * @brief PIOS interface for for the RFM22B radio - * @{ - * - * @file pios_rfm22b.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. - * @brief Implements a driver the the RFM22B driver - * @see The GNU Public License (GPL) Version 3 - * - *****************************************************************************/ + ****************************************************************************** + * + * @addtogroup + * PIOS + * PIOS + * Core + * hardware + * abstraction + * layer + * + * @{ + * + * @addtogroup + * + * + * PIOS_RFM22B + * Radio + * Functions + * + * @brief + * PIOS + * interface + * for + * for + * the + * RFM22B + * radio + * + * @{ + * + * + * @file + * + * + * + * + * + * + * pios_rfm22b.c + * + * @author + * + * + * + * + * The + * OpenPilot + * Team, + * http://www.openpilot.org + * Copyright + * (C) + * 2012. + * + * @brief + * + * + * + * + * + * Implements + * a + * driver + * the + * the + * RFM22B + * driver + * + * @see + * + * + * + * + * + * + * + * The + * GNU + * Public + * License + * (GPL) + * Version + * 3 + * + *****************************************************************************/ /* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ + * + * This + * program + * is + * free + * software; + * you + * can + * redistribute + * it + * and/or + * modify + * + * it + * under + * the + * terms + * of + * the + * GNU + * General + * Public + * License + * as + * published + * by + * + * the + * Free + * Software + * Foundation; + * either + * version + * 3 + * of + * the + * License, + * or + * + * (at + * your + * option) + * any + * later + * version. + * + * + * This + * program + * is + * distributed + * in + * the + * hope + * that + * it + * will + * be + * useful, + * but + * + * WITHOUT + * ANY + * WARRANTY; + * without + * even + * the + * implied + * warranty + * of + * MERCHANTABILITY + * + * or + * FITNESS + * FOR + * A + * PARTICULAR + * PURPOSE. + * See + * the + * GNU + * General + * Public + * License + * + * for + * more + * details. + * + * + * You + * should + * have + * received + * a + * copy + * of + * the + * GNU + * General + * Public + * License + * along + * + * with + * this + * program; + * if + * not, + * write + * to + * the + * Free + * Software + * Foundation, + * Inc., + * + * 59 + * Temple + * Place, + * Suite + * 330, + * Boston, + * MA + * 02111-1307 + * USA + */ -// ***************************************************************** -// RFM22B hardware layer -// -// This module uses the RFM22B's internal packet handling hardware to -// encapsulate our own packet data. -// -// The RFM22B internal hardware packet handler configuration is as follows: -// -// 6-byte (32-bit) preamble .. alternating 0's & 1's -// 4-byte (32-bit) sync -// 1-byte packet length (number of data bytes to follow) -// 0 to 255 user data bytes -// 4 byte ECC -// -// OR in PPM only mode: -// -// 6-byte (32-bit) preamble .. alternating 0's & 1's -// 4-byte (32-bit) sync -// 1-byte packet length (number of data bytes to follow) -// 1 byte valid bitmask -// 8 PPM values (0-255) -// 1 byte CRC -// -// ***************************************************************** +/* + * ***************************************************************** + * RFM22B + * hardware + * layer + * + * This + * module + * uses + * the + * RFM22B's + * internal + * packet + * handling + * hardware + * to + * encapsulate + * our + * own + * packet + * data. + * + * The + * RFM22B + * internal + * hardware + * packet + * handler + * configuration + * is + * as + * follows: + * + * 6-byte + * (32-bit) + * preamble + * .. + * alternating + * 0's + * & + * 1's + * 4-byte + * (32-bit) + * sync + * 1-byte + * packet + * length + * (number + * of + * data + * bytes + * to + * follow) + * 0 + * to + * 255 + * user + * data + * bytes + * 4 + * byte + * ECC + * + * OR + * in + * PPM + * only + * mode: + * + * 6-byte + * (32-bit) + * preamble + * .. + * alternating + * 0's + * & + * 1's + * 4-byte + * (32-bit) + * sync + * 1-byte + * packet + * length + * (number + * of + * data + * bytes + * to + * follow) + * 1 + * byte + * valid + * bitmask + * 8 + * PPM + * values + * (0-255) + * 1 + * byte + * CRC + * + * ***************************************************************** + + */ #include "pios.h" @@ -62,48 +326,116 @@ #include #include -/* Local Defines */ -#define STACK_SIZE_BYTES 200 -#define TASK_PRIORITY (tskIDLE_PRIORITY + 2) -#define ISR_TIMEOUT 1 // ms -#define EVENT_QUEUE_SIZE 5 -#define RFM22B_DEFAULT_RX_DATARATE RFM22_datarate_9600 -#define RFM22B_DEFAULT_TX_POWER RFM22_tx_pwr_txpow_0 -#define RFM22B_NOMINAL_CARRIER_FREQUENCY 430000000 -#define RFM22B_LINK_QUALITY_THRESHOLD 20 -#define RFM22B_DEFAULT_MIN_CHANNEL 0 -#define RFM22B_DEFAULT_MAX_CHANNEL 250 -#define RFM22B_DEFAULT_CHANNEL_SET 24 -#define RFM22B_PPM_ONLY_DATARATE RFM22_datarate_9600 +/* + * Local + * Defines + * */ +#define STACK_SIZE_BYTES 200 +#define TASK_PRIORITY (tskIDLE_PRIORITY + 2) +#define ISR_TIMEOUT 1 /* + * ms */ +#define EVENT_QUEUE_SIZE 5 +#define RFM22B_DEFAULT_RX_DATARATE RFM22_datarate_9600 +#define RFM22B_DEFAULT_TX_POWER RFM22_tx_pwr_txpow_0 +#define RFM22B_NOMINAL_CARRIER_FREQUENCY 430000000 +#define RFM22B_LINK_QUALITY_THRESHOLD 20 +#define RFM22B_DEFAULT_MIN_CHANNEL 0 +#define RFM22B_DEFAULT_MAX_CHANNEL 250 +#define RFM22B_DEFAULT_CHANNEL_SET 24 +#define RFM22B_PPM_ONLY_DATARATE RFM22_datarate_9600 -// The maximum amount of time without activity before initiating a reset. -#define PIOS_RFM22B_SUPERVISOR_TIMEOUT 150 // ms +/* + * The + * maximum + * amount + * of + * time + * without + * activity + * before + * initiating + * a + * reset. */ +#define PIOS_RFM22B_SUPERVISOR_TIMEOUT 150 /* + * ms */ -// this is too adjust the RF module so that it is on frequency -#define OSC_LOAD_CAP 0x7F // cap = 12.5pf .. default +/* + * this + * is + * too + * adjust + * the + * RF + * module + * so + * that + * it + * is + * on + * frequency */ +#define OSC_LOAD_CAP 0x7F /* + * cap + * = + * 12.5pf + * .. + * default */ -#define TX_PREAMBLE_NIBBLES 12 // 7 to 511 (number of nibbles) -#define RX_PREAMBLE_NIBBLES 6 // 5 to 31 (number of nibbles) -#define SYNC_BYTES 4 -#define HEADER_BYTES 4 -#define LENGTH_BYTES 1 +#define TX_PREAMBLE_NIBBLES 12 /* + * 7 + * to + * 511 + * (number + * of + * nibbles) */ +#define RX_PREAMBLE_NIBBLES 6 /* + * 5 + * to + * 31 + * (number + * of + * nibbles) */ +#define SYNC_BYTES 4 +#define HEADER_BYTES 4 +#define LENGTH_BYTES 1 -// the size of the rf modules internal FIFO buffers -#define FIFO_SIZE 64 +/* + * the + * size + * of + * the + * rf + * modules + * internal + * FIFO + * buffers */ +#define FIFO_SIZE 64 -#define TX_FIFO_HI_WATERMARK 62 // 0-63 -#define TX_FIFO_LO_WATERMARK 32 // 0-63 +#define TX_FIFO_HI_WATERMARK 62 /* + * 0-63 */ +#define TX_FIFO_LO_WATERMARK 32 /* + * 0-63 */ -#define RX_FIFO_HI_WATERMARK 32 // 0-63 +#define RX_FIFO_HI_WATERMARK 32 /* + * 0-63 */ -// preamble byte (preceeds SYNC_BYTE's) -#define PREAMBLE_BYTE 0x55 +/* + * preamble + * byte + * (preceeds + * SYNC_BYTE's) */ +#define PREAMBLE_BYTE 0x55 -// RF sync bytes (32-bit in all) -#define SYNC_BYTE_1 0x2D -#define SYNC_BYTE_2 0xD4 -#define SYNC_BYTE_3 0x4B -#define SYNC_BYTE_4 0x59 +/* + * RF + * sync + * bytes + * (32-bit + * in + * all) */ +#define SYNC_BYTE_1 0x2D +#define SYNC_BYTE_2 0xD4 +#define SYNC_BYTE_3 0x4B +#define SYNC_BYTE_4 0x59 #ifndef RX_LED_ON #define RX_LED_ON @@ -116,2431 +448,40269 @@ #define USB_LED_OFF #endif -/* Local type definitions */ - -struct pios_rfm22b_transition { - enum pios_radio_event (*entry_fn)(struct pios_rfm22b_dev *rfm22b_dev); - enum pios_radio_state next_state[RADIO_EVENT_NUM_EVENTS]; -}; - -// Must ensure these prefilled arrays match the define sizes -static const uint8_t FULL_PREAMBLE[FIFO_SIZE] = { - PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, - PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, - PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, - PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, - PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, - PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, - PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, - PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, - PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, - PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, - PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, - PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, - PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE -}; // 64 bytes -static const uint8_t HEADER[(TX_PREAMBLE_NIBBLES + 1) / 2 + 2] = { PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, SYNC_BYTE_1, SYNC_BYTE_2 }; -static const uint8_t OUT_FF[64] = { - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF -}; -// The randomized channel list. -static const uint8_t channel_list[] = { 68, 34, 2, 184, 166, 94, 204, 18, 47, 118, 239, 176, 5, 213, 218, 186, 104, 160, 199, 209, 231, 197, 92, 191, 88, 129, 40, 19, 93, 200, 156, 14, 247, 182, 193, 194, 208, 210, 248, 76, 244, 48, 179, 105, 25, 74, 155, 203, 39, 97, 195, 81, 83, 180, 134, 172, 235, 132, 198, 119, 207, 154, 0, 61, 140, 171, 245, 26, 95, 3, 22, 62, 169, 55, 127, 144, 45, 33, 170, 91, 158, 167, 63, 201, 41, 21, 190, 51, 103, 49, 189, 205, 240, 89, 181, 149, 6, 157, 249, 230, 115, 72, 163, 17, 29, 99, 28, 117, 219, 73, 78, 53, 69, 216, 161, 124, 110, 242, 214, 145, 13, 11, 220, 113, 138, 58, 54, 162, 237, 37, 152, 187, 232, 77, 126, 85, 38, 238, 173, 23, 188, 100, 131, 226, 31, 9, 114, 106, 221, 42, 233, 139, 4, 241, 96, 211, 8, 98, 121, 147, 24, 217, 27, 87, 122, 125, 135, 148, 178, 71, 206, 57, 141, 35, 30, 246, 159, 16, 32, 15, 229, 20, 12, 223, 150, 101, 79, 56, 102, 111, 174, 236, 137, 143, 52, 225, 64, 224, 112, 168, 243, 130, 108, 202, 123, 146, 228, 75, 46, 153, 7, 192, 175, 151, 222, 59, 82, 90, 1, 65, 109, 44, 165, 84, 43, 36, 128, 196, 67, 80, 136, 86, 70, 234, 66, 185, 10, 164, 177, 116, 50, 107, 183, 215, 212, 60, 227, 133, 120, 142 }; - -/* Local function forwared declarations */ -static void pios_rfm22_task(void *parameters); -static bool pios_rfm22_readStatus(struct pios_rfm22b_dev *rfm22b_dev); -static void pios_rfm22_setDatarate(struct pios_rfm22b_dev *rfm22b_dev); -static void rfm22_rxFailure(struct pios_rfm22b_dev *rfm22b_dev); -static void pios_rfm22_inject_event(struct pios_rfm22b_dev *rfm22b_dev, enum pios_radio_event event, bool inISR); -static enum pios_radio_event rfm22_init(struct pios_rfm22b_dev *rfm22b_dev); -static enum pios_radio_event radio_setRxMode(struct pios_rfm22b_dev *rfm22b_dev); -static enum pios_radio_event radio_rxData(struct pios_rfm22b_dev *rfm22b_dev); -static enum pios_radio_event radio_receivePacket(struct pios_rfm22b_dev *rfm22b_dev, uint8_t *p, uint16_t rx_len); -static enum pios_radio_event radio_txStart(struct pios_rfm22b_dev *rfm22b_dev); -static enum pios_radio_event radio_txData(struct pios_rfm22b_dev *rfm22b_dev); -static enum pios_radio_event rfm22_txFailure(struct pios_rfm22b_dev *rfm22b_dev); -static enum pios_radio_event rfm22_process_state_transition(struct pios_rfm22b_dev *rfm22b_dev, enum pios_radio_event event); -static void rfm22_process_event(struct pios_rfm22b_dev *rfm22b_dev, enum pios_radio_event event); -static enum pios_radio_event rfm22_timeout(struct pios_rfm22b_dev *rfm22b_dev); -static enum pios_radio_event rfm22_error(struct pios_rfm22b_dev *rfm22b_dev); -static enum pios_radio_event rfm22_fatal_error(struct pios_rfm22b_dev *rfm22b_dev); -static void rfm22b_add_rx_status(struct pios_rfm22b_dev *rfm22b_dev, enum pios_rfm22b_rx_packet_status status); -static void rfm22_setNominalCarrierFrequency(struct pios_rfm22b_dev *rfm22b_dev, uint8_t init_chan); -static bool rfm22_setFreqHopChannel(struct pios_rfm22b_dev *rfm22b_dev, uint8_t channel); -static void rfm22_updatePairStatus(struct pios_rfm22b_dev *radio_dev); -static void rfm22_calculateLinkQuality(struct pios_rfm22b_dev *rfm22b_dev); -static bool rfm22_isConnected(struct pios_rfm22b_dev *rfm22b_dev); -static bool rfm22_isCoordinator(struct pios_rfm22b_dev *rfm22b_dev); -static uint32_t rfm22_destinationID(struct pios_rfm22b_dev *rfm22b_dev); -static bool rfm22_timeToSend(struct pios_rfm22b_dev *rfm22b_dev); -static void rfm22_synchronizeClock(struct pios_rfm22b_dev *rfm22b_dev); -static portTickType rfm22_coordinatorTime(struct pios_rfm22b_dev *rfm22b_dev, portTickType ticks); -static uint8_t rfm22_calcChannel(struct pios_rfm22b_dev *rfm22b_dev, uint8_t index); -static uint8_t rfm22_calcChannelFromClock(struct pios_rfm22b_dev *rfm22b_dev); -static bool rfm22_changeChannel(struct pios_rfm22b_dev *rfm22b_dev); -static void rfm22_clearLEDs(); - -// Utility functions. -static uint32_t pios_rfm22_time_difference_ms(portTickType start_time, portTickType end_time); -static struct pios_rfm22b_dev *pios_rfm22_alloc(void); - -// SPI read/write functions -static void rfm22_assertCs(struct pios_rfm22b_dev *rfm22b_dev); -static void rfm22_deassertCs(struct pios_rfm22b_dev *rfm22b_dev); -static void rfm22_claimBus(struct pios_rfm22b_dev *rfm22b_dev); -static void rfm22_releaseBus(struct pios_rfm22b_dev *rfm22b_dev); -static void rfm22_write_claim(struct pios_rfm22b_dev *rfm22b_dev, uint8_t addr, uint8_t data); -static void rfm22_write(struct pios_rfm22b_dev *rfm22b_dev, uint8_t addr, uint8_t data); -static uint8_t rfm22_read(struct pios_rfm22b_dev *rfm22b_dev, uint8_t addr); -/* The state transition table */ -static const struct pios_rfm22b_transition rfm22b_transitions[RADIO_STATE_NUM_STATES] = { - // Initialization thread - [RADIO_STATE_UNINITIALIZED] = { - .entry_fn = 0, - .next_state = { - [RADIO_EVENT_INITIALIZE] = RADIO_STATE_INITIALIZING, - [RADIO_EVENT_ERROR] = RADIO_STATE_ERROR, - }, - }, - [RADIO_STATE_INITIALIZING] = { - .entry_fn = rfm22_init, - .next_state = { - [RADIO_EVENT_INITIALIZED] = RADIO_STATE_RX_MODE, - [RADIO_EVENT_ERROR] = RADIO_STATE_ERROR, - [RADIO_EVENT_INITIALIZE] = RADIO_STATE_INITIALIZING, - [RADIO_EVENT_FATAL_ERROR] = RADIO_STATE_FATAL_ERROR, - }, - }, - [RADIO_STATE_RX_MODE] = { - .entry_fn = radio_setRxMode, - .next_state = { - [RADIO_EVENT_INT_RECEIVED] = RADIO_STATE_RX_DATA, - [RADIO_EVENT_TX_START] = RADIO_STATE_TX_START, - [RADIO_EVENT_RX_MODE] = RADIO_STATE_RX_MODE, - [RADIO_EVENT_TIMEOUT] = RADIO_STATE_TIMEOUT, - [RADIO_EVENT_ERROR] = RADIO_STATE_ERROR, - [RADIO_EVENT_INITIALIZE] = RADIO_STATE_INITIALIZING, - [RADIO_EVENT_FATAL_ERROR] = RADIO_STATE_FATAL_ERROR, - }, - }, - [RADIO_STATE_RX_DATA] = { - .entry_fn = radio_rxData, - .next_state = { - [RADIO_EVENT_INT_RECEIVED] = RADIO_STATE_RX_DATA, - [RADIO_EVENT_TX_START] = RADIO_STATE_TX_START, - [RADIO_EVENT_RX_COMPLETE] = RADIO_STATE_TX_START, - [RADIO_EVENT_RX_MODE] = RADIO_STATE_RX_MODE, - [RADIO_EVENT_TIMEOUT] = RADIO_STATE_TIMEOUT, - [RADIO_EVENT_ERROR] = RADIO_STATE_ERROR, - [RADIO_EVENT_INITIALIZE] = RADIO_STATE_INITIALIZING, - [RADIO_EVENT_FATAL_ERROR] = RADIO_STATE_FATAL_ERROR, - }, - }, - [RADIO_STATE_TX_START] = { - .entry_fn = radio_txStart, - .next_state = { - [RADIO_EVENT_INT_RECEIVED] = RADIO_STATE_TX_DATA, - [RADIO_EVENT_RX_MODE] = RADIO_STATE_RX_MODE, - [RADIO_EVENT_TIMEOUT] = RADIO_STATE_TIMEOUT, - [RADIO_EVENT_ERROR] = RADIO_STATE_ERROR, - [RADIO_EVENT_INITIALIZE] = RADIO_STATE_INITIALIZING, - [RADIO_EVENT_FATAL_ERROR] = RADIO_STATE_FATAL_ERROR, - }, - }, - [RADIO_STATE_TX_DATA] = { - .entry_fn = radio_txData, - .next_state = { - [RADIO_EVENT_INT_RECEIVED] = RADIO_STATE_TX_DATA, - [RADIO_EVENT_RX_MODE] = RADIO_STATE_RX_MODE, - [RADIO_EVENT_TIMEOUT] = RADIO_STATE_TIMEOUT, - [RADIO_EVENT_ERROR] = RADIO_STATE_ERROR, - [RADIO_EVENT_INITIALIZE] = RADIO_STATE_INITIALIZING, - [RADIO_EVENT_FATAL_ERROR] = RADIO_STATE_FATAL_ERROR, - }, - }, - [RADIO_STATE_TX_FAILURE] = { - .entry_fn = rfm22_txFailure, - .next_state = { - [RADIO_EVENT_TX_START] = RADIO_STATE_TX_START, - [RADIO_EVENT_TIMEOUT] = RADIO_STATE_TIMEOUT, - [RADIO_EVENT_ERROR] = RADIO_STATE_ERROR, - [RADIO_EVENT_INITIALIZE] = RADIO_STATE_INITIALIZING, - [RADIO_EVENT_FATAL_ERROR] = RADIO_STATE_FATAL_ERROR, - }, - }, - [RADIO_STATE_TIMEOUT] = { - .entry_fn = rfm22_timeout, - .next_state = { - [RADIO_EVENT_TX_START] = RADIO_STATE_TX_START, - [RADIO_EVENT_RX_MODE] = RADIO_STATE_RX_MODE, - [RADIO_EVENT_ERROR] = RADIO_STATE_ERROR, - [RADIO_EVENT_INITIALIZE] = RADIO_STATE_INITIALIZING, - [RADIO_EVENT_FATAL_ERROR] = RADIO_STATE_FATAL_ERROR, - }, - }, - [RADIO_STATE_ERROR] = { - .entry_fn = rfm22_error, - .next_state = { - [RADIO_EVENT_INITIALIZE] = RADIO_STATE_INITIALIZING, - [RADIO_EVENT_FATAL_ERROR] = RADIO_STATE_FATAL_ERROR, - }, - }, - [RADIO_STATE_FATAL_ERROR] = { - .entry_fn = rfm22_fatal_error, - .next_state = {}, - }, -}; -// xtal 10 ppm, 434MHz -static const uint32_t data_rate[] = { - 9600, // 96 kbps, 433 HMz, 30 khz freq dev - 19200, // 19.2 kbps, 433 MHz, 45 khz freq dev - 32000, // 32 kbps, 433 MHz, 45 khz freq dev - 57600, // 57.6 kbps, 433 MHz, 45 khz freq dev - 64000, // 64 kbps, 433 MHz, 45 khz freq dev - 100000, // 100 kbps, 433 MHz, 60 khz freq dev - 128000, // 128 kbps, 433 MHz, 90 khz freq dev - 192000, // 192 kbps, 433 MHz, 128 khz freq dev - 256000, // 256 kbps, 433 MHz, 150 khz freq dev -}; -static const uint8_t reg_1C[] = { 0x01, 0x05, 0x06, 0x95, 0x95, 0x81, 0x88, 0x8B, 0x8D }; // rfm22_if_filter_bandwidth -static const uint8_t reg_1D[] = { 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40 }; // rfm22_afc_loop_gearshift_override -static const uint8_t reg_1E[] = { 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x02 }; // rfm22_afc_timing_control -static const uint8_t reg_1F[] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }; // rfm22_clk_recovery_gearshift_override -static const uint8_t reg_20[] = { 0xA1, 0xD0, 0x7D, 0x68, 0x5E, 0x78, 0x5E, 0x3F, 0x2F }; // rfm22_clk_recovery_oversampling_ratio -static const uint8_t reg_21[] = { 0x20, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02 }; // rfm22_clk_recovery_offset2 -static const uint8_t reg_22[] = { 0x4E, 0x9D, 0x06, 0x3A, 0x5D, 0x11, 0x5D, 0x0C, 0xBB }; // rfm22_clk_recovery_offset1 -static const uint8_t reg_23[] = { 0xA5, 0x49, 0x25, 0x93, 0x86, 0x11, 0x86, 0x4A, 0x0D }; // rfm22_clk_recovery_offset0 -static const uint8_t reg_24[] = { 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x06, 0x07 }; // rfm22_clk_recovery_timing_loop_gain1 -static const uint8_t reg_25[] = { 0x34, 0x88, 0x77, 0x29, 0xE2, 0x90, 0xE2, 0x1A, 0xFF }; // rfm22_clk_recovery_timing_loop_gain0 -static const uint8_t reg_2A[] = { 0x1E, 0x24, 0x28, 0x3C, 0x3C, 0x50, 0x50, 0x50, 0x50 }; // rfm22_afc_limiter .. AFC_pull_in_range = �AFCLimiter[7:0] x (hbsel+1) x 625 Hz -static const uint8_t reg_58[] = { 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xED }; // rfm22_cpcuu -static const uint8_t reg_69[] = { 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60 }; // rfm22_agc_override1 -static const uint8_t reg_6E[] = { 0x4E, 0x9D, 0x08, 0x0E, 0x10, 0x19, 0x20, 0x31, 0x41 }; // rfm22_tx_data_rate1 -static const uint8_t reg_6F[] = { 0xA5, 0x49, 0x31, 0xBF, 0x62, 0x9A, 0xC5, 0x27, 0x89 }; // rfm22_tx_data_rate0 -static const uint8_t reg_70[] = { 0x2C, 0x2C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C }; // rfm22_modulation_mode_control1 -static const uint8_t reg_71[] = { 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23 }; // rfm22_modulation_mode_control2 -static const uint8_t reg_72[] = { 0x30, 0x48, 0x48, 0x48, 0x48, 0x60, 0x90, 0xCD, 0x0F }; // rfm22_frequency_deviation -static const uint8_t packet_time[] = { 80, 40, 25, 15, 13, 10, 8, 6, 5 }; -static const uint8_t packet_time_ppm[] = { 26, 25, 25, 15, 13, 10, 8, 6, 5 }; -static const uint8_t num_channels[] = { 4, 4, 4, 6, 8, 8, 10, 12, 16 }; -static struct pios_rfm22b_dev *g_rfm22b_dev = NULL; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/* + * Local + * type + * definitions + * */ + + struct pios_rfm22b_transition { + enum + pios_radio_event + ( + * + entry_fn) + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + enum + pios_radio_state + next_state + [ + RADIO_EVENT_NUM_EVENTS]; + }; + +/* + * Must + * ensure + * these + * prefilled + * arrays + * match + * the + * define + * sizes */ + static const uint8_t FULL_PREAMBLE[FIFO_SIZE] = + { + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE, + PREAMBLE_BYTE + }; /* + * 64 + * bytes */ + static const uint8_t HEADER[(TX_PREAMBLE_NIBBLES + 1) / 2 + 2] = { PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, SYNC_BYTE_1, SYNC_BYTE_2 }; + static const uint8_t OUT_FF[64] = + { + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF + }; + /* + * The + * randomized + * channel + * list. */ + static const uint8_t channel_list[] = + { + 68, + 34, + 2, + 184, 166, 94, 204, 18, 47, 118, 239, 176, 5, 213, 218, 186, 104, 160, 199, 209, 231, 197, 92, 191, 88, 129, 40, 19, 93, 200, 156, 14, 247, 182, 193, 194, 208, 210, 248, 76, 244, 48, 179, 105, 25, 74, 155, 203, + 39, + 97, + 195, 81, 83, 180, 134, 172, 235, 132, 198, 119, 207, + 154, + 0, + 61, + 140, 171, 245, 26, 95, 3, 22, 62, 169, 55, 127, 144, 45, 33, 170, 91, 158, 167, 63, 201, 41, 21, 190, 51, 103, 49, 189, 205, 240, 89, 181, 149, 6, 157, 249, 230, 115, 72, 163, 17, 29, 99, 28, 117, 219, + 73, + 78, + 53, 69, + 216, + 161, + 124, + 110, 242, 214, 145, 13, 11, 220, 113, 138, 58, 54, 162, 237, 37, 152, 187, 232, 77, 126, 85, 38, 238, 173, 23, 188, 100, 131, 226, 31, 9, 114, 106, 221, 42, 233, 139, 4, 241, 96, 211, 8, 98, 121, 147, 24, + 217, + 27, + 87, + 122, + 125, + 135, + 148, 178, 71, 206, 57, 141, 35, 30, 246, 159, 16, 32, 15, 229, 20, 12, 223, 150, 101, 79, 56, 102, 111, 174, 236, 137, 143, 52, 225, 64, 224, 112, 168, 243, 130, 108, 202, 123, 146, 228, 75, 46, 153, 7, 192, + 175, + 151, + 222, + 59, + 82, + 90, 1, 65, 109, 44, 165, 84, 43, 36, 128, 196, 67, 80, 136, 86, 70, 234, 66, 185, 10, 164, 177, 116, 50, 107, 183, 215, 212, 60, 227, 133, 120, 142 + }; + +/* + * Local + * function + * forwared + * declarations + * */ + static void pios_rfm22_task + ( + void + * + parameters); + static bool pios_rfm22_readStatus + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static void pios_rfm22_setDatarate + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static void rfm22_rxFailure + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static void pios_rfm22_inject_event + ( + struct + pios_rfm22b_dev + * rfm22b_dev, + enum + pios_radio_event + event, + bool + inISR); + static enum pios_radio_event rfm22_init + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static enum pios_radio_event radio_setRxMode + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static enum pios_radio_event radio_rxData + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static enum pios_radio_event radio_receivePacket + ( + struct + pios_rfm22b_dev + * rfm22b_dev, + uint8_t + * + p, + uint16_t + rx_len); + static enum pios_radio_event radio_txStart + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static enum pios_radio_event radio_txData + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static enum pios_radio_event rfm22_txFailure + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static enum pios_radio_event rfm22_process_state_transition + ( + struct + pios_rfm22b_dev + * rfm22b_dev, + enum + pios_radio_event + event); + static void rfm22_process_event + ( + struct + pios_rfm22b_dev + * rfm22b_dev, + enum + pios_radio_event + event); + static enum pios_radio_event rfm22_timeout + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static enum pios_radio_event rfm22_error + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static enum pios_radio_event rfm22_fatal_error + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static void rfm22b_add_rx_status + ( + struct + pios_rfm22b_dev + * rfm22b_dev, + enum + pios_rfm22b_rx_packet_status + status); + static void rfm22_setNominalCarrierFrequency + ( + struct + pios_rfm22b_dev + * rfm22b_dev, + uint8_t + init_chan); + static bool rfm22_setFreqHopChannel + ( + struct + pios_rfm22b_dev + * rfm22b_dev, + uint8_t + channel); + static void rfm22_updatePairStatus + ( + struct + pios_rfm22b_dev + * + radio_dev); + static void rfm22_calculateLinkQuality + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static bool rfm22_isConnected + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static bool rfm22_isCoordinator + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static uint32_t rfm22_destinationID + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static bool rfm22_timeToSend + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static void rfm22_synchronizeClock + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static portTickType rfm22_coordinatorTime + ( + struct + pios_rfm22b_dev + * rfm22b_dev, + portTickType + ticks); + static uint8_t rfm22_calcChannel + ( + struct + pios_rfm22b_dev + * rfm22b_dev, + uint8_t + index); + static uint8_t rfm22_calcChannelFromClock + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static bool rfm22_changeChannel + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static void rfm22_clearLEDs + ( + ); + +/* + * Utility + * functions. */ + static uint32_t pios_rfm22_time_difference_ms + ( + portTickType + start_time, + portTickType + end_time); + static struct pios_rfm22b_dev *pios_rfm22_alloc + ( + void); + +/* + * SPI + * read/write + * functions */ + static void rfm22_assertCs + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static void rfm22_deassertCs + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static void rfm22_claimBus + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static void rfm22_releaseBus + ( + struct + pios_rfm22b_dev + * + rfm22b_dev); + static void rfm22_write_claim + ( + struct + pios_rfm22b_dev + * rfm22b_dev, + uint8_t + addr, + uint8_t + data); + static void rfm22_write + ( + struct + pios_rfm22b_dev + * rfm22b_dev, + uint8_t + addr, + uint8_t + data); + static uint8_t rfm22_read + ( + struct + pios_rfm22b_dev + * rfm22b_dev, + uint8_t + addr); + + +/* + * The + * state + * transition + * table + * */ + static const struct pios_rfm22b_transition rfm22b_transitions[RADIO_STATE_NUM_STATES] = + { + /* + * Initialization + * thread */ + [ + RADIO_STATE_UNINITIALIZED + ] + = + { + . + entry_fn + = + 0, + . + next_state + = + { + [ + RADIO_EVENT_INITIALIZE + ] + = + RADIO_STATE_INITIALIZING, + [ + RADIO_EVENT_ERROR + ] + = + RADIO_STATE_ERROR, + }, + }, + [ + RADIO_STATE_INITIALIZING + ] + = + { + . + entry_fn + = + rfm22_init, + . + next_state + = + { + [ + RADIO_EVENT_INITIALIZED + ] + = + RADIO_STATE_RX_MODE, + [ + RADIO_EVENT_ERROR + ] + = + RADIO_STATE_ERROR, + [ + RADIO_EVENT_INITIALIZE + ] + = + RADIO_STATE_INITIALIZING, + [ + RADIO_EVENT_FATAL_ERROR + ] + = + RADIO_STATE_FATAL_ERROR, + }, + }, + + [ + RADIO_STATE_RX_MODE + ] + = + { + . + entry_fn + = + radio_setRxMode, + . + next_state + = + { + [ + RADIO_EVENT_INT_RECEIVED + ] + = + RADIO_STATE_RX_DATA, + [ + RADIO_EVENT_TX_START + ] + = + RADIO_STATE_TX_START, + [ + RADIO_EVENT_RX_MODE + ] + = + RADIO_STATE_RX_MODE, + [ + RADIO_EVENT_TIMEOUT + ] + = + RADIO_STATE_TIMEOUT, + [ + RADIO_EVENT_ERROR + ] + = + RADIO_STATE_ERROR, + [ + RADIO_EVENT_INITIALIZE + ] + = + RADIO_STATE_INITIALIZING, + [ + RADIO_EVENT_FATAL_ERROR + ] + = + RADIO_STATE_FATAL_ERROR, + }, + }, + [ + RADIO_STATE_RX_DATA + ] + = + { + . + entry_fn + = + radio_rxData, + . + next_state + = + { + [ + RADIO_EVENT_INT_RECEIVED + ] + = + RADIO_STATE_RX_DATA, + [ + RADIO_EVENT_TX_START + ] + = + RADIO_STATE_TX_START, + [ + RADIO_EVENT_RX_COMPLETE + ] + = + RADIO_STATE_TX_START, + [ + RADIO_EVENT_RX_MODE + ] + = + RADIO_STATE_RX_MODE, + [ + RADIO_EVENT_TIMEOUT + ] + = + RADIO_STATE_TIMEOUT, + [ + RADIO_EVENT_ERROR + ] + = + RADIO_STATE_ERROR, + [ + RADIO_EVENT_INITIALIZE + ] + = + RADIO_STATE_INITIALIZING, + [ + RADIO_EVENT_FATAL_ERROR + ] + = + RADIO_STATE_FATAL_ERROR, + }, + }, + [ + RADIO_STATE_TX_START + ] + = + { + . + entry_fn + = + radio_txStart, + . + next_state + = + { + [ + RADIO_EVENT_INT_RECEIVED + ] + = + RADIO_STATE_TX_DATA, + [ + RADIO_EVENT_RX_MODE + ] + = + RADIO_STATE_RX_MODE, + [ + RADIO_EVENT_TIMEOUT + ] + = + RADIO_STATE_TIMEOUT, + [ + RADIO_EVENT_ERROR + ] + = + RADIO_STATE_ERROR, + [ + RADIO_EVENT_INITIALIZE + ] + = + RADIO_STATE_INITIALIZING, + [ + RADIO_EVENT_FATAL_ERROR + ] + = + RADIO_STATE_FATAL_ERROR, + }, + }, + [ + RADIO_STATE_TX_DATA + ] + = + { + . + entry_fn + = + radio_txData, + . + next_state + = + { + [ + RADIO_EVENT_INT_RECEIVED + ] + = + RADIO_STATE_TX_DATA, + [ + RADIO_EVENT_RX_MODE + ] + = + RADIO_STATE_RX_MODE, + [ + RADIO_EVENT_TIMEOUT + ] + = + RADIO_STATE_TIMEOUT, + [ + RADIO_EVENT_ERROR + ] + = + RADIO_STATE_ERROR, + [ + RADIO_EVENT_INITIALIZE + ] + = + RADIO_STATE_INITIALIZING, + [ + RADIO_EVENT_FATAL_ERROR + ] + = + RADIO_STATE_FATAL_ERROR, + }, + }, + [ + RADIO_STATE_TX_FAILURE + ] + = + { + . + entry_fn + = + rfm22_txFailure, + . + next_state + = + { + [ + RADIO_EVENT_TX_START + ] + = + RADIO_STATE_TX_START, + [ + RADIO_EVENT_TIMEOUT + ] + = + RADIO_STATE_TIMEOUT, + [ + RADIO_EVENT_ERROR + ] + = + RADIO_STATE_ERROR, + [ + RADIO_EVENT_INITIALIZE + ] + = + RADIO_STATE_INITIALIZING, + [ + RADIO_EVENT_FATAL_ERROR + ] + = + RADIO_STATE_FATAL_ERROR, + }, + }, + [ + RADIO_STATE_TIMEOUT + ] + = + { + . + entry_fn + = + rfm22_timeout, + . + next_state + = + { + [ + RADIO_EVENT_TX_START + ] + = + RADIO_STATE_TX_START, + [ + RADIO_EVENT_RX_MODE + ] + = + RADIO_STATE_RX_MODE, + [ + RADIO_EVENT_ERROR + ] + = + RADIO_STATE_ERROR, + [ + RADIO_EVENT_INITIALIZE + ] + = + RADIO_STATE_INITIALIZING, + [ + RADIO_EVENT_FATAL_ERROR + ] + = + RADIO_STATE_FATAL_ERROR, + }, + }, + [ + RADIO_STATE_ERROR + ] + = + { + . + entry_fn + = + rfm22_error, + . + next_state + = + { + [ + RADIO_EVENT_INITIALIZE + ] + = + RADIO_STATE_INITIALIZING, + [ + RADIO_EVENT_FATAL_ERROR + ] + = + RADIO_STATE_FATAL_ERROR, + }, + }, + [ + RADIO_STATE_FATAL_ERROR + ] + = + { + . + entry_fn + = + rfm22_fatal_error, + . + next_state + = + { }, + }, + }; + +/* + * xtal + * 10 + * ppm, + * 434MHz */ + static const uint32_t data_rate[] = + { + 9600, /* + * 96 + * kbps, + * 433 + * HMz, + * 30 + * khz + * freq + * dev */ + 19200, /* + * 19.2 + * kbps, + * 433 + * MHz, + * 45 + * khz + * freq + * dev */ + 32000, /* + * 32 + * kbps, + * 433 + * MHz, + * 45 + * khz + * freq + * dev */ + 57600, /* + * 57.6 + * kbps, + * 433 + * MHz, + * 45 + * khz + * freq + * dev */ + 64000, /* + * 64 + * kbps, + * 433 + * MHz, + * 45 + * khz + * freq + * dev */ + 100000, /* + * 100 + * kbps, + * 433 + * MHz, + * 60 + * khz + * freq + * dev */ + 128000, /* + * 128 + * kbps, + * 433 + * MHz, + * 90 + * khz + * freq + * dev */ + 192000, /* + * 192 + * kbps, + * 433 + * MHz, + * 128 + * khz + * freq + * dev */ + 256000, /* + * 256 + * kbps, + * 433 + * MHz, + * 150 + * khz + * freq + * dev */ + }; + static const uint8_t reg_1C[] = { 0x01, 0x05, 0x06, 0x95, 0x95, 0x81, 0x88, 0x8B, 0x8D }; /* + * rfm22_if_filter_bandwidth */ + static const uint8_t reg_1D[] = { 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40 }; /* + * rfm22_afc_loop_gearshift_override */ + static const uint8_t reg_1E[] = { 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x02 }; /* + * rfm22_afc_timing_control */ + static const uint8_t reg_1F[] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }; /* + * rfm22_clk_recovery_gearshift_override */ + static const uint8_t reg_20[] = { 0xA1, 0xD0, 0x7D, 0x68, 0x5E, 0x78, 0x5E, 0x3F, 0x2F }; /* + * rfm22_clk_recovery_oversampling_ratio */ + static const uint8_t reg_21[] = { 0x20, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02 }; /* + * rfm22_clk_recovery_offset2 */ + static const uint8_t reg_22[] = { 0x4E, 0x9D, 0x06, 0x3A, 0x5D, 0x11, 0x5D, 0x0C, 0xBB }; /* + * rfm22_clk_recovery_offset1 */ + static const uint8_t reg_23[] = { 0xA5, 0x49, 0x25, 0x93, 0x86, 0x11, 0x86, 0x4A, 0x0D }; /* + * rfm22_clk_recovery_offset0 */ + static const uint8_t reg_24[] = { 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x06, 0x07 }; /* + * rfm22_clk_recovery_timing_loop_gain1 */ + static const uint8_t reg_25[] = { 0x34, 0x88, 0x77, 0x29, 0xE2, 0x90, 0xE2, 0x1A, 0xFF }; /* + * rfm22_clk_recovery_timing_loop_gain0 */ + static const uint8_t reg_2A[] = { 0x1E, 0x24, 0x28, 0x3C, 0x3C, 0x50, 0x50, 0x50, 0x50 }; /* + * rfm22_afc_limiter + * .. + * AFC_pull_in_range + * = + * �AFCLimiter[7:0] + * x + * (hbsel+1) + * x + * 625 + * Hz */ + static const uint8_t reg_58[] = { 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xED }; /* + * rfm22_cpcuu */ + static const uint8_t reg_69[] = { 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60 }; /* + * rfm22_agc_override1 */ + static const uint8_t reg_6E[] = { 0x4E, 0x9D, 0x08, 0x0E, 0x10, 0x19, 0x20, 0x31, 0x41 }; /* + * rfm22_tx_data_rate1 */ + static const uint8_t reg_6F[] = { 0xA5, 0x49, 0x31, 0xBF, 0x62, 0x9A, 0xC5, 0x27, 0x89 }; /* + * rfm22_tx_data_rate0 */ + static const uint8_t reg_70[] = { 0x2C, 0x2C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C }; /* + * rfm22_modulation_mode_control1 */ + static const uint8_t reg_71[] = { 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23 }; /* + * rfm22_modulation_mode_control2 */ + static const uint8_t reg_72[] = { 0x30, 0x48, 0x48, 0x48, 0x48, 0x60, 0x90, 0xCD, 0x0F }; /* + * rfm22_frequency_deviation */ + static const uint8_t packet_time[] = { 80, 40, 25, 15, 13, 10, 8, 6, 5 }; + static const uint8_t packet_time_ppm[] = { 26, 25, 25, 15, 13, 10, 8, 6, 5 }; + static const uint8_t num_channels[] = { 4, 4, 4, 6, 8, 8, 10, 12, 16 }; + static struct pios_rfm22b_dev * g_rfm22b_dev =NULL; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /***************************************************************************** -* External Interface Functions -*****************************************************************************/ + * + * External + * Interface + * Functions + *****************************************************************************/ /** - * Initialise an RFM22B device - * - * @param[out] rfm22b_id A pointer to store the device ID in. - * @param[in] spi_id The SPI bus index. - * @param[in] slave_num The SPI bus slave number. - * @param[in] cfg The device configuration. - */ -int32_t PIOS_RFM22B_Init(uint32_t *rfm22b_id, uint32_t spi_id, uint32_t slave_num, const struct pios_rfm22b_cfg *cfg) -{ - PIOS_DEBUG_Assert(rfm22b_id); - PIOS_DEBUG_Assert(cfg); + * + * Initialise + * an + * RFM22B + * device + * + * + * @param[out] + * rfm22b_id + * + * A + * pointer + * to + * store + * the + * device + * ID + * in. + * + * @param[in] + * spi_id + * + * The + * SPI + * bus + * index. + * + * @param[in] + * slave_num + * + * The + * SPI + * bus + * slave + * number. + * + * @param[in] + * cfg + * + * The + * device + * configuration. + */ +int32_t PIOS_RFM22B_Init +( + uint32_t + * + rfm22b_id, + uint32_t + spi_id, + uint32_t + slave_num, + const + struct + pios_rfm22b_cfg + * cfg +){ + PIOS_DEBUG_Assert ( rfm22b_id); + PIOS_DEBUG_Assert ( cfg); - // Allocate the device structure. - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)pios_rfm22_alloc(); - if (!rfm22b_dev) { - return -1; - } - *rfm22b_id = (uint32_t)rfm22b_dev; - g_rfm22b_dev = rfm22b_dev; - // Store the SPI handle - rfm22b_dev->slave_num = slave_num; - rfm22b_dev->spi_id = spi_id; - // Initialize our configuration parameters - rfm22b_dev->datarate = RFM22B_DEFAULT_RX_DATARATE; - rfm22b_dev->tx_power = RFM22B_DEFAULT_TX_POWER; - rfm22b_dev->coordinator = false; - rfm22b_dev->coordinatorID = 0; - // Initialize the com callbacks. - rfm22b_dev->rx_in_cb = NULL; - rfm22b_dev->tx_out_cb = NULL; - // Initialzie the PPM callback. - rfm22b_dev->ppm_callback = NULL; - // Initialize the stats. - rfm22b_dev->stats.packets_per_sec = 0; - rfm22b_dev->stats.rx_good = 0; - rfm22b_dev->stats.rx_corrected = 0; - rfm22b_dev->stats.rx_error = 0; - rfm22b_dev->stats.rx_missed = 0; - rfm22b_dev->stats.tx_dropped = 0; - rfm22b_dev->stats.tx_resent = 0; - rfm22b_dev->stats.resets = 0; - rfm22b_dev->stats.timeouts = 0; - rfm22b_dev->stats.link_quality = 0; - rfm22b_dev->stats.rssi = 0; - rfm22b_dev->stats.tx_seq = 0; - rfm22b_dev->stats.rx_seq = 0; - rfm22b_dev->stats.tx_failure = 0; - // Initialize the channels. - PIOS_RFM22B_SetChannelConfig(*rfm22b_id, RFM22B_DEFAULT_RX_DATARATE, RFM22B_DEFAULT_MIN_CHANNEL, - RFM22B_DEFAULT_MAX_CHANNEL, RFM22B_DEFAULT_CHANNEL_SET, false, false, false, false); - // Create the event queue - rfm22b_dev->eventQueue = xQueueCreate(EVENT_QUEUE_SIZE, sizeof(enum pios_radio_event)); - // Bind the configuration to the device instance - rfm22b_dev->cfg = *cfg; - // Create a semaphore to know if an ISR needs responding to - vSemaphoreCreateBinary(rfm22b_dev->isrPending); - // Create our (hopefully) unique 32 bit id from the processor serial number. - uint8_t crcs[] = { 0, 0, 0, 0 }; - { - char serial_no_str[33]; - PIOS_SYS_SerialNumberGet(serial_no_str); - // Create a 32 bit value using 4 8 bit CRC values. - for (uint8_t i = 0; serial_no_str[i] != 0; ++i) { - crcs[i % 4] = PIOS_CRC_updateByte(crcs[i % 4], serial_no_str[i]); - } - } - rfm22b_dev->deviceID = crcs[0] | crcs[1] << 8 | crcs[2] << 16 | crcs[3] << 24; - DEBUG_PRINTF(2, "RF device ID: %x\n\r", rfm22b_dev->deviceID); - // Initialize the external interrupt. - PIOS_EXTI_Init(cfg->exti_cfg); - // Register the watchdog timer for the radio driver task + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * Allocate + * the + * device + * structure. */ + struct pios_rfm22b_dev * rfm22b_dev =(struct pios_rfm22b_dev *)pios_rfm22_alloc(); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + if (!rfm22b_dev){ + return -1; + } + + * rfm22b_id = (uint32_t)rfm22b_dev; + g_rfm22b_dev = rfm22b_dev; + + /* + * Store + * the + * SPI + * handle */ + rfm22b_dev->slave_num = slave_num; + rfm22b_dev->spi_id = spi_id; + + /* + * Initialize + * our + * configuration + * parameters */ + rfm22b_dev->datarate = RFM22B_DEFAULT_RX_DATARATE; + rfm22b_dev->tx_power = RFM22B_DEFAULT_TX_POWER; + rfm22b_dev->coordinator = false; + rfm22b_dev->coordinatorID = 0; + + /* + * Initialize + * the + * com + * callbacks. */ + rfm22b_dev->rx_in_cb = NULL; + rfm22b_dev->tx_out_cb = NULL; + + /* + * Initialzie + * the + * PPM + * callback. */ + rfm22b_dev->ppm_callback = NULL; + + /* + * Initialize + * the + * stats. */ + rfm22b_dev->stats.packets_per_sec = 0; + rfm22b_dev->stats.rx_good = 0; + rfm22b_dev->stats.rx_corrected = 0; + rfm22b_dev->stats.rx_error = 0; + rfm22b_dev->stats.rx_missed = 0; + rfm22b_dev->stats.tx_dropped = 0; + rfm22b_dev->stats.tx_resent = 0; + rfm22b_dev->stats.resets = 0; + rfm22b_dev->stats.timeouts = 0; + rfm22b_dev->stats.link_quality = 0; + rfm22b_dev->stats.rssi = 0; + rfm22b_dev->stats.tx_seq = 0; + rfm22b_dev->stats.rx_seq = 0; + rfm22b_dev->stats.tx_failure = 0; + + /* + * Initialize + * the + * channels. */ + PIOS_RFM22B_SetChannelConfig (* rfm22b_id,RFM22B_DEFAULT_RX_DATARATE,RFM22B_DEFAULT_MIN_CHANNEL, + RFM22B_DEFAULT_MAX_CHANNEL, RFM22B_DEFAULT_CHANNEL_SET, false, false, false, false); + + /* + * Create + * the + * event + * queue */ + rfm22b_dev->eventQueue = xQueueCreate(EVENT_QUEUE_SIZE, sizeof(enum pios_radio_event)); + + /* + * Bind + * the + * configuration + * to + * the + * device + * instance */ + rfm22b_dev->cfg = *cfg; + + /* + * Create + * a + * semaphore + * to + * know + * if + * an + * ISR + * needs + * responding + * to */ + vSemaphoreCreateBinary (rfm22b_dev->isrPending); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * Create + * our + * (hopefully) + * unique + * 32 + * bit + * id + * from + * the + * processor + * serial + * number. */ + uint8_t crcs[] = { 0, 0, 0, 0 }; + { + char serial_no_str[33]; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PIOS_SYS_SerialNumberGet ( + serial_no_str); + + /* + * Create + * a + * 32 + * bit + * value + * using + * 4 + * 8 + * bit + * CRC + * values. */ + for ( + uint8_t + i + = + 0 ; + serial_no_str + [ + i + ] + != + 0 ; + ++ + i) + { + crcs + [ + i + % + 4 + ] + = + PIOS_CRC_updateByte ( + crcs + [ + i + % + 4 + ], + serial_no_str + [ + i + ]); + } + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rfm22b_dev->deviceID = crcs[0] | crcs[1]<< 8 | crcs[2] << 16 | crcs[3] << 24; + DEBUG_PRINTF (2,"RF device ID: %x\n\r",rfm22b_dev->deviceID); + + /* + * Initialize + * the + * external + * interrupt. */ + PIOS_EXTI_Init (cfg->exti_cfg); + + /* + * Register + * the + * watchdog + * timer + * for + * the + * radio + * driver + * task */ #if defined(PIOS_INCLUDE_WDG) && defined(PIOS_WDG_RFM22B) - PIOS_WDG_RegisterFlag(PIOS_WDG_RFM22B); + PIOS_WDG_RegisterFlag ( + PIOS_WDG_RFM22B); #endif /* PIOS_WDG_RFM22B */ - // Initialize the ECC library. - initialize_ecc(); + /* + * Initialize + * the + * ECC + * library. */ + initialize_ecc(); - // Set the state to initializing. - rfm22b_dev->state = RADIO_STATE_UNINITIALIZED; + /* + * Set + * the + * state + * to + * initializing. */ + rfm22b_dev->state = RADIO_STATE_UNINITIALIZED; - // Initialize the radio device. - pios_rfm22_inject_event(rfm22b_dev, RADIO_EVENT_INITIALIZE, false); + /* + * Initialize + * the + * radio + * device. */ + pios_rfm22_inject_event (rfm22b_dev,RADIO_EVENT_INITIALIZE,false); - // Start the driver task. This task controls the radio state machine and removed all of the IO from the IRQ handler. - xTaskCreate(pios_rfm22_task, (signed char *)"PIOS_RFM22B_Task", STACK_SIZE_BYTES, (void *)rfm22b_dev, TASK_PRIORITY, &(rfm22b_dev->taskHandle)); + /* + * Start + * the + * driver + * task. + * + * This + * task + * controls + * the + * radio + * state + * machine + * and + * removed + * all + * of + * the + * IO + * from + * the + * IRQ + * handler. */ + xTaskCreate (pios_rfm22_task,(signedchar *)"PIOS_RFM22B_Task",STACK_SIZE_BYTES,(void *)rfm22b_dev,TASK_PRIORITY,&(rfm22b_dev->taskHandle)); - return 0; + return 0; } /** - * Re-initialize the modem after a configuration change. - * - * @param[in] rbm22b_id The RFM22B device ID. - */ -void PIOS_RFM22B_Reinit(uint32_t rfm22b_id) -{ - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; + * + * Re-initialize + * the + * modem + * after + * a + * configuration + * change. + * + * + * @param[in] + * rbm22b_id + * + * The + * RFM22B + * device + * ID. + */ +void PIOS_RFM22B_Reinit + (uint32_trfm22b_id){ + struct pios_rfm22b_dev * rfm22b_dev =(struct pios_rfm22b_dev *)rfm22b_id; - if (PIOS_RFM22B_Validate(rfm22b_dev)) { - pios_rfm22_inject_event(rfm22b_dev, RADIO_EVENT_INITIALIZE, false); - } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + if (PIOS_RFM22B_Validate(rfm22b_dev)){ + pios_rfm22_inject_event (rfm22b_dev,RADIO_EVENT_INITIALIZE,false); + } } /** - * The RFM22B external interrupt routine. - */ -bool PIOS_RFM22_EXT_Int(void) -{ - if (!PIOS_RFM22B_Validate(g_rfm22b_dev)) { - return false; - } + * + * The + * RFM22B + * external + * interrupt + * routine. + */ +bool PIOS_RFM22_EXT_Int + (void){ + if (!PIOS_RFM22B_Validate (g_rfm22b_dev)){ + return false; + } - // Inject an interrupt event into the state machine. - pios_rfm22_inject_event(g_rfm22b_dev, RADIO_EVENT_INT_RECEIVED, true); - return false; + /* + * Inject + * an + * interrupt + * event + * into + * the + * state + * machine. */ + pios_rfm22_inject_event (g_rfm22b_dev,RADIO_EVENT_INT_RECEIVED,true); + + return false; } /** - * Returns the unique device ID for the RFM22B device. - * - * @param[in] rfm22b_id The RFM22B device index. - * @return The unique device ID - */ -uint32_t PIOS_RFM22B_DeviceID(uint32_t rfm22b_id) -{ - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; + * + * Returns + * the + * unique + * device + * ID + * for + * the + * RFM22B + * device. + * + * + * @param[in] + * rfm22b_id + * The + * RFM22B + * device + * index. + * + * @return + * The + * unique + * device + * ID + */ +uint32_t PIOS_RFM22B_DeviceID + (uint32_trfm22b_id){ + struct pios_rfm22b_dev * rfm22b_dev =(struct pios_rfm22b_dev *)rfm22b_id; - if (PIOS_RFM22B_Validate(rfm22b_dev)) { - return rfm22b_dev->deviceID; - } - return 0; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + if (PIOS_RFM22B_Validate(rfm22b_dev)){ + return rfm22b_dev->deviceID; + } + + return 0; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/** + * + * Are + * we + * connected + * to + * the + * remote + * modem? + * + * + * @param[in] + * rfm22b_dev + * + * The + * device + * structure + */ +static bool rfm22_isConnected + (struct pios_rfm22b_dev* rfm22b_dev){ + return (rfm22b_dev->stats.link_state == OPLINKSTATUS_LINKSTATE_CONNECTED) || (rfm22b_dev->stats.link_state == OPLINKSTATUS_LINKSTATE_CONNECTING); } /** - * Are we connected to the remote modem? - * - * @param[in] rfm22b_dev The device structure - */ -static bool rfm22_isConnected(struct pios_rfm22b_dev *rfm22b_dev) -{ - return (rfm22b_dev->stats.link_state == OPLINKSTATUS_LINKSTATE_CONNECTED) || (rfm22b_dev->stats.link_state == OPLINKSTATUS_LINKSTATE_CONNECTING); + * + * Returns + * true + * if + * the + * modem + * is + * not + * actively + * sending + * or + * receiving + * a + * packet. + * + * + * @param[in] + * rfm22b_id + * The + * RFM22B + * device + * index. + * + * @return + * True + * if + * the + * modem + * is + * not + * actively + * sending + * or + * receiving + * a + * packet. + */ +bool PIOS_RFM22B_InRxWait + (uint32_trfm22b_id){ + struct pios_rfm22b_dev * rfm22b_dev =(struct pios_rfm22b_dev *)rfm22b_id; + + if (PIOS_RFM22B_Validate(rfm22b_dev)){ + return (rfm22b_dev->rfm22b_state == RFM22B_STATE_RX_WAIT) || (rfm22b_dev->rfm22b_state == RFM22B_STATE_TRANSITION); + } + + return false; } /** - * Returns true if the modem is not actively sending or receiving a packet. - * - * @param[in] rfm22b_id The RFM22B device index. - * @return True if the modem is not actively sending or receiving a packet. - */ -bool PIOS_RFM22B_InRxWait(uint32_t rfm22b_id) -{ - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; + * + * Sets + * the + * radio + * device + * transmit + * power. + * + * + * @param[in] + * rfm22b_id + * The + * RFM22B + * device + * index. + * + * @param[in] + * tx_pwr + * The + * transmit + * power. + */ +void PIOS_RFM22B_SetTxPower +( + uint32_t + rfm22b_id, + enum + rfm22b_tx_power + tx_pwr +){ + struct pios_rfm22b_dev * rfm22b_dev =(struct pios_rfm22b_dev *)rfm22b_id; - if (PIOS_RFM22B_Validate(rfm22b_dev)) { - return (rfm22b_dev->rfm22b_state == RFM22B_STATE_RX_WAIT) || (rfm22b_dev->rfm22b_state == RFM22B_STATE_TRANSITION); - } - return false; + if (!PIOS_RFM22B_Validate (rfm22b_dev)){ + return; + } + + rfm22b_dev->tx_power = tx_pwr; } /** - * Sets the radio device transmit power. - * - * @param[in] rfm22b_id The RFM22B device index. - * @param[in] tx_pwr The transmit power. - */ -void PIOS_RFM22B_SetTxPower(uint32_t rfm22b_id, enum rfm22b_tx_power tx_pwr) -{ - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; + * + * Sets + * the + * range + * and + * number + * of + * channels + * to + * use + * for + * the + * radio. + * + * The + * channels + * are + * 0 + * to + * 255 + * divided + * across + * the + * 430-440 + * MHz + * range. + * + * The + * number + * of + * channels + * configured + * will + * be + * spread + * across + * the + * selected + * channel + * range. + * + * The + * channel + * spacing + * is + * 10MHz + * / + * 250 + * = + * 40kHz + * + * + * @param[in] + * rfm22b_id + * + * The + * RFM22B + * device + * index. + * + * @param[in] + * datarate + * + * The + * desired + * datarate. + * + * @param[in] + * min_chan + * + * The + * minimum + * channel. + * + * @param[in] + * max_chan + * + * The + * maximum + * channel. + * + * @param[in] + * chan_set + * + * The + * "seed" + * for + * selecting + * a + * channel + * sequence. + * + * @param[in] + * coordinator + * Is + * this + * modem + * an + * coordinator. + * + * @param[in] + * ppm_mode + * Should + * this + * modem + * send/receive + * ppm + * packets? + * + * @param[in] + * oneway + * Only + * the + * coordinator + * can + * send + * packets + * if + * true. + */ +void PIOS_RFM22B_SetChannelConfig +( + uint32_t + rfm22b_id, + enum + rfm22b_datarate + datarate, + uint8_t + min_chan, + uint8_t + max_chan, + uint8_t + chan_set, + bool + coordinator, + bool + oneway, + bool + ppm_mode, + bool + ppm_only +){ + struct pios_rfm22b_dev * rfm22b_dev =(struct pios_rfm22b_dev *)rfm22b_id; - if (!PIOS_RFM22B_Validate(rfm22b_dev)) { - return; - } - rfm22b_dev->tx_power = tx_pwr; + if (!PIOS_RFM22B_Validate (rfm22b_dev)){ + return; + } + + ppm_mode = ppm_mode || ppm_only; + rfm22b_dev->coordinator = coordinator; + rfm22b_dev->ppm_send_mode = ppm_mode && coordinator; + rfm22b_dev->ppm_recv_mode = ppm_mode && !coordinator; + if (ppm_mode && (datarate <= RFM22B_PPM_ONLY_DATARATE)){ + ppm_only = true; + } + + rfm22b_dev->ppm_only_mode = ppm_only; + if (ppm_only){ + rfm22b_dev->one_way_link = true; + datarate = RFM22B_PPM_ONLY_DATARATE; + rfm22b_dev->datarate = RFM22B_PPM_ONLY_DATARATE; + } + else { + rfm22b_dev->one_way_link = oneway; + rfm22b_dev->datarate = datarate; + } + + rfm22b_dev->packet_time = (ppm_mode ? packet_time_ppm[datarate] : packet_time[datarate]); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * Find + * the + * first + * N + * channels + * that + * meet + * the + * min/max + * criteria + * out + * of + * the + * random + * channel + * list. */ + uint8_t num_found = 0; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + for (uint16_t i = 0; (i < RFM22B_NUM_CHANNELS) && (num_found < num_channels[datarate]); ++i) + { + uint8_t idx = (i + chan_set) % RFM22B_NUM_CHANNELS; + uint8_t chan = channel_list[idx]; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + if ((chan >= min_chan) && (chan <= max_chan)){ + rfm22b_dev->channels[num_found ++] =chan; + } + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * Calculate + * the + * maximum + * packet + * length + * from + * the + * datarate. */ + float bytes_per_period = (float)data_rate[datarate] * (float)(rfm22b_dev->packet_time - 2) / 9000; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rfm22b_dev->max_packet_len = bytes_per_period - TX_PREAMBLE_NIBBLES / 2 - SYNC_BYTES - HEADER_BYTES - LENGTH_BYTES; + if (rfm22b_dev->max_packet_len > RFM22B_MAX_PACKET_LEN){ + rfm22b_dev->max_packet_len = RFM22B_MAX_PACKET_LEN; + } } /** - * Sets the range and number of channels to use for the radio. - * The channels are 0 to 255 divided across the 430-440 MHz range. - * The number of channels configured will be spread across the selected channel range. - * The channel spacing is 10MHz / 250 = 40kHz - * - * @param[in] rfm22b_id The RFM22B device index. - * @param[in] datarate The desired datarate. - * @param[in] min_chan The minimum channel. - * @param[in] max_chan The maximum channel. - * @param[in] chan_set The "seed" for selecting a channel sequence. - * @param[in] coordinator Is this modem an coordinator. - * @param[in] ppm_mode Should this modem send/receive ppm packets? - * @param[in] oneway Only the coordinator can send packets if true. - */ -void PIOS_RFM22B_SetChannelConfig(uint32_t rfm22b_id, enum rfm22b_datarate datarate, uint8_t min_chan, uint8_t max_chan, uint8_t chan_set, bool coordinator, bool oneway, bool ppm_mode, bool ppm_only) -{ - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; + * + * Set + * a + * modem + * to + * be + * a + * coordinator + * or + * not. + * + * + * @param[in] + * rfm22b_id + * The + * RFM22B + * device + * index. + * + * @param[in] + * coordinator + * If + * true, + * this + * modem + * will + * be + * configured + * as + * a + * coordinator. + */ +extern void PIOS_RFM22B_SetCoordinator +( + uint32_t + rfm22b_id, + bool + coordinator +){ + struct pios_rfm22b_dev * rfm22b_dev =(struct pios_rfm22b_dev *)rfm22b_id; - if (!PIOS_RFM22B_Validate(rfm22b_dev)) { - return; - } - ppm_mode = ppm_mode || ppm_only; - rfm22b_dev->coordinator = coordinator; - rfm22b_dev->ppm_send_mode = ppm_mode && coordinator; - rfm22b_dev->ppm_recv_mode = ppm_mode && !coordinator; - if (ppm_mode && (datarate <= RFM22B_PPM_ONLY_DATARATE)) { - ppm_only = true; - } - rfm22b_dev->ppm_only_mode = ppm_only; - if (ppm_only) { - rfm22b_dev->one_way_link = true; - datarate = RFM22B_PPM_ONLY_DATARATE; - rfm22b_dev->datarate = RFM22B_PPM_ONLY_DATARATE; - } else { - rfm22b_dev->one_way_link = oneway; - rfm22b_dev->datarate = datarate; - } - rfm22b_dev->packet_time = (ppm_mode ? packet_time_ppm[datarate] : packet_time[datarate]); - - // Find the first N channels that meet the min/max criteria out of the random channel list. - uint8_t num_found = 0; - for (uint16_t i = 0; (i < RFM22B_NUM_CHANNELS) && (num_found < num_channels[datarate]); ++i) { - uint8_t idx = (i + chan_set) % RFM22B_NUM_CHANNELS; - uint8_t chan = channel_list[idx]; - if ((chan >= min_chan) && (chan <= max_chan)) { - rfm22b_dev->channels[num_found++] = chan; - } - } - - // Calculate the maximum packet length from the datarate. - float bytes_per_period = (float)data_rate[datarate] * (float)(rfm22b_dev->packet_time - 2) / 9000; - - rfm22b_dev->max_packet_len = bytes_per_period - TX_PREAMBLE_NIBBLES / 2 - SYNC_BYTES - HEADER_BYTES - LENGTH_BYTES; - if (rfm22b_dev->max_packet_len > RFM22B_MAX_PACKET_LEN) { - rfm22b_dev->max_packet_len = RFM22B_MAX_PACKET_LEN; - } + if (PIOS_RFM22B_Validate(rfm22b_dev)){ + rfm22b_dev->coordinator = coordinator; + } } /** - * Set a modem to be a coordinator or not. - * - * @param[in] rfm22b_id The RFM22B device index. - * @param[in] coordinator If true, this modem will be configured as a coordinator. - */ -extern void PIOS_RFM22B_SetCoordinator(uint32_t rfm22b_id, bool coordinator) -{ - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; + * + * Sets + * the + * device + * coordinator + * ID. + * + * + * @param[in] + * rfm22b_id + * The + * RFM22B + * device + * index. + * + * @param[in] + * coord_id + * The + * coordinator + * ID. + */ +void PIOS_RFM22B_SetCoordinatorID +( + uint32_t + rfm22b_id, + uint32_t + coord_id +){ + struct pios_rfm22b_dev * rfm22b_dev =(struct pios_rfm22b_dev *)rfm22b_id; - if (PIOS_RFM22B_Validate(rfm22b_dev)) { - rfm22b_dev->coordinator = coordinator; - } + if (PIOS_RFM22B_Validate(rfm22b_dev)){ + rfm22b_dev->coordinatorID = coord_id; + } } /** - * Sets the device coordinator ID. - * - * @param[in] rfm22b_id The RFM22B device index. - * @param[in] coord_id The coordinator ID. - */ -void PIOS_RFM22B_SetCoordinatorID(uint32_t rfm22b_id, uint32_t coord_id) -{ - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; + * + * Returns + * the + * device + * statistics + * RFM22B + * device. + * + * + * @param[in] + * rfm22b_id + * The + * RFM22B + * device + * index. + * + * @param[out] + * stats + * The + * stats + * are + * returned + * in + * this + * structure + */ +void PIOS_RFM22B_GetStats +( + uint32_t + rfm22b_id, + struct + rfm22b_stats + * + stats +){ + struct pios_rfm22b_dev * rfm22b_dev =(struct pios_rfm22b_dev *)rfm22b_id; - if (PIOS_RFM22B_Validate(rfm22b_dev)) { - rfm22b_dev->coordinatorID = coord_id; - } + if (!PIOS_RFM22B_Validate (rfm22b_dev)){ + return; + } + + /* + * Calculate + * the + * current + * link + * quality */ + rfm22_calculateLinkQuality (rfm22b_dev); + + /* + * Return + * the + * stats. */ + * stats =rfm22b_dev->stats; } /** - * Returns the device statistics RFM22B device. - * - * @param[in] rfm22b_id The RFM22B device index. - * @param[out] stats The stats are returned in this structure - */ -void PIOS_RFM22B_GetStats(uint32_t rfm22b_id, struct rfm22b_stats *stats) -{ - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; + * + * Get + * the + * stats + * of + * the + * oter + * radio + * devices + * that + * are + * in + * range. + * + * + * @param[out] + * device_ids + * + * A + * pointer + * to + * the + * array + * to + * store + * the + * device + * IDs. + * + * @param[out] + * RSSIs + * + * A + * pointer + * to + * the + * array + * to + * store + * the + * RSSI + * values + * in. + * + * @param[in] + * mx_pairs + * + * The + * length + * of + * the + * pdevice_ids + * and + * RSSIs + * arrays. + * + * @return + * + * The + * number + * of + * pair + * stats + * returned. + */ +uint8_t PIOS_RFM2B_GetPairStats +( + uint32_t + rfm22b_id, + uint32_t + * + device_ids, + int8_t + * + RSSIs, + uint8_t + max_pairs +){ + struct pios_rfm22b_dev * rfm22b_dev =(struct pios_rfm22b_dev *)rfm22b_id; - if (!PIOS_RFM22B_Validate(rfm22b_dev)) { - return; - } + if (!PIOS_RFM22B_Validate (rfm22b_dev)){ + return 0; + } - // Calculate the current link quality - rfm22_calculateLinkQuality(rfm22b_dev); - // Return the stats. - *stats = rfm22b_dev->stats; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + uint8_t mp = (max_pairs >= OPLINKSTATUS_PAIRIDS_NUMELEM) ? max_pairs : OPLINKSTATUS_PAIRIDS_NUMELEM; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + for (uint8_t i = 0; i < mp; ++i) + { + device_ids[i] = rfm22b_dev->pair_stats[i].pairID; + RSSIs[i] = rfm22b_dev->pair_stats[i].rssi; + } + return mp; } /** - * Get the stats of the oter radio devices that are in range. - * - * @param[out] device_ids A pointer to the array to store the device IDs. - * @param[out] RSSIs A pointer to the array to store the RSSI values in. - * @param[in] mx_pairs The length of the pdevice_ids and RSSIs arrays. - * @return The number of pair stats returned. - */ -uint8_t PIOS_RFM2B_GetPairStats(uint32_t rfm22b_id, uint32_t *device_ids, int8_t *RSSIs, uint8_t max_pairs) -{ - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; + * + * Check + * the + * radio + * device + * for + * a + * valid + * connection + * + * + * @param[in] + * rfm22b_id + * + * The + * rfm22b + * device. + * + * @return + * true + * if + * there + * is + * a + * valid + * connection + * to + * paired + * radio, + * false + * otherwise. + */ +bool PIOS_RFM22B_LinkStatus + (uint32_trfm22b_id){ + struct pios_rfm22b_dev * rfm22b_dev =(struct pios_rfm22b_dev *)rfm22b_id; - if (!PIOS_RFM22B_Validate(rfm22b_dev)) { - return 0; - } + if (!PIOS_RFM22B_Validate (rfm22b_dev)){ + return false; + } - uint8_t mp = (max_pairs >= OPLINKSTATUS_PAIRIDS_NUMELEM) ? max_pairs : OPLINKSTATUS_PAIRIDS_NUMELEM; - for (uint8_t i = 0; i < mp; ++i) { - device_ids[i] = rfm22b_dev->pair_stats[i].pairID; - RSSIs[i] = rfm22b_dev->pair_stats[i].rssi; - } - - return mp; + return rfm22b_dev->stats.link_quality > RFM22B_LINK_QUALITY_THRESHOLD; } /** - * Check the radio device for a valid connection - * - * @param[in] rfm22b_id The rfm22b device. - * @return true if there is a valid connection to paired radio, false otherwise. - */ -bool PIOS_RFM22B_LinkStatus(uint32_t rfm22b_id) -{ - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; + * + * Put + * the + * RFM22B + * device + * into + * receive + * mode. + * + * + * @param[in] + * rfm22b_id + * + * The + * rfm22b + * device. + * + * @param[in] + * p + * + * The + * packet + * to + * receive + * into. + * + * @return + * true + * if + * Rx + * mode + * was + * entered + * sucessfully. + */ +bool PIOS_RFM22B_ReceivePacket +( + uint32_t + rfm22b_id, + uint8_t + * + p +){ + struct pios_rfm22b_dev * rfm22b_dev =(struct pios_rfm22b_dev *)rfm22b_id; - if (!PIOS_RFM22B_Validate(rfm22b_dev)) { - return false; - } - return rfm22b_dev->stats.link_quality > RFM22B_LINK_QUALITY_THRESHOLD; -} + if (!PIOS_RFM22B_Validate (rfm22b_dev)){ + return false; + } -/** - * Put the RFM22B device into receive mode. - * - * @param[in] rfm22b_id The rfm22b device. - * @param[in] p The packet to receive into. - * @return true if Rx mode was entered sucessfully. - */ -bool PIOS_RFM22B_ReceivePacket(uint32_t rfm22b_id, uint8_t *p) -{ - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; + rfm22b_dev->rx_packet_handle = p; - if (!PIOS_RFM22B_Validate(rfm22b_dev)) { - return false; - } - rfm22b_dev->rx_packet_handle = p; + /* + * Claim + * the + * SPI + * bus. */ + rfm22_claimBus (rfm22b_dev); - // Claim the SPI bus. - rfm22_claimBus(rfm22b_dev); + /* + * disable + * interrupts */ + rfm22_write ( rfm22b_dev, RFM22_interrupt_enable1,0x00); + rfm22_write ( rfm22b_dev, RFM22_interrupt_enable2,0x00); - // disable interrupts - rfm22_write(rfm22b_dev, RFM22_interrupt_enable1, 0x00); - rfm22_write(rfm22b_dev, RFM22_interrupt_enable2, 0x00); - - // Switch to TUNE mode - rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl1, RFM22_opfc1_pllon); + /* + * Switch + * to + * TUNE + * mode */ + rfm22_write ( rfm22b_dev, RFM22_op_and_func_ctrl1,RFM22_opfc1_pllon); #ifdef PIOS_RFM22B_DEBUG_ON_TELEM - D2_LED_OFF; -#endif // PIOS_RFM22B_DEBUG_ON_TELEM - RX_LED_OFF; - TX_LED_OFF; + D2_LED_OFF; +#endif /* + * PIOS_RFM22B_DEBUG_ON_TELEM */ + RX_LED_OFF; + TX_LED_OFF; - // empty the rx buffer - rfm22b_dev->rx_buffer_wr = 0; + /* + * empty + * the + * rx + * buffer */ + rfm22b_dev->rx_buffer_wr = 0; - // Clear the TX buffer. - rfm22b_dev->tx_data_rd = rfm22b_dev->tx_data_wr = 0; + /* + * Clear + * the + * TX + * buffer. */ + rfm22b_dev->tx_data_rd = rfm22b_dev->tx_data_wr = 0; - // clear FIFOs - rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl2, RFM22_opfc2_ffclrrx | RFM22_opfc2_ffclrtx); - rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl2, 0x00); + /* + * clear + * FIFOs */ + rfm22_write ( rfm22b_dev, RFM22_op_and_func_ctrl2,RFM22_opfc2_ffclrrx | RFM22_opfc2_ffclrtx); + rfm22_write ( rfm22b_dev, RFM22_op_and_func_ctrl2,0x00); - // enable RX interrupts - rfm22_write(rfm22b_dev, RFM22_interrupt_enable1, RFM22_ie1_encrcerror | RFM22_ie1_enpkvalid | - RFM22_ie1_enrxffafull | RFM22_ie1_enfferr); - rfm22_write(rfm22b_dev, RFM22_interrupt_enable2, RFM22_ie2_enpreainval | RFM22_ie2_enpreaval | - RFM22_ie2_enswdet); + /* + * enable + * RX + * interrupts */ + rfm22_write ( rfm22b_dev, RFM22_interrupt_enable1,RFM22_ie1_encrcerror | RFM22_ie1_enpkvalid | + RFM22_ie1_enrxffafull | RFM22_ie1_enfferr); + rfm22_write ( rfm22b_dev, RFM22_interrupt_enable2,RFM22_ie2_enpreainval | RFM22_ie2_enpreaval | + RFM22_ie2_enswdet); - // enable the receiver - rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl1, RFM22_opfc1_pllon | RFM22_opfc1_rxon); + /* + * enable + * the + * receiver */ + rfm22_write (rfm22b_dev,RFM22_op_and_func_ctrl1,RFM22_opfc1_pllon| RFM22_opfc1_rxon); - // Release the SPI bus. - rfm22_releaseBus(rfm22b_dev); + /* + * Release + * the + * SPI + * bus. */ + rfm22_releaseBus (rfm22b_dev); - // Indicate that we're in RX wait mode. - rfm22b_dev->rfm22b_state = RFM22B_STATE_RX_WAIT; + /* + * Indicate + * that + * we're + * in + * RX + * wait + * mode. */ + rfm22b_dev->rfm22b_state = RFM22B_STATE_RX_WAIT; - return true; + return true; } /** - * Transmit a packet via the RFM22B device. - * - * @param[in] rfm22b_id The rfm22b device. - * @param[in] p The packet to transmit. - * @return true if there if the packet was queued for transmission. - */ -bool PIOS_RFM22B_TransmitPacket(uint32_t rfm22b_id, uint8_t *p, uint8_t len) -{ - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; + * + * Transmit + * a + * packet + * via + * the + * RFM22B + * device. + * + * + * @param[in] + * rfm22b_id + * + * The + * rfm22b + * device. + * + * @param[in] + * p + * + * The + * packet + * to + * transmit. + * + * @return + * true + * if + * there + * if + * the + * packet + * was + * queued + * for + * transmission. + */ +bool PIOS_RFM22B_TransmitPacket +( + uint32_t + rfm22b_id, + uint8_t + * + p, + uint8_t + len +){ + struct pios_rfm22b_dev * rfm22b_dev =(struct pios_rfm22b_dev *)rfm22b_id; - if (!PIOS_RFM22B_Validate(rfm22b_dev)) { - return false; - } + if (!PIOS_RFM22B_Validate (rfm22b_dev)){ + return false; + } - rfm22b_dev->tx_packet_handle = p; - rfm22b_dev->stats.tx_byte_count += len; - rfm22b_dev->packet_start_ticks = xTaskGetTickCount(); - if (rfm22b_dev->packet_start_ticks == 0) { - rfm22b_dev->packet_start_ticks = 1; - } + rfm22b_dev->tx_packet_handle = p; + rfm22b_dev->stats.tx_byte_count += len; + rfm22b_dev->packet_start_ticks = xTaskGetTickCount(); + if (rfm22b_dev->packet_start_ticks == 0){ + rfm22b_dev->packet_start_ticks = 1; + } - // Claim the SPI bus. - rfm22_claimBus(rfm22b_dev); + /* + * Claim + * the + * SPI + * bus. */ + rfm22_claimBus (rfm22b_dev); - // Disable interrupts - rfm22_write(rfm22b_dev, RFM22_interrupt_enable1, 0x00); - rfm22_write(rfm22b_dev, RFM22_interrupt_enable2, 0x00); + /* + * Disable + * interrupts */ + rfm22_write ( rfm22b_dev, RFM22_interrupt_enable1,0x00); + rfm22_write ( rfm22b_dev, RFM22_interrupt_enable2,0x00); - // set the tx power - rfm22b_dev->tx_power = 0x7; - rfm22_write(rfm22b_dev, RFM22_tx_power, RFM22_tx_pwr_lna_sw | rfm22b_dev->tx_power); + /* + * set + * the + * tx + * power */ + rfm22b_dev->tx_power = 0x7; + rfm22_write ( rfm22b_dev, RFM22_tx_power, RFM22_tx_pwr_lna_sw | rfm22b_dev->tx_power); - // TUNE mode - rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl1, RFM22_opfc1_pllon); + /* + * TUNE + * mode */ + rfm22_write ( rfm22b_dev, RFM22_op_and_func_ctrl1,RFM22_opfc1_pllon); - // Queue the data up for sending - rfm22b_dev->tx_data_wr = len; + /* + * Queue + * the + * data + * up + * for + * sending */ + rfm22b_dev->tx_data_wr = len; - RX_LED_OFF; + RX_LED_OFF; - // Set the destination address in the transmit header. - uint32_t id = rfm22_destinationID(rfm22b_dev); - rfm22_write(rfm22b_dev, RFM22_transmit_header0, id & 0xff); - rfm22_write(rfm22b_dev, RFM22_transmit_header1, (id >> 8) & 0xff); - rfm22_write(rfm22b_dev, RFM22_transmit_header2, (id >> 16) & 0xff); - rfm22_write(rfm22b_dev, RFM22_transmit_header3, (id >> 24) & 0xff); - // FIFO mode, GFSK modulation - uint8_t fd_bit = rfm22_read(rfm22b_dev, RFM22_modulation_mode_control2) & RFM22_mmc2_fd; - rfm22_write(rfm22b_dev, RFM22_modulation_mode_control2, fd_bit | RFM22_mmc2_dtmod_fifo | RFM22_mmc2_modtyp_gfsk); - // Clear the FIFOs. - rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl2, RFM22_opfc2_ffclrrx | RFM22_opfc2_ffclrtx); - rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl2, 0x00); - // Set the total number of data bytes we are going to transmit. - rfm22_write(rfm22b_dev, RFM22_transmit_packet_length, len); - // Add some data to the chips TX FIFO before enabling the transmitter - uint8_t *tx_buffer = rfm22b_dev->tx_packet_handle; - rfm22_assertCs(rfm22b_dev); - PIOS_SPI_TransferByte(rfm22b_dev->spi_id, RFM22_fifo_access | 0x80); - int bytes_to_write = (rfm22b_dev->tx_data_wr - rfm22b_dev->tx_data_rd); - bytes_to_write = (bytes_to_write > FIFO_SIZE) ? FIFO_SIZE : bytes_to_write; - PIOS_SPI_TransferBlock(rfm22b_dev->spi_id, &tx_buffer[rfm22b_dev->tx_data_rd], NULL, bytes_to_write, NULL); - rfm22b_dev->tx_data_rd += bytes_to_write; - rfm22_deassertCs(rfm22b_dev); - // Enable TX interrupts. - rfm22_write(rfm22b_dev, RFM22_interrupt_enable1, RFM22_ie1_enpksent | RFM22_ie1_entxffaem); - // Enable the transmitter. - rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl1, RFM22_opfc1_pllon | RFM22_opfc1_txon); - // Release the SPI bus. - rfm22_releaseBus(rfm22b_dev); - // We're in Tx mode. - rfm22b_dev->rfm22b_state = RFM22B_STATE_TX_MODE; - TX_LED_ON; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * Set + * the + * destination + * address + * in + * the + * transmit + * header. */ + uint32_t id = rfm22_destinationID(rfm22b_dev); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rfm22_write ( rfm22b_dev, RFM22_transmit_header0, id & 0xff); + rfm22_write ( rfm22b_dev, RFM22_transmit_header1, (id >> 8) & 0xff); + rfm22_write ( rfm22b_dev, RFM22_transmit_header2, (id >> 16) & 0xff); + rfm22_write ( rfm22b_dev, RFM22_transmit_header3, (id >> 24) & 0xff); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * FIFO + * mode, + * GFSK + * modulation */ + uint8_t fd_bit = rfm22_read(rfm22b_dev, RFM22_modulation_mode_control2) & RFM22_mmc2_fd; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rfm22_write ( rfm22b_dev, RFM22_modulation_mode_control2, fd_bit | RFM22_mmc2_dtmod_fifo | RFM22_mmc2_modtyp_gfsk); + + /* + * Clear + * the + * FIFOs. */ + rfm22_write ( rfm22b_dev, RFM22_op_and_func_ctrl2, RFM22_opfc2_ffclrrx | RFM22_opfc2_ffclrtx); + rfm22_write ( rfm22b_dev, RFM22_op_and_func_ctrl2, 0x00); + + /* + * Set + * the + * total + * number + * of + * data + * bytes + * we + * are + * going + * to + * transmit. */ + rfm22_write ( rfm22b_dev, RFM22_transmit_packet_length, len); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * Add + * some + * data + * to + * the + * chips + * TX + * FIFO + * before + * enabling + * the + * transmitter */ + uint8_t * tx_buffer =rfm22b_dev->tx_packet_handle; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rfm22_assertCs (rfm22b_dev); + PIOS_SPI_TransferByte (rfm22b_dev->spi_id,RFM22_fifo_access| 0x80); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + int bytes_to_write = (rfm22b_dev->tx_data_wr - rfm22b_dev->tx_data_rd); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bytes_to_write = (bytes_to_write > FIFO_SIZE) ? FIFO_SIZE : bytes_to_write; + PIOS_SPI_TransferBlock (rfm22b_dev->spi_id,&tx_buffer[rfm22b_dev->tx_data_rd],NULL,bytes_to_write,NULL); + rfm22b_dev->tx_data_rd += bytes_to_write; + rfm22_deassertCs (rfm22b_dev); + + /* + * Enable + * TX + * interrupts. */ + rfm22_write ( rfm22b_dev, RFM22_interrupt_enable1,RFM22_ie1_enpksent | RFM22_ie1_entxffaem); + + /* + * Enable + * the + * transmitter. */ + rfm22_write ( rfm22b_dev, RFM22_op_and_func_ctrl1,RFM22_opfc1_pllon | RFM22_opfc1_txon); + + /* + * Release + * the + * SPI + * bus. */ + rfm22_releaseBus (rfm22b_dev); + + /* + * We're + * in + * Tx + * mode. */ + rfm22b_dev->rfm22b_state = RFM22B_STATE_TX_MODE; + + TX_LED_ON; #ifdef PIOS_RFM22B_DEBUG_ON_TELEM - D1_LED_ON; + D1_LED_ON; #endif - return true; + return true; } /** - * Process a Tx interrupt from the RFM22B device. - * - * @param[in] rfm22b_id The rfm22b device. - * @return PIOS_RFM22B_TX_COMPLETE on completed Tx, or PIOS_RFM22B_INT_SUCCESS/PIOS_RFM22B_INT_FAILURE. - */ -pios_rfm22b_int_result PIOS_RFM22B_ProcessTx(uint32_t rfm22b_id) -{ - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; + * + * Process + * a + * Tx + * interrupt + * from + * the + * RFM22B + * device. + * + * + * @param[in] + * rfm22b_id + * + * The + * rfm22b + * device. + * + * @return + * PIOS_RFM22B_TX_COMPLETE + * on + * completed + * Tx, + * or + * PIOS_RFM22B_INT_SUCCESS/PIOS_RFM22B_INT_FAILURE. + */ +pios_rfm22b_int_result PIOS_RFM22B_ProcessTx + (uint32_trfm22b_id){ + struct pios_rfm22b_dev * rfm22b_dev =(struct pios_rfm22b_dev *)rfm22b_id; - if (!PIOS_RFM22B_Validate(rfm22b_dev)) { - return PIOS_RFM22B_INT_FAILURE; - } + if (!PIOS_RFM22B_Validate (rfm22b_dev)){ + return PIOS_RFM22B_INT_FAILURE; + } + /* + * Read + * the + * device + * status + * registers */ + if (!pios_rfm22_readStatus (rfm22b_dev)){ + return PIOS_RFM22B_INT_FAILURE; + } + /* + * TX + * FIFO + * almost + * empty, + * it + * needs + * filling + * up */ + if (rfm22b_dev->status_regs.int_status_1.tx_fifo_almost_empty){ + /* + * Add + * data + * to + * the + * TX + * FIFO + * buffer */ + uint8_t * tx_buffer = rfm22b_dev->tx_packet_handle; + uint16_t max_bytes = FIFO_SIZE - TX_FIFO_LO_WATERMARK - 1; - // Read the device status registers - if (!pios_rfm22_readStatus(rfm22b_dev)) { - return PIOS_RFM22B_INT_FAILURE; - } - // TX FIFO almost empty, it needs filling up - if (rfm22b_dev->status_regs.int_status_1.tx_fifo_almost_empty) { - // Add data to the TX FIFO buffer - uint8_t *tx_buffer = rfm22b_dev->tx_packet_handle; - uint16_t max_bytes = FIFO_SIZE - TX_FIFO_LO_WATERMARK - 1; - rfm22_claimBus(rfm22b_dev); - rfm22_assertCs(rfm22b_dev); - PIOS_SPI_TransferByte(rfm22b_dev->spi_id, RFM22_fifo_access | 0x80); - int bytes_to_write = (rfm22b_dev->tx_data_wr - rfm22b_dev->tx_data_rd); - bytes_to_write = (bytes_to_write > max_bytes) ? max_bytes : bytes_to_write; - PIOS_SPI_TransferBlock(rfm22b_dev->spi_id, &tx_buffer[rfm22b_dev->tx_data_rd], NULL, bytes_to_write, NULL); - rfm22b_dev->tx_data_rd += bytes_to_write; - rfm22_deassertCs(rfm22b_dev); - rfm22_releaseBus(rfm22b_dev); - return PIOS_RFM22B_INT_SUCCESS; - } else if (rfm22b_dev->status_regs.int_status_1.packet_sent_interrupt) { - // Transition out of Tx mode. - rfm22b_dev->rfm22b_state = RFM22B_STATE_TRANSITION; - return PIOS_RFM22B_TX_COMPLETE; - } - return 0; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rfm22_claimBus (rfm22b_dev); + rfm22_assertCs (rfm22b_dev); + PIOS_SPI_TransferByte (rfm22b_dev->spi_id,RFM22_fifo_access| 0x80); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + int bytes_to_write = (rfm22b_dev->tx_data_wr - rfm22b_dev->tx_data_rd); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bytes_to_write = (bytes_to_write > max_bytes) ? max_bytes : bytes_to_write; + PIOS_SPI_TransferBlock (rfm22b_dev->spi_id,&tx_buffer[rfm22b_dev->tx_data_rd],NULL,bytes_to_write,NULL); + rfm22b_dev->tx_data_rd += bytes_to_write; + rfm22_deassertCs (rfm22b_dev); + rfm22_releaseBus (rfm22b_dev); + + return PIOS_RFM22B_INT_SUCCESS; + } + else if (rfm22b_dev->status_regs.int_status_1.packet_sent_interrupt) + { + /* + * Transition + * out + * of + * Tx + * mode. */ + rfm22b_dev->rfm22b_state = RFM22B_STATE_TRANSITION; + + return PIOS_RFM22B_TX_COMPLETE; + } + + return 0; } /** - * Process a Rx interrupt from the RFM22B device. - * - * @param[in] rfm22b_id The rfm22b device. - * @return PIOS_RFM22B_RX_COMPLETE on completed Rx, or PIOS_RFM22B_INT_SUCCESS/PIOS_RFM22B_INT_FAILURE. - */ -pios_rfm22b_int_result PIOS_RFM22B_ProcessRx(uint32_t rfm22b_id) -{ - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; + * + * Process + * a + * Rx + * interrupt + * from + * the + * RFM22B + * device. + * + * + * @param[in] + * rfm22b_id + * + * The + * rfm22b + * device. + * + * @return + * PIOS_RFM22B_RX_COMPLETE + * on + * completed + * Rx, + * or + * PIOS_RFM22B_INT_SUCCESS/PIOS_RFM22B_INT_FAILURE. + */ +pios_rfm22b_int_result PIOS_RFM22B_ProcessRx + (uint32_trfm22b_id){ + struct pios_rfm22b_dev * rfm22b_dev =(struct pios_rfm22b_dev *)rfm22b_id; - if (!PIOS_RFM22B_Validate(rfm22b_dev)) { - return PIOS_RFM22B_INT_FAILURE; - } - uint8_t *rx_buffer = rfm22b_dev->rx_packet_handle; - pios_rfm22b_int_result ret = PIOS_RFM22B_INT_SUCCESS; + if (!PIOS_RFM22B_Validate (rfm22b_dev)){ + return PIOS_RFM22B_INT_FAILURE; + } - // Read the device status registers - if (!pios_rfm22_readStatus(rfm22b_dev)) { - rfm22_rxFailure(rfm22b_dev); - return PIOS_RFM22B_INT_FAILURE; - } - // FIFO under/over flow error. Restart RX mode. - if (rfm22b_dev->status_regs.int_status_1.fifo_underoverflow_error || - rfm22b_dev->status_regs.int_status_1.crc_error) { - rfm22_rxFailure(rfm22b_dev); - return PIOS_RFM22B_INT_FAILURE; - } - // Valid packet received - if (rfm22b_dev->status_regs.int_status_1.valid_packet_received) { - // Claim the SPI bus. - rfm22_claimBus(rfm22b_dev); - // read the total length of the packet data - uint32_t len = rfm22_read(rfm22b_dev, RFM22_received_packet_length); - // The received packet is going to be larger than the receive buffer - if (len > rfm22b_dev->max_packet_len) { - rfm22_releaseBus(rfm22b_dev); - rfm22_rxFailure(rfm22b_dev); - return PIOS_RFM22B_INT_FAILURE; - } - // there must still be data in the RX FIFO we need to get - if (rfm22b_dev->rx_buffer_wr < len) { - int32_t bytes_to_read = len - rfm22b_dev->rx_buffer_wr; - // Fetch the data from the RX FIFO - rfm22_assertCs(rfm22b_dev); - PIOS_SPI_TransferByte(rfm22b_dev->spi_id, RFM22_fifo_access & 0x7F); - rfm22b_dev->rx_buffer_wr += (PIOS_SPI_TransferBlock(rfm22b_dev->spi_id, OUT_FF, (uint8_t *)&rx_buffer[rfm22b_dev->rx_buffer_wr], - bytes_to_read, NULL) == 0) ? bytes_to_read : 0; - rfm22_deassertCs(rfm22b_dev); - } - // Read the packet header (destination ID) - rfm22b_dev->rx_destination_id = rfm22_read(rfm22b_dev, RFM22_received_header0); - rfm22b_dev->rx_destination_id |= (rfm22_read(rfm22b_dev, RFM22_received_header1) << 8); - rfm22b_dev->rx_destination_id |= (rfm22_read(rfm22b_dev, RFM22_received_header2) << 16); - rfm22b_dev->rx_destination_id |= (rfm22_read(rfm22b_dev, RFM22_received_header3) << 24); - // Release the SPI bus. - rfm22_releaseBus(rfm22b_dev); - // Is there a length error? - if (rfm22b_dev->rx_buffer_wr != len) { - rfm22_rxFailure(rfm22b_dev); - return PIOS_RFM22B_INT_FAILURE; - } - // Increment the total byte received count. - rfm22b_dev->stats.rx_byte_count += rfm22b_dev->rx_buffer_wr; - // Update the pair status with this packet. - rfm22_updatePairStatus(rfm22b_dev); - // We're finished with Rx mode - rfm22b_dev->rfm22b_state = RFM22B_STATE_TRANSITION; - ret = PIOS_RFM22B_RX_COMPLETE; - } else if (rfm22b_dev->status_regs.int_status_1.rx_fifo_almost_full) { - // RX FIFO almost full, it needs emptying - // read data from the rf chips FIFO buffer - // Claim the SPI bus. - rfm22_claimBus(rfm22b_dev); - // Read the total length of the packet data - uint16_t len = rfm22_read(rfm22b_dev, RFM22_received_packet_length); - // The received packet is going to be larger than the specified length - if ((rfm22b_dev->rx_buffer_wr + RX_FIFO_HI_WATERMARK) > len) { - rfm22_releaseBus(rfm22b_dev); - rfm22_rxFailure(rfm22b_dev); - return PIOS_RFM22B_INT_FAILURE; - } - // The received packet is going to be larger than the receive buffer - if ((rfm22b_dev->rx_buffer_wr + RX_FIFO_HI_WATERMARK) > rfm22b_dev->max_packet_len) { - rfm22_releaseBus(rfm22b_dev); - rfm22_rxFailure(rfm22b_dev); - return PIOS_RFM22B_INT_FAILURE; - } - // Fetch the data from the RX FIFO - rfm22_assertCs(rfm22b_dev); - PIOS_SPI_TransferByte(rfm22b_dev->spi_id, RFM22_fifo_access & 0x7F); - rfm22b_dev->rx_buffer_wr += (PIOS_SPI_TransferBlock(rfm22b_dev->spi_id, OUT_FF, (uint8_t *)&rx_buffer[rfm22b_dev->rx_buffer_wr], - RX_FIFO_HI_WATERMARK, NULL) == 0) ? RX_FIFO_HI_WATERMARK : 0; - rfm22_deassertCs(rfm22b_dev); - // Release the SPI bus. - rfm22_releaseBus(rfm22b_dev); - // Make sure that we're in RX mode. - rfm22b_dev->rfm22b_state = RFM22B_STATE_RX_MODE; - } else if (rfm22b_dev->status_regs.int_status_2.valid_preamble_detected) { - // Valid preamble detected - RX_LED_ON; - // Sync word detected + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + uint8_t * rx_buffer =rfm22b_dev->rx_packet_handle; + pios_rfm22b_int_result ret = PIOS_RFM22B_INT_SUCCESS; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * Read + * the + * device + * status + * registers */ + if (!pios_rfm22_readStatus (rfm22b_dev)){ + rfm22_rxFailure (rfm22b_dev); + + return PIOS_RFM22B_INT_FAILURE; + } + /* + * FIFO + * under/over + * flow + * error. + * + * Restart + * RX + * mode. */ + if (rfm22b_dev->status_regs.int_status_1.fifo_underoverflow_error || + rfm22b_dev->status_regs.int_status_1.crc_error) + { + rfm22_rxFailure (rfm22b_dev); + + return PIOS_RFM22B_INT_FAILURE; + } + /* + * Valid + * packet + * received */ + if (rfm22b_dev->status_regs.int_status_1.valid_packet_received){ + /* + * Claim + * the + * SPI + * bus. */ + rfm22_claimBus (rfm22b_dev); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * read + * the + * total + * length + * of + * the + * packet + * data */ + uint32_t len = rfm22_read(rfm22b_dev, RFM22_received_packet_length); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * The + * received + * packet + * is + * going + * to + * be + * larger + * than + * the + * receive + * buffer */ + if (len > rfm22b_dev->max_packet_len){ + rfm22_releaseBus (rfm22b_dev); + rfm22_rxFailure (rfm22b_dev); + + return PIOS_RFM22B_INT_FAILURE; + } + /* + * there + * must + * still + * be + * data + * in + * the + * RX + * FIFO + * we + * need + * to + * get */ + if (rfm22b_dev->rx_buffer_wr < len){ + int32_t bytes_to_read = len - rfm22b_dev->rx_buffer_wr; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * Fetch + * the + * data + * from + * the + * RX + * FIFO */ + rfm22_assertCs (rfm22b_dev); + PIOS_SPI_TransferByte (rfm22b_dev->spi_id,RFM22_fifo_access& 0x7F); + rfm22b_dev->rx_buffer_wr += (PIOS_SPI_TransferBlock(rfm22b_dev->spi_id, OUT_FF, (uint8_t *)&rx_buffer[rfm22b_dev->rx_buffer_wr], + bytes_to_read, NULL) == 0) ? bytes_to_read : 0; + rfm22_deassertCs (rfm22b_dev); + } + + /* + * Read + * the + * packet + * header + * (destination + * ID) */ + rfm22b_dev->rx_destination_id = rfm22_read(rfm22b_dev, RFM22_received_header0); + rfm22b_dev->rx_destination_id |= (rfm22_read(rfm22b_dev, RFM22_received_header1)<< 8); + rfm22b_dev->rx_destination_id |= (rfm22_read(rfm22b_dev, RFM22_received_header2)<< 16); + rfm22b_dev->rx_destination_id |= (rfm22_read(rfm22b_dev, RFM22_received_header3)<< 24); + + /* + * Release + * the + * SPI + * bus. */ + rfm22_releaseBus (rfm22b_dev); + /* + * Is + * there + * a + * length + * error? */ + if (rfm22b_dev->rx_buffer_wr != len){ + rfm22_rxFailure (rfm22b_dev); + + return PIOS_RFM22B_INT_FAILURE; + } + + /* + * Increment + * the + * total + * byte + * received + * count. */ + rfm22b_dev->stats.rx_byte_count += rfm22b_dev->rx_buffer_wr; + + /* + * Update + * the + * pair + * status + * with + * this + * packet. */ + rfm22_updatePairStatus (rfm22b_dev); + + /* + * We're + * finished + * with + * Rx + * mode */ + rfm22b_dev->rfm22b_state = RFM22B_STATE_TRANSITION; + + ret = PIOS_RFM22B_RX_COMPLETE; + } + else if (rfm22b_dev->status_regs.int_status_1.rx_fifo_almost_full) + { + /* + * RX + * FIFO + * almost + * full, + * it + * needs + * emptying + * read + * data + * from + * the + * rf + * chips + * FIFO + * buffer + + */ + + /* + * Claim + * the + * SPI + * bus. */ + rfm22_claimBus (rfm22b_dev); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * Read + * the + * total + * length + * of + * the + * packet + * data */ + uint16_t len = rfm22_read(rfm22b_dev, RFM22_received_packet_length); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * The + * received + * packet + * is + * going + * to + * be + * larger + * than + * the + * specified + * length */ + if ((rfm22b_dev->rx_buffer_wr + RX_FIFO_HI_WATERMARK) > len){ + rfm22_releaseBus (rfm22b_dev); + rfm22_rxFailure (rfm22b_dev); + + return PIOS_RFM22B_INT_FAILURE; + } + /* + * The + * received + * packet + * is + * going + * to + * be + * larger + * than + * the + * receive + * buffer */ + if ((rfm22b_dev->rx_buffer_wr + RX_FIFO_HI_WATERMARK) > rfm22b_dev->max_packet_len){ + rfm22_releaseBus (rfm22b_dev); + rfm22_rxFailure (rfm22b_dev); + + return PIOS_RFM22B_INT_FAILURE; + } + + /* + * Fetch + * the + * data + * from + * the + * RX + * FIFO */ + rfm22_assertCs (rfm22b_dev); + PIOS_SPI_TransferByte (rfm22b_dev->spi_id,RFM22_fifo_access& 0x7F); + rfm22b_dev->rx_buffer_wr += (PIOS_SPI_TransferBlock(rfm22b_dev->spi_id, OUT_FF, (uint8_t *)&rx_buffer[rfm22b_dev->rx_buffer_wr], + RX_FIFO_HI_WATERMARK, NULL) == 0) ? RX_FIFO_HI_WATERMARK : 0; + rfm22_deassertCs (rfm22b_dev); + + /* + * Release + * the + * SPI + * bus. */ + rfm22_releaseBus (rfm22b_dev); + + /* + * Make + * sure + * that + * we're + * in + * RX + * mode. */ + rfm22b_dev->rfm22b_state = RFM22B_STATE_RX_MODE; + } + else if (rfm22b_dev->status_regs.int_status_2.valid_preamble_detected) + { + /* + * Valid + * preamble + * detected */ + RX_LED_ON; + + /* + * Sync + * word + * detected */ #ifdef PIOS_RFM22B_DEBUG_ON_TELEM - D2_LED_ON; -#endif // PIOS_RFM22B_DEBUG_ON_TELEM - rfm22b_dev->packet_start_ticks = xTaskGetTickCount(); - if (rfm22b_dev->packet_start_ticks == 0) { - rfm22b_dev->packet_start_ticks = 1; - } + D2_LED_ON; +#endif /* + * PIOS_RFM22B_DEBUG_ON_TELEM */ + rfm22b_dev->packet_start_ticks = xTaskGetTickCount(); + if (rfm22b_dev->packet_start_ticks == 0){ + rfm22b_dev->packet_start_ticks = 1; + } - // We detected the preamble, now wait for sync. - rfm22b_dev->rfm22b_state = RFM22B_STATE_RX_WAIT_SYNC; - } else if (rfm22b_dev->status_regs.int_status_2.sync_word_detected) { - // Claim the SPI bus. - rfm22_claimBus(rfm22b_dev); + /* + * We + * detected + * the + * preamble, + * now + * wait + * for + * sync. */ + rfm22b_dev->rfm22b_state = RFM22B_STATE_RX_WAIT_SYNC; + } + else if (rfm22b_dev->status_regs.int_status_2.sync_word_detected) + { + /* + * Claim + * the + * SPI + * bus. */ + rfm22_claimBus (rfm22b_dev); - // read the 10-bit signed afc correction value - // bits 9 to 2 - uint16_t afc_correction = (uint16_t)rfm22_read(rfm22b_dev, RFM22_afc_correction_read) << 8; - // bits 1 & 0 - afc_correction |= (uint16_t)rfm22_read(rfm22b_dev, RFM22_ook_counter_value1) & 0x00c0; - afc_correction >>= 6; - // convert the afc value to Hz - int32_t afc_corr = (int32_t)(rfm22b_dev->frequency_step_size * afc_correction + 0.5f); - rfm22b_dev->afc_correction_Hz = (afc_corr < -127) ? -127 : ((afc_corr > 127) ? 127 : afc_corr); - // read rx signal strength .. 45 = -100dBm, 205 = -20dBm - uint8_t rssi = rfm22_read(rfm22b_dev, RFM22_rssi); - // convert to dBm - rfm22b_dev->rssi_dBm = (int8_t)(rssi >> 1) - 122; - // Release the SPI bus. - rfm22_releaseBus(rfm22b_dev); - // Indicate that we're in RX mode. - rfm22b_dev->rfm22b_state = RFM22B_STATE_RX_MODE; - } else if ((rfm22b_dev->rfm22b_state == RFM22B_STATE_RX_WAIT_SYNC) && !rfm22b_dev->status_regs.int_status_2.valid_preamble_detected) { - // Waiting for the preamble timed out. - rfm22_rxFailure(rfm22b_dev); - return PIOS_RFM22B_INT_FAILURE; - } - return ret; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * read + * the + * 10-bit + * signed + * afc + * correction + * value */ + /* + * bits + * 9 + * to + * 2 */ + uint16_t afc_correction = (uint16_t)rfm22_read(rfm22b_dev, RFM22_afc_correction_read)<< 8; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * bits + * 1 + * & + * 0 */ + afc_correction |= (uint16_t)rfm22_read(rfm22b_dev, RFM22_ook_counter_value1) & 0x00c0; + afc_correction >>= 6; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * convert + * the + * afc + * value + * to + * Hz */ + int32_t afc_corr = (int32_t)(rfm22b_dev->frequency_step_size * afc_correction + 0.5f); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rfm22b_dev->afc_correction_Hz = (afc_corr < -127) ? -127 : ((afc_corr > 127) ? 127 : afc_corr); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * read + * rx + * signal + * strength + * .. + * 45 + * = + * -100dBm, + * 205 + * = + * -20dBm */ + uint8_t rssi = rfm22_read(rfm22b_dev, RFM22_rssi); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * convert + * to + * dBm */ + rfm22b_dev->rssi_dBm = (int8_t)(rssi >> 1) - 122; + + /* + * Release + * the + * SPI + * bus. */ + rfm22_releaseBus (rfm22b_dev); + + /* + * Indicate + * that + * we're + * in + * RX + * mode. */ + rfm22b_dev->rfm22b_state = RFM22B_STATE_RX_MODE; + } + else if ((rfm22b_dev->rfm22b_state == RFM22B_STATE_RX_WAIT_SYNC) && !rfm22b_dev->status_regs.int_status_2.valid_preamble_detected) + { + /* + * Waiting + * for + * the + * preamble + * timed + * out. */ + rfm22_rxFailure (rfm22b_dev); + + return PIOS_RFM22B_INT_FAILURE; + } + + return ret; } /** - * Set the PPM packet received callback. - * - * @param[in] rfm22b_dev The RFM22B device ID. - * @param[in] cb The callback function pointer. - */ -void PIOS_RFM22B_SetPPMCallback(uint32_t rfm22b_id, PPMReceivedCallback cb) -{ - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; + * + * Set + * the + * PPM + * packet + * received + * callback. + * + * + * @param[in] + * rfm22b_dev + * + * The + * RFM22B + * device + * ID. + * + * @param[in] + * cb + * + * + * + * + * + * + * + * + * + * The + * callback + * function + * pointer. + */ +void PIOS_RFM22B_SetPPMCallback +( + uint32_t + rfm22b_id, + PPMReceivedCallback + cb +){ + struct pios_rfm22b_dev * rfm22b_dev =(struct pios_rfm22b_dev *)rfm22b_id; - if (!PIOS_RFM22B_Validate(rfm22b_dev)) { - return; - } + if (!PIOS_RFM22B_Validate (rfm22b_dev)){ + return; + } - rfm22b_dev->ppm_callback = cb; + rfm22b_dev->ppm_callback = cb; } /** - * Set the PPM values to be transmitted. - * - * @param[in] rfm22b_dev The RFM22B device ID. - * @param[in] channels The PPM channel values. - */ -extern void PIOS_RFM22B_PPMSet(uint32_t rfm22b_id, int16_t *channels) -{ - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; + * + * Set + * the + * PPM + * values + * to + * be + * transmitted. + * + * + * @param[in] + * rfm22b_dev + * + * The + * RFM22B + * device + * ID. + * + * @param[in] + * channels + * + * + * + * The + * PPM + * channel + * values. + */ +extern void PIOS_RFM22B_PPMSet +( + uint32_t + rfm22b_id, + int16_t + * + channels +){ + struct pios_rfm22b_dev * rfm22b_dev =(struct pios_rfm22b_dev *)rfm22b_id; - if (!PIOS_RFM22B_Validate(rfm22b_dev)) { - return; - } + if (!PIOS_RFM22B_Validate (rfm22b_dev)){ + return; + } - for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS; ++i) { - rfm22b_dev->ppm[i] = channels[i]; - } + for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS; ++i) + { + rfm22b_dev->ppm[i] = channels[i]; + } } /** - * Fetch the PPM values that have been received. - * - * @param[in] rfm22b_dev The RFM22B device structure pointer. - * @param[out] channels The PPM channel values. - */ -extern void PIOS_RFM22B_PPMGet(uint32_t rfm22b_id, int16_t *channels) -{ - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; + * + * Fetch + * the + * PPM + * values + * that + * have + * been + * received. + * + * + * @param[in] + * rfm22b_dev + * + * The + * RFM22B + * device + * structure + * pointer. + * + * @param[out] + * channels + * + * + * The + * PPM + * channel + * values. + */ +extern void PIOS_RFM22B_PPMGet +( + uint32_t + rfm22b_id, + int16_t + * + channels +){ + struct pios_rfm22b_dev * rfm22b_dev =(struct pios_rfm22b_dev *)rfm22b_id; - if (!PIOS_RFM22B_Validate(rfm22b_dev)) { - return; - } + if (!PIOS_RFM22B_Validate (rfm22b_dev)){ + return; + } - for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS; ++i) { - channels[i] = rfm22b_dev->ppm[i]; - } + for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS; ++i) + { + channels[i] = rfm22b_dev->ppm[i]; + } } /** - * Validate that the device structure is valid. - * - * @param[in] rfm22b_dev The RFM22B device structure pointer. - */ -inline bool PIOS_RFM22B_Validate(struct pios_rfm22b_dev *rfm22b_dev) -{ - return rfm22b_dev != NULL && rfm22b_dev->magic == PIOS_RFM22B_DEV_MAGIC; + * + * Validate + * that + * the + * device + * structure + * is + * valid. + * + * + * @param[in] + * rfm22b_dev + * + * The + * RFM22B + * device + * structure + * pointer. + */ +inline bool PIOS_RFM22B_Validate + (struct pios_rfm22b_dev* rfm22b_dev){ + return rfm22b_dev != NULL && rfm22b_dev->magic == PIOS_RFM22B_DEV_MAGIC; } /***************************************************************************** -* The Device Control Thread -*****************************************************************************/ + * + * The + * Device + * Control + * Thread + *****************************************************************************/ /** - * The task that controls the radio state machine. - * - * @param[in] paramters The task parameters. - */ -static void pios_rfm22_task(void *parameters) -{ - struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)parameters; + * + * The + * task + * that + * controls + * the + * radio + * state + * machine. + * + * + * @param[in] + * paramters + * + * The + * task + * parameters. + */ +static void pios_rfm22_task + (void* parameters){ + struct pios_rfm22b_dev * rfm22b_dev =(struct pios_rfm22b_dev *)parameters; - if (!PIOS_RFM22B_Validate(rfm22b_dev)) { - return; - } - portTickType lastEventTicks = xTaskGetTickCount(); + if (!PIOS_RFM22B_Validate (rfm22b_dev)){ + return; + } - while (1) { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + portTickType lastEventTicks = xTaskGetTickCount(); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + while (1) + { #if defined(PIOS_INCLUDE_WDG) && defined(PIOS_WDG_RFM22B) - // Update the watchdog timer - PIOS_WDG_UpdateFlag(PIOS_WDG_RFM22B); + /* + * Update + * the + * watchdog + * timer */ + PIOS_WDG_UpdateFlag ( + PIOS_WDG_RFM22B); #endif /* PIOS_WDG_RFM22B */ + /* + * Wait + * for + * a + * signal + * indicating + * an + * external + * interrupt + * or + * a + * pending + * send/receive + * request. */ + if (xSemaphoreTake(rfm22b_dev->isrPending, ISR_TIMEOUT / portTICK_RATE_MS) == pdTRUE){ + lastEventTicks = xTaskGetTickCount(); - // Wait for a signal indicating an external interrupt or a pending send/receive request. - if (xSemaphoreTake(rfm22b_dev->isrPending, ISR_TIMEOUT / portTICK_RATE_MS) == pdTRUE) { - lastEventTicks = xTaskGetTickCount(); - // Process events through the state machine. - enum pios_radio_event event; - while (xQueueReceive(rfm22b_dev->eventQueue, &event, 0) == pdTRUE) { - if ((event == RADIO_EVENT_INT_RECEIVED) && - ((rfm22b_dev->state == RADIO_STATE_UNINITIALIZED) || (rfm22b_dev->state == RADIO_STATE_INITIALIZING))) { - continue; - } - rfm22_process_event(rfm22b_dev, event); - } - } else { - // Has it been too long since the last event? - portTickType curTicks = xTaskGetTickCount(); - if (pios_rfm22_time_difference_ms(lastEventTicks, curTicks) > PIOS_RFM22B_SUPERVISOR_TIMEOUT) { - // Clear the event queue. - enum pios_radio_event event; - while (xQueueReceive(rfm22b_dev->eventQueue, &event, 0) == pdTRUE) { - // Do nothing; - } - lastEventTicks = xTaskGetTickCount(); - // Transsition through an error event. - rfm22_process_event(rfm22b_dev, RADIO_EVENT_ERROR); - } - } - // Change channels if necessary. - if (rfm22_changeChannel(rfm22b_dev)) { - rfm22_process_event(rfm22b_dev, RADIO_EVENT_RX_MODE); - } - portTickType curTicks = xTaskGetTickCount(); - // Have we been sending / receiving this packet too long? - if ((rfm22b_dev->packet_start_ticks > 0) && - (pios_rfm22_time_difference_ms(rfm22b_dev->packet_start_ticks, curTicks) > (rfm22b_dev->packet_time * 3))) { - rfm22_process_event(rfm22b_dev, RADIO_EVENT_TIMEOUT); - } - // Start transmitting a packet if it's time. - bool time_to_send = rfm22_timeToSend(rfm22b_dev); - #ifdef PIOS_RFM22B_DEBUG_ON_TELEM - if (time_to_send) { - D4_LED_ON; - } else { - D4_LED_OFF; - } - #endif - if (time_to_send && PIOS_RFM22B_InRxWait((uint32_t)rfm22b_dev)) { - rfm22_process_event(rfm22b_dev, RADIO_EVENT_TX_START); - } - } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * Process + * events + * through + * the + * state + * machine. */ + enum pios_radio_event event; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + while (xQueueReceive(rfm22b_dev->eventQueue, &event, 0) == pdTRUE) + { + if ((event == RADIO_EVENT_INT_RECEIVED) && + ((rfm22b_dev->state == RADIO_STATE_UNINITIALIZED) || (rfm22b_dev->state == RADIO_STATE_INITIALIZING))) + { + continue; + } + + rfm22_process_event (rfm22b_dev,event); + } + } + else { + /* + * Has + * it + * been + * too + * long + * since + * the + * last + * event? */ + portTickType curTicks = xTaskGetTickCount(); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + if (pios_rfm22_time_difference_ms(lastEventTicks, curTicks) > PIOS_RFM22B_SUPERVISOR_TIMEOUT){ + /* + * Clear + * the + * event + * queue. */ + enum pios_radio_event event; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + while (xQueueReceive(rfm22b_dev->eventQueue, &event, 0) == pdTRUE) + { + /* + * Do + * nothing; */ + } + lastEventTicks = xTaskGetTickCount(); + + /* + * Transsition + * through + * an + * error + * event. */ + rfm22_process_event (rfm22b_dev,RADIO_EVENT_ERROR); + } + } + /* + * Change + * channels + * if + * necessary. */ + if (rfm22_changeChannel(rfm22b_dev)){ + rfm22_process_event (rfm22b_dev,RADIO_EVENT_RX_MODE); + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + portTickType curTicks = xTaskGetTickCount(); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * Have + * we + * been + * sending + * / + * receiving + * this + * packet + * too + * long? */ + if ((rfm22b_dev->packet_start_ticks > 0) && + (pios_rfm22_time_difference_ms (rfm22b_dev->packet_start_ticks,curTicks) > (rfm22b_dev->packet_time * 3))) + { + rfm22_process_event (rfm22b_dev,RADIO_EVENT_TIMEOUT); + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * Start + * transmitting + * a + * packet + * if + * it's + * time. */ + bool time_to_send = rfm22_timeToSend(rfm22b_dev); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #ifdef PIOS_RFM22B_DEBUG_ON_TELEM + if ( + time_to_send) + { + D4_LED_ON; + } + else + { + D4_LED_OFF; + } + #endif + if (time_to_send && PIOS_RFM22B_InRxWait((uint32_t)rfm22b_dev)){ + rfm22_process_event (rfm22b_dev,RADIO_EVENT_TX_START); + } + } } /***************************************************************************** -* The State Machine Functions -*****************************************************************************/ + * + * The + * State + * Machine + * Functions + *****************************************************************************/ /** - * Inject an event into the RFM22B state machine. - * - * @param[in] rfm22b_dev The device structure - * @param[in] event The event to inject - * @param[in] inISR Is this being called from an interrrup service routine? - */ -static void pios_rfm22_inject_event(struct pios_rfm22b_dev *rfm22b_dev, enum pios_radio_event event, bool inISR) -{ - if (inISR) { - // Store the event. - portBASE_TYPE pxHigherPriorityTaskWoken1; - if (xQueueSendFromISR(rfm22b_dev->eventQueue, &event, &pxHigherPriorityTaskWoken1) != pdTRUE) { - return; - } - // Signal the semaphore to wake up the handler thread. - portBASE_TYPE pxHigherPriorityTaskWoken2; - if (xSemaphoreGiveFromISR(rfm22b_dev->isrPending, &pxHigherPriorityTaskWoken2) != pdTRUE) { - // Something went fairly seriously wrong - rfm22b_dev->errors++; - } - portEND_SWITCHING_ISR((pxHigherPriorityTaskWoken2 == pdTRUE) || (pxHigherPriorityTaskWoken2 == pdTRUE)); - } else { - // Store the event. - if (xQueueSend(rfm22b_dev->eventQueue, &event, portMAX_DELAY) != pdTRUE) { - return; - } - // Signal the semaphore to wake up the handler thread. - if (xSemaphoreGive(rfm22b_dev->isrPending) != pdTRUE) { - // Something went fairly seriously wrong - rfm22b_dev->errors++; - } - } + * + * Inject + * an + * event + * into + * the + * RFM22B + * state + * machine. + * + * + * @param[in] + * rfm22b_dev + * The + * device + * structure + * + * @param[in] + * event + * The + * event + * to + * inject + * + * @param[in] + * inISR + * Is + * this + * being + * called + * from + * an + * interrrup + * service + * routine? + */ +static void pios_rfm22_inject_event +( + struct + pios_rfm22b_dev + * + rfm22b_dev, + enum + pios_radio_event + event, + bool + inISR +){ + if (inISR){ + /* + * Store + * the + * event. */ + portBASE_TYPE pxHigherPriorityTaskWoken1; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + if (xQueueSendFromISR(rfm22b_dev->eventQueue, &event, &pxHigherPriorityTaskWoken1) != pdTRUE){ + return; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * Signal + * the + * semaphore + * to + * wake + * up + * the + * handler + * thread. */ + portBASE_TYPE pxHigherPriorityTaskWoken2; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + if (xSemaphoreGiveFromISR(rfm22b_dev->isrPending, &pxHigherPriorityTaskWoken2) != pdTRUE){ + /* + * Something + * went + * fairly + * seriously + * wrong */ + rfm22b_dev->errors ++; + } + + portEND_SWITCHING_ISR ((pxHigherPriorityTaskWoken2== pdTRUE) || (pxHigherPriorityTaskWoken2 == pdTRUE)); + } + else { + /* + * Store + * the + * event. */ + if (xQueueSend(rfm22b_dev->eventQueue, &event, portMAX_DELAY) != pdTRUE){ + return; + } + /* + * Signal + * the + * semaphore + * to + * wake + * up + * the + * handler + * thread. */ + if (xSemaphoreGive(rfm22b_dev->isrPending) != pdTRUE){ + /* + * Something + * went + * fairly + * seriously + * wrong */ + rfm22b_dev->errors ++; + } + } } /** - * Process the next state transition from the given event. - * - * @param[in] rfm22b_dev The device structure - * @param[in] event The event to process - * @return enum pios_radio_event The next event to inject - */ -static enum pios_radio_event rfm22_process_state_transition(struct pios_rfm22b_dev *rfm22b_dev, enum pios_radio_event event) -{ - // No event - if (event >= RADIO_EVENT_NUM_EVENTS) { - return RADIO_EVENT_NUM_EVENTS; - } + * + * Process + * the + * next + * state + * transition + * from + * the + * given + * event. + * + * + * @param[in] + * rfm22b_dev + * The + * device + * structure + * + * @param[in] + * event + * The + * event + * to + * process + * + * @return + * enum + * pios_radio_event + * + * The + * next + * event + * to + * inject + */ +static enum pios_radio_event rfm22_process_state_transition +( + struct + pios_rfm22b_dev + * + rfm22b_dev, + enum + pios_radio_event + event +){ + /* + * No + * event */ + if (event >= RADIO_EVENT_NUM_EVENTS){ + return RADIO_EVENT_NUM_EVENTS; + } - // Don't transition if there is no transition defined - enum pios_radio_state next_state = rfm22b_transitions[rfm22b_dev->state].next_state[event]; - if (!next_state) { - return RADIO_EVENT_NUM_EVENTS; - } - /* - * Move to the next state - * - * This is done prior to calling the new state's entry function to - * guarantee that the entry function never depends on the previous - * state. This way, it cannot ever know what the previous state was. - */ - rfm22b_dev->state = next_state; - /* Call the entry function (if any) for the next state. */ - if (rfm22b_transitions[rfm22b_dev->state].entry_fn) { - return rfm22b_transitions[rfm22b_dev->state].entry_fn(rfm22b_dev); - } - return RADIO_EVENT_NUM_EVENTS; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * Don't + * transition + * if + * there + * is + * no + * transition + * defined */ + enum pios_radio_state next_state = rfm22b_transitions[rfm22b_dev->state].next_state[event]; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + if (!next_state){ + return RADIO_EVENT_NUM_EVENTS; + } + + /* + * + * Move + * to + * the + * next + * state + * + * + * This + * is + * done + * prior + * to + * calling + * the + * new + * state's + * entry + * function + * to + * + * guarantee + * that + * the + * entry + * function + * never + * depends + * on + * the + * previous + * + * state. + * + * This + * way, + * it + * cannot + * ever + * know + * what + * the + * previous + * state + * was. + */ + rfm22b_dev->state = next_state; + /* + * Call + * the + * entry + * function + * (if + * any) + * for + * the + * next + * state. + * */ + if (rfm22b_transitions[rfm22b_dev->state].entry_fn){ + return rfm22b_transitions[rfm22b_dev->state].entry_fn (rfm22b_dev); + } + + return RADIO_EVENT_NUM_EVENTS; } /** - * Process the given event through the state transition table. - * This could cause a series of events and transitions to take place. - * - * @param[in] rfm22b_dev The device structure - * @param[in] event The event to process - */ -static void rfm22_process_event(struct pios_rfm22b_dev *rfm22b_dev, enum pios_radio_event event) -{ - // Process all state transitions. - while (event != RADIO_EVENT_NUM_EVENTS) { - event = rfm22_process_state_transition(rfm22b_dev, event); - } + * + * Process + * the + * given + * event + * through + * the + * state + * transition + * table. + * + * This + * could + * cause + * a + * series + * of + * events + * and + * transitions + * to + * take + * place. + * + * + * @param[in] + * rfm22b_dev + * The + * device + * structure + * + * @param[in] + * event + * The + * event + * to + * process + */ +static void rfm22_process_event +( + struct + pios_rfm22b_dev + * + rfm22b_dev, + enum + pios_radio_event + event +){ + /* + * Process + * all + * state + * transitions. */ + while (event != RADIO_EVENT_NUM_EVENTS) + { + event = rfm22_process_state_transition(rfm22b_dev, event); + } } /***************************************************************************** -* The Device Initialization / Configuration Functions -*****************************************************************************/ + * + * The + * Device + * Initialization + * / + * Configuration + * Functions + *****************************************************************************/ /** - * Initialize (or re-initialize) the RFM22B radio device. - * - * @param[in] rfm22b_dev The device structure - * @return enum pios_radio_event The next event to inject - */ -static enum pios_radio_event rfm22_init(struct pios_rfm22b_dev *rfm22b_dev) -{ - // Initialize the register values. - rfm22b_dev->status_regs.int_status_1.raw = 0; - rfm22b_dev->status_regs.int_status_2.raw = 0; - rfm22b_dev->status_regs.device_status.raw = 0; - rfm22b_dev->status_regs.ezmac_status.raw = 0; + * + * Initialize + * (or + * re-initialize) + * the + * RFM22B + * radio + * device. + * + * + * @param[in] + * rfm22b_dev + * The + * device + * structure + * + * @return + * enum + * pios_radio_event + * + * The + * next + * event + * to + * inject + */ +static enum pios_radio_event rfm22_init + (struct pios_rfm22b_dev* rfm22b_dev){ + /* + * Initialize + * the + * register + * values. */ + rfm22b_dev->status_regs.int_status_1.raw = 0; + rfm22b_dev->status_regs.int_status_2.raw = 0; + rfm22b_dev->status_regs.device_status.raw = 0; + rfm22b_dev->status_regs.ezmac_status.raw = 0; + + /* + * Clean + * the + * LEDs */ + rfm22_clearLEDs(); + + /* + * Initialize + * the + * detected + * device + * statistics. */ + for (uint8_t i = 0; i < OPLINKSTATUS_PAIRIDS_NUMELEM; ++i) + { + rfm22b_dev->pair_stats[i].pairID = 0; + rfm22b_dev->pair_stats[i].rssi = -127; + rfm22b_dev->pair_stats[i].afc_correction = 0; + rfm22b_dev->pair_stats[i].lastContact = 0; + } + + /* + * Initlize + * the + * link + * stats. */ + for (uint8_t i = 0; i < RFM22B_RX_PACKET_STATS_LEN; ++i) + { + rfm22b_dev->rx_packet_stats[i] = 0; + } + /* + * Initialize + * the + * state */ + rfm22b_dev->stats.link_state = OPLINKSTATUS_LINKSTATE_ENABLED; + + /* + * Initialize + * the + * packets. */ + rfm22b_dev->rx_packet_len = 0; + rfm22b_dev->rx_destination_id = 0; + rfm22b_dev->tx_packet_handle = NULL; + + /* + * Initialize + * the + * devide + * state */ + rfm22b_dev->rx_buffer_wr = 0; + rfm22b_dev->tx_data_rd = rfm22b_dev->tx_data_wr = 0; + rfm22b_dev->channel = 0; + rfm22b_dev->channel_index = 0; + rfm22b_dev->afc_correction_Hz = 0; + rfm22b_dev->packet_start_ticks = 0; + rfm22b_dev->tx_complete_ticks = 0; + rfm22b_dev->rfm22b_state = RFM22B_STATE_INITIALIZING; + rfm22b_dev->on_sync_channel = false; + + /* + * software + * reset + * the + * RF + * chip + * .. + * following + * procedure + * according + * to + * Si4x3x + * Errata + * (rev. + * B) */ + rfm22_write_claim (rfm22b_dev,RFM22_op_and_func_ctrl1,RFM22_opfc1_swres); + + for (uint8_t i = 0; i < 50; ++i) + { + /* + * read + * the + * status + * registers */ + pios_rfm22_readStatus (rfm22b_dev); + /* + * Is + * the + * chip + * ready? */ + if (rfm22b_dev->status_regs.int_status_2.chip_ready){ + break; + } + + /* + * Wait + * 1ms + * if + * not. */ + PIOS_DELAY_WaitmS (1); + } + /* + * **************** */ + + /* + * read + * status + * - + * clears + * interrupt */ + pios_rfm22_readStatus (rfm22b_dev); + + /* + * Claim + * the + * SPI + * bus. */ + rfm22_claimBus (rfm22b_dev); + + /* + * disable + * all + * interrupts */ + rfm22_write ( rfm22b_dev, RFM22_interrupt_enable1,0x00); + rfm22_write ( rfm22b_dev, RFM22_interrupt_enable2,0x00); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * read + * the + * RF + * chip + * ID + * bytes */ + + /* + * read + * the + * device + * type */ + uint8_t device_type = rfm22_read(rfm22b_dev, RFM22_DEVICE_TYPE) & RFM22_DT_MASK; + /* + * read + * the + * device + * version */ + uint8_t device_version = rfm22_read(rfm22b_dev, RFM22_DEVICE_VERSION) & RFM22_DV_MASK; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - // Clean the LEDs - rfm22_clearLEDs(); - // Initialize the detected device statistics. - for (uint8_t i = 0; i < OPLINKSTATUS_PAIRIDS_NUMELEM; ++i) { - rfm22b_dev->pair_stats[i].pairID = 0; - rfm22b_dev->pair_stats[i].rssi = -127; - rfm22b_dev->pair_stats[i].afc_correction = 0; - rfm22b_dev->pair_stats[i].lastContact = 0; - } - // Initlize the link stats. - for (uint8_t i = 0; i < RFM22B_RX_PACKET_STATS_LEN; ++i) { - rfm22b_dev->rx_packet_stats[i] = 0; - } - // Initialize the state - rfm22b_dev->stats.link_state = OPLINKSTATUS_LINKSTATE_ENABLED; - // Initialize the packets. - rfm22b_dev->rx_packet_len = 0; - rfm22b_dev->rx_destination_id = 0; - rfm22b_dev->tx_packet_handle = NULL; - // Initialize the devide state - rfm22b_dev->rx_buffer_wr = 0; - rfm22b_dev->tx_data_rd = rfm22b_dev->tx_data_wr = 0; - rfm22b_dev->channel = 0; - rfm22b_dev->channel_index = 0; - rfm22b_dev->afc_correction_Hz = 0; - rfm22b_dev->packet_start_ticks = 0; - rfm22b_dev->tx_complete_ticks = 0; - rfm22b_dev->rfm22b_state = RFM22B_STATE_INITIALIZING; - rfm22b_dev->on_sync_channel = false; - // software reset the RF chip .. following procedure according to Si4x3x Errata (rev. B) - rfm22_write_claim(rfm22b_dev, RFM22_op_and_func_ctrl1, RFM22_opfc1_swres); - for (uint8_t i = 0; i < 50; ++i) { - // read the status registers - pios_rfm22_readStatus(rfm22b_dev); - // Is the chip ready? - if (rfm22b_dev->status_regs.int_status_2.chip_ready) { - break; - } - // Wait 1ms if not. - PIOS_DELAY_WaitmS(1); - } - // **************** - // read status - clears interrupt - pios_rfm22_readStatus(rfm22b_dev); - // Claim the SPI bus. - rfm22_claimBus(rfm22b_dev); - // disable all interrupts - rfm22_write(rfm22b_dev, RFM22_interrupt_enable1, 0x00); - rfm22_write(rfm22b_dev, RFM22_interrupt_enable2, 0x00); - // read the RF chip ID bytes - // read the device type - uint8_t device_type = rfm22_read(rfm22b_dev, RFM22_DEVICE_TYPE) & RFM22_DT_MASK; - // read the device version - uint8_t device_version = rfm22_read(rfm22b_dev, RFM22_DEVICE_VERSION) & RFM22_DV_MASK; #if defined(RFM22_DEBUG) - DEBUG_PRINTF(2, "rf device type: %d\n\r", device_type); - DEBUG_PRINTF(2, "rf device version: %d\n\r", device_version); + DEBUG_PRINTF ( + 2, + "rf device type: %d\n\r", + device_type); + DEBUG_PRINTF ( + 2, + "rf device version: %d\n\r", + device_version); #endif - - if (device_type != 0x08) { + if (device_type != 0x08){ #if defined(RFM22_DEBUG) - DEBUG_PRINTF(2, "rf device type: INCORRECT - should be 0x08\n\r"); + DEBUG_PRINTF ( + 2, + "rf device type: INCORRECT - should be 0x08\n\r"); #endif - // incorrect RF module type - return RADIO_EVENT_FATAL_ERROR; - } - if (device_version != RFM22_DEVICE_VERSION_B1) { + /* + * incorrect + * RF + * module + * type */ + return RADIO_EVENT_FATAL_ERROR; + } + if (device_version != RFM22_DEVICE_VERSION_B1){ #if defined(RFM22_DEBUG) - DEBUG_PRINTF(2, "rf device version: INCORRECT\n\r"); -#endif - // incorrect RF module version - return RADIO_EVENT_FATAL_ERROR; - } - - // calibrate our RF module to be exactly on frequency .. different for every module - rfm22_write(rfm22b_dev, RFM22_xtal_osc_load_cap, OSC_LOAD_CAP); - - // disable Low Duty Cycle Mode - rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl2, 0x00); - - // 1MHz clock output - rfm22_write(rfm22b_dev, RFM22_cpu_output_clk, RFM22_coc_1MHz); - - // READY mode - rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl1, RFM22_opfc1_xton); - - // choose the 3 GPIO pin functions - // GPIO port use default value - rfm22_write(rfm22b_dev, RFM22_io_port_config, RFM22_io_port_default); - if (rfm22b_dev->cfg.gpio_direction == GPIO0_TX_GPIO1_RX) { - // GPIO0 = TX State (to control RF Switch) - rfm22_write(rfm22b_dev, RFM22_gpio0_config, RFM22_gpio0_config_drv3 | RFM22_gpio0_config_txstate); - // GPIO1 = RX State (to control RF Switch) - rfm22_write(rfm22b_dev, RFM22_gpio1_config, RFM22_gpio1_config_drv3 | RFM22_gpio1_config_rxstate); - } else { - // GPIO0 = TX State (to control RF Switch) - rfm22_write(rfm22b_dev, RFM22_gpio0_config, RFM22_gpio0_config_drv3 | RFM22_gpio0_config_rxstate); - // GPIO1 = RX State (to control RF Switch) - rfm22_write(rfm22b_dev, RFM22_gpio1_config, RFM22_gpio1_config_drv3 | RFM22_gpio1_config_txstate); - } - // GPIO2 = Clear Channel Assessment - rfm22_write(rfm22b_dev, RFM22_gpio2_config, RFM22_gpio2_config_drv3 | RFM22_gpio2_config_cca); - - // FIFO mode, GFSK modulation - uint8_t fd_bit = rfm22_read(rfm22b_dev, RFM22_modulation_mode_control2) & RFM22_mmc2_fd; - rfm22_write(rfm22b_dev, RFM22_modulation_mode_control2, RFM22_mmc2_trclk_clk_none | RFM22_mmc2_dtmod_fifo | fd_bit | RFM22_mmc2_modtyp_gfsk); - - // setup to read the internal temperature sensor - - // ADC used to sample the temperature sensor - uint8_t adc_config = RFM22_ac_adcsel_temp_sensor | RFM22_ac_adcref_bg; - rfm22_write(rfm22b_dev, RFM22_adc_config, adc_config); - - // adc offset - rfm22_write(rfm22b_dev, RFM22_adc_sensor_amp_offset, 0); - - // temp sensor calibration .. �40C to +64C 0.5C resolution - rfm22_write(rfm22b_dev, RFM22_temp_sensor_calib, RFM22_tsc_tsrange0 | RFM22_tsc_entsoffs); - - // temp sensor offset - rfm22_write(rfm22b_dev, RFM22_temp_value_offset, 0); - - // start an ADC conversion - rfm22_write(rfm22b_dev, RFM22_adc_config, adc_config | RFM22_ac_adcstartbusy); - - // set the RSSI threshold interrupt to about -90dBm - rfm22_write(rfm22b_dev, RFM22_rssi_threshold_clear_chan_indicator, (-90 + 122) * 2); - - // enable the internal Tx & Rx packet handlers (without CRC) - rfm22_write(rfm22b_dev, RFM22_data_access_control, RFM22_dac_enpacrx | RFM22_dac_enpactx); - - // x-nibbles tx preamble - rfm22_write(rfm22b_dev, RFM22_preamble_length, TX_PREAMBLE_NIBBLES); - // x-nibbles rx preamble detection - rfm22_write(rfm22b_dev, RFM22_preamble_detection_ctrl1, RX_PREAMBLE_NIBBLES << 3); - - // header control - using a 4 by header with broadcast of 0xffffffff - rfm22_write(rfm22b_dev, RFM22_header_control1, - RFM22_header_cntl1_bcen_0 | - RFM22_header_cntl1_bcen_1 | - RFM22_header_cntl1_bcen_2 | - RFM22_header_cntl1_bcen_3 | - RFM22_header_cntl1_hdch_0 | - RFM22_header_cntl1_hdch_1 | - RFM22_header_cntl1_hdch_2 | - RFM22_header_cntl1_hdch_3); - // Check all bit of all bytes of the header, unless we're an unbound modem. - uint8_t header_mask = (rfm22_destinationID(rfm22b_dev) == 0xffffffff) ? 0 : 0xff; - rfm22_write(rfm22b_dev, RFM22_header_enable0, header_mask); - rfm22_write(rfm22b_dev, RFM22_header_enable1, header_mask); - rfm22_write(rfm22b_dev, RFM22_header_enable2, header_mask); - rfm22_write(rfm22b_dev, RFM22_header_enable3, header_mask); - // The destination ID and receive ID should be the same. - uint32_t id = rfm22_destinationID(rfm22b_dev); - rfm22_write(rfm22b_dev, RFM22_check_header0, id & 0xff); - rfm22_write(rfm22b_dev, RFM22_check_header1, (id >> 8) & 0xff); - rfm22_write(rfm22b_dev, RFM22_check_header2, (id >> 16) & 0xff); - rfm22_write(rfm22b_dev, RFM22_check_header3, (id >> 24) & 0xff); - // 4 header bytes, synchronization word length 3, 2, 1 & 0 used, packet length included in header. - rfm22_write(rfm22b_dev, RFM22_header_control2, - RFM22_header_cntl2_hdlen_3210 | - RFM22_header_cntl2_synclen_3210 | - ((TX_PREAMBLE_NIBBLES >> 8) & 0x01)); - - // sync word - rfm22_write(rfm22b_dev, RFM22_sync_word3, SYNC_BYTE_1); - rfm22_write(rfm22b_dev, RFM22_sync_word2, SYNC_BYTE_2); - rfm22_write(rfm22b_dev, RFM22_sync_word1, SYNC_BYTE_3); - rfm22_write(rfm22b_dev, RFM22_sync_word0, SYNC_BYTE_4); - - // TX FIFO Almost Full Threshold (0 - 63) - rfm22_write(rfm22b_dev, RFM22_tx_fifo_control1, TX_FIFO_HI_WATERMARK); - - // TX FIFO Almost Empty Threshold (0 - 63) - rfm22_write(rfm22b_dev, RFM22_tx_fifo_control2, TX_FIFO_LO_WATERMARK); - - // RX FIFO Almost Full Threshold (0 - 63) - rfm22_write(rfm22b_dev, RFM22_rx_fifo_control, RX_FIFO_HI_WATERMARK); - - // Set the frequency calibration - rfm22_write(rfm22b_dev, RFM22_xtal_osc_load_cap, rfm22b_dev->cfg.RFXtalCap); - - // Release the bus - rfm22_releaseBus(rfm22b_dev); - - // Initialize the frequency and datarate to te default. - rfm22_setNominalCarrierFrequency(rfm22b_dev, 0); - pios_rfm22_setDatarate(rfm22b_dev); - - return RADIO_EVENT_INITIALIZED; -} - -/** - * Set the air datarate for the RFM22B device. - * - * Carson's rule: - * The signal bandwidth is about 2(Delta-f + fm) .. - * - * Delta-f = frequency deviation - * fm = maximum frequency of the signal - * - * @param[in] rfm33b_dev The device structure pointer. - * @param[in] datarate The air datarate. - * @param[in] data_whitening Is data whitening desired? - */ -static void pios_rfm22_setDatarate(struct pios_rfm22b_dev *rfm22b_dev) -{ - enum rfm22b_datarate datarate = rfm22b_dev->datarate; - bool data_whitening = true; - - // Claim the SPI bus. - rfm22_claimBus(rfm22b_dev); - - // rfm22_if_filter_bandwidth - rfm22_write(rfm22b_dev, 0x1C, reg_1C[datarate]); - - // rfm22_afc_loop_gearshift_override - rfm22_write(rfm22b_dev, 0x1D, reg_1D[datarate]); - // RFM22_afc_timing_control - rfm22_write(rfm22b_dev, 0x1E, reg_1E[datarate]); - - // RFM22_clk_recovery_gearshift_override - rfm22_write(rfm22b_dev, 0x1F, reg_1F[datarate]); - // rfm22_clk_recovery_oversampling_ratio - rfm22_write(rfm22b_dev, 0x20, reg_20[datarate]); - // rfm22_clk_recovery_offset2 - rfm22_write(rfm22b_dev, 0x21, reg_21[datarate]); - // rfm22_clk_recovery_offset1 - rfm22_write(rfm22b_dev, 0x22, reg_22[datarate]); - // rfm22_clk_recovery_offset0 - rfm22_write(rfm22b_dev, 0x23, reg_23[datarate]); - // rfm22_clk_recovery_timing_loop_gain1 - rfm22_write(rfm22b_dev, 0x24, reg_24[datarate]); - // rfm22_clk_recovery_timing_loop_gain0 - rfm22_write(rfm22b_dev, 0x25, reg_25[datarate]); - // rfm22_agc_override1 - rfm22_write(rfm22b_dev, RFM22_agc_override1, reg_69[datarate]); - - // rfm22_afc_limiter - rfm22_write(rfm22b_dev, 0x2A, reg_2A[datarate]); - - // rfm22_tx_data_rate1 - rfm22_write(rfm22b_dev, 0x6E, reg_6E[datarate]); - // rfm22_tx_data_rate0 - rfm22_write(rfm22b_dev, 0x6F, reg_6F[datarate]); - - if (!data_whitening) { - // rfm22_modulation_mode_control1 - rfm22_write(rfm22b_dev, 0x70, reg_70[datarate] & ~RFM22_mmc1_enwhite); - } else { - // rfm22_modulation_mode_control1 - rfm22_write(rfm22b_dev, 0x70, reg_70[datarate] | RFM22_mmc1_enwhite); - } - - // rfm22_modulation_mode_control2 - rfm22_write(rfm22b_dev, 0x71, reg_71[datarate]); - - // rfm22_frequency_deviation - rfm22_write(rfm22b_dev, 0x72, reg_72[datarate]); - - // rfm22_cpcuu - rfm22_write(rfm22b_dev, 0x58, reg_58[datarate]); - - rfm22_write(rfm22b_dev, RFM22_ook_counter_value1, 0x00); - rfm22_write(rfm22b_dev, RFM22_ook_counter_value2, 0x00); - - // Release the bus - rfm22_releaseBus(rfm22b_dev); -} - -/** - * Set the nominal carrier frequency, channel step size, and initial channel - * - * @param[in] rfm33b_dev The device structure pointer. - * @param[in] init_chan The initial channel to tune to. - */ -static void rfm22_setNominalCarrierFrequency(struct pios_rfm22b_dev *rfm22b_dev, uint8_t init_chan) -{ - // Set the frequency channels to start at 430MHz - uint32_t frequency_hz = RFM22B_NOMINAL_CARRIER_FREQUENCY; - // The step size is 10MHz / 250 channels = 40khz, and the step size is specified in 10khz increments. - uint8_t freq_hop_step_size = 4; - - // holds the hbsel (1 or 2) - uint8_t hbsel; - - if (frequency_hz < 480000000) { - hbsel = 0; - } else { - hbsel = 1; - } - float freq_mhz = (float)(frequency_hz) / 1000000.0f; - float xtal_freq_khz = 30000.0f; - float sfreq = freq_mhz / (10.0f * (xtal_freq_khz / 30000.0f) * (1 + hbsel)); - uint32_t fb = (uint32_t)sfreq - 24 + (64 + 32 * hbsel); - uint32_t fc = (uint32_t)((sfreq - (uint32_t)sfreq) * 64000.0f); - uint8_t fch = (fc >> 8) & 0xff; - uint8_t fcl = fc & 0xff; - - // Claim the SPI bus. - rfm22_claimBus(rfm22b_dev); - - // Setthe frequency hopping step size. - rfm22_write(rfm22b_dev, RFM22_frequency_hopping_step_size, freq_hop_step_size); - - // frequency hopping channel (0-255) - rfm22b_dev->frequency_step_size = 156.25f * hbsel; - - // frequency hopping channel (0-255) - rfm22b_dev->channel = init_chan; - rfm22_write(rfm22b_dev, RFM22_frequency_hopping_channel_select, init_chan); - - // no frequency offset - rfm22_write(rfm22b_dev, RFM22_frequency_offset1, 0); - rfm22_write(rfm22b_dev, RFM22_frequency_offset2, 0); - - // set the carrier frequency - rfm22_write(rfm22b_dev, RFM22_frequency_band_select, fb & 0xff); - rfm22_write(rfm22b_dev, RFM22_nominal_carrier_frequency1, fch); - rfm22_write(rfm22b_dev, RFM22_nominal_carrier_frequency0, fcl); - - // Release the bus - rfm22_releaseBus(rfm22b_dev); -} - - -/** - * Set the frequency hopping channel. - * - * @param[in] rfm33b_dev The device structure pointer. - */ -static bool rfm22_setFreqHopChannel(struct pios_rfm22b_dev *rfm22b_dev, uint8_t channel) -{ - // set the frequency hopping channel - if (rfm22b_dev->channel == channel) { - return false; - } -#ifdef PIOS_RFM22B_DEBUG_ON_TELEM - D3_LED_TOGGLE; -#endif // PIOS_RFM22B_DEBUG_ON_TELEM - rfm22b_dev->channel = channel; - rfm22_write_claim(rfm22b_dev, RFM22_frequency_hopping_channel_select, channel); - return true; -} - -/** - * Read the RFM22B interrupt and device status registers - * - * @param[in] rfm22b_dev The device structure - */ -static bool pios_rfm22_readStatus(struct pios_rfm22b_dev *rfm22b_dev) -{ - // 1. Read the interrupt statuses with burst read - rfm22_claimBus(rfm22b_dev); // Set RC and the semaphore - uint8_t write_buf[3] = { RFM22_interrupt_status1 &0x7f, 0xFF, 0xFF }; - uint8_t read_buf[3]; - rfm22_assertCs(rfm22b_dev); - PIOS_SPI_TransferBlock(rfm22b_dev->spi_id, write_buf, read_buf, sizeof(write_buf), NULL); - rfm22_deassertCs(rfm22b_dev); - rfm22b_dev->status_regs.int_status_1.raw = read_buf[1]; - rfm22b_dev->status_regs.int_status_2.raw = read_buf[2]; - - // Device status - rfm22b_dev->status_regs.device_status.raw = rfm22_read(rfm22b_dev, RFM22_device_status); - - // EzMAC status - rfm22b_dev->status_regs.ezmac_status.raw = rfm22_read(rfm22b_dev, RFM22_ezmac_status); - - // Release the bus - rfm22_releaseBus(rfm22b_dev); - - // the RF module has gone and done a reset - we need to re-initialize the rf module - if (rfm22b_dev->status_regs.int_status_2.poweron_reset) { - return false; - } - - return true; -} - -/** - * Recover from a failure in receiving a packet. - * - * @param[in] rfm22b_dev The device structure - * @return enum pios_radio_event The next event to inject - */ -static void rfm22_rxFailure(struct pios_rfm22b_dev *rfm22b_dev) -{ - rfm22b_dev->stats.rx_failure++; - rfm22b_dev->rx_buffer_wr = 0; - rfm22b_dev->packet_start_ticks = 0; - rfm22b_dev->rfm22b_state = RFM22B_STATE_TRANSITION; -} - - -/***************************************************************************** -* Radio Transmit and Receive functions. -*****************************************************************************/ - -/** - * Start a transmit if possible - * - * @param[in] radio_dev The device structure - * @return enum pios_radio_event The next event to inject - */ -static enum pios_radio_event radio_txStart(struct pios_rfm22b_dev *radio_dev) -{ - uint8_t *p = radio_dev->tx_packet; - uint8_t len = 0; - uint8_t max_data_len = radio_dev->max_packet_len - (radio_dev->ppm_only_mode ? 0 : RS_ECC_NPARITY); - - // Don't send if it's not our turn, or if we're receiving a packet. - if (!rfm22_timeToSend(radio_dev) || !PIOS_RFM22B_InRxWait((uint32_t)radio_dev)) { - return RADIO_EVENT_RX_MODE; - } - - // Don't send anything if we're bound to a coordinator and not yet connected. - if (!rfm22_isCoordinator(radio_dev) && !rfm22_isConnected(radio_dev)) { - return RADIO_EVENT_RX_MODE; - } - - // Should we append PPM data to the packet? - if (radio_dev->ppm_send_mode) { - len = RFM22B_PPM_NUM_CHANNELS + (radio_dev->ppm_only_mode ? 2 : 1); - - // Ensure we can fit the PPM data in the packet. - if (max_data_len < len) { - return RADIO_EVENT_RX_MODE; - } - - // The first byte is a bitmask of valid channels. - p[0] = 0; - - // Read the PPM input. - for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS; ++i) { - int32_t val = radio_dev->ppm[i]; - if ((val == PIOS_RCVR_INVALID) || (val == PIOS_RCVR_TIMEOUT)) { - p[i + 1] = 0; - } else { - p[0] |= 1 << i; - p[i + 1] = (val < 1000) ? 0 : ((val >= 1900) ? 255 : (uint8_t)(256 * (val - 1000) / 900)); - } - } - - // The last byte is a CRC. - if (radio_dev->ppm_only_mode) { - uint8_t crc = 0; - for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS + 1; ++i) { - crc = PIOS_CRC_updateByte(crc, p[i]); - } - p[RFM22B_PPM_NUM_CHANNELS + 1] = crc; - } - } - - // Append data from the com interface if applicable. - if (!radio_dev->ppm_only_mode && radio_dev->tx_out_cb) { - // Try to get some data to send - bool need_yield = false; - len += (radio_dev->tx_out_cb)(radio_dev->tx_out_context, p + len, max_data_len - len, NULL, &need_yield); - } - - // Always send a packet on the sync channel if this modem is a coordinator. - if ((len == 0) && ((radio_dev->channel_index != 0) || !rfm22_isCoordinator(radio_dev))) { - return RADIO_EVENT_RX_MODE; - } - - // Increment the packet sequence number. - radio_dev->stats.tx_seq++; - - // Add the error correcting code. - if (!radio_dev->ppm_only_mode) { - if (len != 0) { - encode_data((unsigned char *)p, len, (unsigned char *)p); - } - len += RS_ECC_NPARITY; - } - - // Transmit the packet. - PIOS_RFM22B_TransmitPacket((uint32_t)radio_dev, p, len); - - return RADIO_EVENT_NUM_EVENTS; -} - -/** - * Transmit packet data. - * - * @param[in] rfm22b_dev The device structure - * @return enum pios_radio_event The next event to inject - */ -static enum pios_radio_event radio_txData(struct pios_rfm22b_dev *radio_dev) -{ - enum pios_radio_event ret_event = RADIO_EVENT_NUM_EVENTS; - pios_rfm22b_int_result res = PIOS_RFM22B_ProcessTx((uint32_t)radio_dev); - - // Is the transmition complete - if (res == PIOS_RFM22B_TX_COMPLETE) { - radio_dev->tx_complete_ticks = xTaskGetTickCount(); - - // Is this an ACK? - ret_event = RADIO_EVENT_RX_MODE; - radio_dev->tx_packet_handle = 0; - radio_dev->tx_data_wr = radio_dev->tx_data_rd = 0; - // Start a new transaction - radio_dev->packet_start_ticks = 0; - -#ifdef PIOS_RFM22B_DEBUG_ON_TELEM - D1_LED_OFF; -#endif - } - - return ret_event; -} - -/** - * Switch the radio into receive mode. - * - * @param[in] rfm22b_dev The device structure - * @return enum pios_radio_event The next event to inject - */ -static enum pios_radio_event radio_setRxMode(struct pios_rfm22b_dev *rfm22b_dev) -{ - if (!PIOS_RFM22B_ReceivePacket((uint32_t)rfm22b_dev, rfm22b_dev->rx_packet)) { - return RADIO_EVENT_NUM_EVENTS; - } - rfm22b_dev->packet_start_ticks = 0; - - // No event generated - return RADIO_EVENT_NUM_EVENTS; -} - -/** - * Complete the receipt of a packet. - * - * @param[in] radio_dev The device structure - * @param[in] p The packet handle of the received packet. - * @param[in] rc_len The number of bytes received. - * @return enum pios_radio_event The next event to inject - */ -static enum pios_radio_event radio_receivePacket(struct pios_rfm22b_dev *radio_dev, uint8_t *p, uint16_t rx_len) -{ - bool good_packet = true; - bool corrected_packet = false; - uint8_t data_len = rx_len; - - // We don't rsencode ppm only packets. - if (!radio_dev->ppm_only_mode) { - data_len -= RS_ECC_NPARITY; - - // Attempt to correct any errors in the packet. - if (data_len > 0) { - decode_data((unsigned char *)p, rx_len); - good_packet = check_syndrome() == 0; - - // We have an error. Try to correct it. - if (!good_packet && (correct_errors_erasures((unsigned char *)p, rx_len, 0, 0) != 0)) { - // We corrected it - corrected_packet = true; - } - } - } - - // Should we pull PPM data off of the head of the packet? - if ((good_packet || corrected_packet) && radio_dev->ppm_recv_mode) { - uint8_t ppm_len = RFM22B_PPM_NUM_CHANNELS + (radio_dev->ppm_only_mode ? 2 : 1); - - // Ensure the packet it long enough - if (data_len < ppm_len) { - good_packet = false; - } - - // Verify the CRC if this is a PPM only packet. - if ((good_packet || corrected_packet) && radio_dev->ppm_only_mode) { - uint8_t crc = 0; - for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS + 1; ++i) { - crc = PIOS_CRC_updateByte(crc, p[i]); - } - if (p[RFM22B_PPM_NUM_CHANNELS + 1] != crc) { - good_packet = false; - corrected_packet = false; - } - } - - if (good_packet || corrected_packet) { - for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS; ++i) { - // Is this a valid channel? - if (p[0] & (1 << i)) { - uint32_t val = p[i + 1]; - radio_dev->ppm[i] = (uint16_t)(1000 + val * 900 / 256); - } else { - radio_dev->ppm[i] = PIOS_RCVR_INVALID; - } - } - - p += RFM22B_PPM_NUM_CHANNELS + 1; - data_len -= RFM22B_PPM_NUM_CHANNELS + 1; - - // Call the PPM received callback if it's available. - if (radio_dev->ppm_callback) { - radio_dev->ppm_callback(radio_dev->ppm); - } - } - } - - // Set the packet status - if (good_packet) { - rfm22b_add_rx_status(radio_dev, RADIO_GOOD_RX_PACKET); - } else if (corrected_packet) { - // We corrected the error. - rfm22b_add_rx_status(radio_dev, RADIO_CORRECTED_RX_PACKET); - } else { - // We couldn't correct the error, so drop the packet. - rfm22b_add_rx_status(radio_dev, RADIO_ERROR_RX_PACKET); - } - - enum pios_radio_event ret_event = RADIO_EVENT_RX_COMPLETE; - if (good_packet || corrected_packet) { - // Send the data to the com port - bool rx_need_yield; - if (radio_dev->rx_in_cb && (data_len > 0) && !radio_dev->ppm_only_mode) { - (radio_dev->rx_in_cb)(radio_dev->rx_in_context, p, data_len, NULL, &rx_need_yield); - } - - // We only synchronize the clock on packets from our coordinator on the sync channel. - if (!rfm22_isCoordinator(radio_dev) && (radio_dev->rx_destination_id == rfm22_destinationID(radio_dev)) && (radio_dev->channel_index == 0)) { - rfm22_synchronizeClock(radio_dev); - radio_dev->stats.link_state = OPLINKSTATUS_LINKSTATE_CONNECTED; - radio_dev->on_sync_channel = false; - } - } else { - ret_event = RADIO_EVENT_RX_COMPLETE; - } - - return ret_event; -} - -/** - * Receive the packet data. - * - * @param[in] rfm22b_dev The device structure - * @return enum pios_radio_event The next event to inject - */ -static enum pios_radio_event radio_rxData(struct pios_rfm22b_dev *radio_dev) -{ - enum pios_radio_event ret_event = RADIO_EVENT_NUM_EVENTS; - pios_rfm22b_int_result res = PIOS_RFM22B_ProcessRx((uint32_t)radio_dev); - - switch (res) { - case PIOS_RFM22B_RX_COMPLETE: - - // Receive the packet. - ret_event = radio_receivePacket(radio_dev, radio_dev->rx_packet_handle, radio_dev->rx_buffer_wr); - radio_dev->rx_buffer_wr = 0; -#ifdef PIOS_RFM22B_DEBUG_ON_TELEM - D2_LED_OFF; + DEBUG_PRINTF ( + 2, + "rf device version: INCORRECT\n\r"); #endif - // Start a new transaction - radio_dev->packet_start_ticks = 0; - break; + /* + * incorrect + * RF + * module + * version */ + return RADIO_EVENT_FATAL_ERROR; + } - case PIOS_RFM22B_INT_FAILURE: + /* + * calibrate + * our + * RF + * module + * to + * be + * exactly + * on + * frequency + * .. + * different + * for + * every + * module */ + rfm22_write ( rfm22b_dev, RFM22_xtal_osc_load_cap,OSC_LOAD_CAP); - ret_event = RADIO_EVENT_RX_MODE; - break; + /* + * disable + * Low + * Duty + * Cycle + * Mode */ + rfm22_write ( rfm22b_dev, RFM22_op_and_func_ctrl2,0x00); - default: - // do nothing. - break; - } + /* + * 1MHz + * clock + * output */ + rfm22_write ( rfm22b_dev, RFM22_cpu_output_clk, RFM22_coc_1MHz); - return ret_event; -} + /* + * READY + * mode */ + rfm22_write ( rfm22b_dev, RFM22_op_and_func_ctrl1,RFM22_opfc1_xton); -/***************************************************************************** -* Link Statistics Functions -*****************************************************************************/ + /* + * choose + * the + * 3 + * GPIO + * pin + * functions + * GPIO + * port + * use + * default + * value + + */ + rfm22_write ( rfm22b_dev, RFM22_io_port_config, RFM22_io_port_default); + if (rfm22b_dev->cfg.gpio_direction == GPIO0_TX_GPIO1_RX){ + /* + * GPIO0 + * = + * TX + * State + * (to + * control + * RF + * Switch) */ + rfm22_write ( rfm22b_dev, RFM22_gpio0_config, RFM22_gpio0_config_drv3 | RFM22_gpio0_config_txstate); + /* + * GPIO1 + * = + * RX + * State + * (to + * control + * RF + * Switch) */ + rfm22_write ( rfm22b_dev, RFM22_gpio1_config, RFM22_gpio1_config_drv3 | RFM22_gpio1_config_rxstate); + } + else { + /* + * GPIO0 + * = + * TX + * State + * (to + * control + * RF + * Switch) */ + rfm22_write ( rfm22b_dev, RFM22_gpio0_config, RFM22_gpio0_config_drv3 | RFM22_gpio0_config_rxstate); + /* + * GPIO1 + * = + * RX + * State + * (to + * control + * RF + * Switch) */ + rfm22_write ( rfm22b_dev, RFM22_gpio1_config, RFM22_gpio1_config_drv3 | RFM22_gpio1_config_txstate); + } -/** - * Update the modem pair status. - * - * @param[in] rfm22b_dev The device structure - */ -static void rfm22_updatePairStatus(struct pios_rfm22b_dev *radio_dev) -{ - int8_t rssi = radio_dev->rssi_dBm; - int8_t afc = radio_dev->afc_correction_Hz; - uint32_t id = radio_dev->rx_destination_id; + /* + * GPIO2 + * = + * Clear + * Channel + * Assessment */ + rfm22_write (rfm22b_dev,RFM22_gpio2_config,RFM22_gpio2_config_drv3 | RFM22_gpio2_config_cca); - // Have we seen this device recently? - bool found = false; - uint8_t id_idx = 0; - for (; id_idx < OPLINKSTATUS_PAIRIDS_NUMELEM; ++id_idx) { - if (radio_dev->pair_stats[id_idx].pairID == id) { - found = true; - break; - } - } - // If we have seen it, update the RSSI and reset the last contact counter - if (found) { - radio_dev->pair_stats[id_idx].rssi = rssi; - radio_dev->pair_stats[id_idx].afc_correction = afc; - radio_dev->pair_stats[id_idx].lastContact = 0; - } else { - // If we haven't seen it, find a slot to put it in. - uint8_t min_idx = 0; - int8_t min_rssi = radio_dev->pair_stats[0].rssi; - for (id_idx = 1; id_idx < OPLINKSTATUS_PAIRIDS_NUMELEM; ++id_idx) { - if (radio_dev->pair_stats[id_idx].rssi < min_rssi) { - min_rssi = radio_dev->pair_stats[id_idx].rssi; - min_idx = id_idx; - } - } - radio_dev->pair_stats[min_idx].pairID = id; - radio_dev->pair_stats[min_idx].rssi = rssi; - radio_dev->pair_stats[min_idx].afc_correction = afc; - radio_dev->pair_stats[min_idx].lastContact = 0; - } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * FIFO + * mode, + * GFSK + * modulation */ + uint8_t fd_bit = rfm22_read(rfm22b_dev, RFM22_modulation_mode_control2) & RFM22_mmc2_fd; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rfm22_write (rfm22b_dev,RFM22_modulation_mode_control2,RFM22_mmc2_trclk_clk_none| RFM22_mmc2_dtmod_fifo | fd_bit | RFM22_mmc2_modtyp_gfsk); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * setup + * to + * read + * the + * internal + * temperature + * sensor */ + + /* + * ADC + * used + * to + * sample + * the + * temperature + * sensor */ + uint8_t adc_config = RFM22_ac_adcsel_temp_sensor | RFM22_ac_adcref_bg; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rfm22_write ( rfm22b_dev, RFM22_adc_config, adc_config); + + /* + * adc + * offset */ + rfm22_write ( rfm22b_dev, RFM22_adc_sensor_amp_offset, 0); + + /* + * temp + * sensor + * calibration + * .. + * �40C + * to + * +64C + * 0.5C + * resolution */ + rfm22_write ( rfm22b_dev, RFM22_temp_sensor_calib, RFM22_tsc_tsrange0 | RFM22_tsc_entsoffs); + + /* + * temp + * sensor + * offset */ + rfm22_write ( rfm22b_dev, RFM22_temp_value_offset, 0); + + /* + * start + * an + * ADC + * conversion */ + rfm22_write ( rfm22b_dev, RFM22_adc_config, adc_config | RFM22_ac_adcstartbusy); + + /* + * set + * the + * RSSI + * threshold + * interrupt + * to + * about + * -90dBm */ + rfm22_write ( rfm22b_dev, RFM22_rssi_threshold_clear_chan_indicator,(-90 + 122) * 2); + + /* + * enable + * the + * internal + * Tx + * & + * Rx + * packet + * handlers + * (without + * CRC) */ + rfm22_write ( rfm22b_dev, RFM22_data_access_control, RFM22_dac_enpacrx | RFM22_dac_enpactx); + + /* + * x-nibbles + * tx + * preamble */ + rfm22_write ( rfm22b_dev, RFM22_preamble_length, TX_PREAMBLE_NIBBLES); + /* + * x-nibbles + * rx + * preamble + * detection */ + rfm22_write ( rfm22b_dev, RFM22_preamble_detection_ctrl1, RX_PREAMBLE_NIBBLES<< 3); + + /* + * header + * control + * - + * using + * a + * 4 + * by + * header + * with + * broadcast + * of + * 0xffffffff */ + rfm22_write ( rfm22b_dev, RFM22_header_control1, + RFM22_header_cntl1_bcen_0 | + RFM22_header_cntl1_bcen_1 | + RFM22_header_cntl1_bcen_2 | + RFM22_header_cntl1_bcen_3 | + RFM22_header_cntl1_hdch_0 | + RFM22_header_cntl1_hdch_1 | + RFM22_header_cntl1_hdch_2 | + RFM22_header_cntl1_hdch_3); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * Check + * all + * bit + * of + * all + * bytes + * of + * the + * header, + * unless + * we're + * an + * unbound + * modem. */ + uint8_t header_mask = (rfm22_destinationID(rfm22b_dev) == 0xffffffff) ? 0 : 0xff; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rfm22_write ( rfm22b_dev, RFM22_header_enable0, header_mask); + rfm22_write ( rfm22b_dev, RFM22_header_enable1, header_mask); + rfm22_write ( rfm22b_dev, RFM22_header_enable2, header_mask); + rfm22_write ( rfm22b_dev, RFM22_header_enable3, header_mask); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * The + * destination + * ID + * and + * receive + * ID + * should + * be + * the + * same. */ + uint32_t id = rfm22_destinationID(rfm22b_dev); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rfm22_write ( rfm22b_dev, RFM22_check_header0,id & 0xff); + rfm22_write ( rfm22b_dev, RFM22_check_header1,(id >> 8) & 0xff); + rfm22_write ( rfm22b_dev, RFM22_check_header2,(id >> 16) & 0xff); + rfm22_write ( rfm22b_dev, RFM22_check_header3,(id >> 24) & 0xff); + /* + * 4 + * header + * bytes, + * synchronization + * word + * length + * 3, + * 2, + * 1 + * & + * 0 + * used, + * packet + * length + * included + * in + * header. */ + rfm22_write ( rfm22b_dev, RFM22_header_control2, + RFM22_header_cntl2_hdlen_3210 | + RFM22_header_cntl2_synclen_3210 | + ((TX_PREAMBLE_NIBBLES >> 8) & 0x01)); + + /* + * sync + * word */ + rfm22_write ( rfm22b_dev, RFM22_sync_word3, SYNC_BYTE_1); + rfm22_write ( rfm22b_dev, RFM22_sync_word2, SYNC_BYTE_2); + rfm22_write ( rfm22b_dev, RFM22_sync_word1, SYNC_BYTE_3); + rfm22_write ( rfm22b_dev, RFM22_sync_word0, SYNC_BYTE_4); + + /* + * TX + * FIFO + * Almost + * Full + * Threshold + * (0 + * - + * 63) */ + rfm22_write ( rfm22b_dev, RFM22_tx_fifo_control1, TX_FIFO_HI_WATERMARK); + + /* + * TX + * FIFO + * Almost + * Empty + * Threshold + * (0 + * - + * 63) */ + rfm22_write ( rfm22b_dev, RFM22_tx_fifo_control2, TX_FIFO_LO_WATERMARK); + + /* + * RX + * FIFO + * Almost + * Full + * Threshold + * (0 + * - + * 63) */ + rfm22_write ( rfm22b_dev, RFM22_rx_fifo_control, RX_FIFO_HI_WATERMARK); + + /* + * Set + * the + * frequency + * calibration */ + rfm22_write ( rfm22b_dev, RFM22_xtal_osc_load_cap,rfm22b_dev->cfg.RFXtalCap); + + /* + * Release + * the + * bus */ + rfm22_releaseBus (rfm22b_dev); + + /* + * Initialize + * the + * frequency + * and + * datarate + * to + * te + * default. */ + rfm22_setNominalCarrierFrequency (rfm22b_dev,0); + pios_rfm22_setDatarate (rfm22b_dev); + + return RADIO_EVENT_INITIALIZED; } /** - * Calculate the link quality from the packet receipt, tranmittion statistics. - * - * @param[in] rfm22b_dev The device structure - */ -static void rfm22_calculateLinkQuality(struct pios_rfm22b_dev *rfm22b_dev) -{ - // Add the RX packet statistics - rfm22b_dev->stats.rx_good = 0; - rfm22b_dev->stats.rx_corrected = 0; - rfm22b_dev->stats.rx_error = 0; - rfm22b_dev->stats.tx_resent = 0; - for (uint8_t i = 0; i < RFM22B_RX_PACKET_STATS_LEN; ++i) { - uint32_t val = rfm22b_dev->rx_packet_stats[i]; - for (uint8_t j = 0; j < 16; ++j) { - switch ((val >> (j * 2)) & 0x3) { - case RADIO_GOOD_RX_PACKET: - rfm22b_dev->stats.rx_good++; - break; - case RADIO_CORRECTED_RX_PACKET: - rfm22b_dev->stats.rx_corrected++; - break; - case RADIO_ERROR_RX_PACKET: - rfm22b_dev->stats.rx_error++; - break; - case RADIO_RESENT_TX_PACKET: - rfm22b_dev->stats.tx_resent++; - break; - } - } - } + * + * Set + * the + * air + * datarate + * for + * the + * RFM22B + * device. + * + * + * Carson's + * rule: + * + * + * The + * signal + * bandwidth + * is + * about + * 2(Delta-f + * + + * fm) + * .. + * + * + * Delta-f + * = + * frequency + * deviation + * + * fm + * = + * maximum + * frequency + * of + * the + * signal + * + * + * @param[in] + * rfm33b_dev + * + * The + * device + * structure + * pointer. + * + * @param[in] + * datarate + * + * The + * air + * datarate. + * + * @param[in] + * data_whitening + * + * Is + * data + * whitening + * desired? + */ +static void pios_rfm22_setDatarate + (struct pios_rfm22b_dev* rfm22b_dev){ + enum rfm22b_datarate datarate = rfm22b_dev->datarate; + bool data_whitening = true; - // Calculate the link quality metric, which is related to the number of good packets in relation to the number of bad packets. - // Note: This assumes that the number of packets sampled for the stats is 64. - // Using this equation, error and resent packets are counted as -2, and corrected packets are counted as -1. - // The range is 0 (all error or resent packets) to 128 (all good packets). - rfm22b_dev->stats.link_quality = 64 + rfm22b_dev->stats.rx_good - rfm22b_dev->stats.rx_error - rfm22b_dev->stats.tx_resent; + /* + * Claim + * the + * SPI + * bus. */ + rfm22_claimBus (rfm22b_dev); + + /* + * rfm22_if_filter_bandwidth */ + rfm22_write ( rfm22b_dev, 0x1C, reg_1C[datarate]); + + /* + * rfm22_afc_loop_gearshift_override */ + rfm22_write ( rfm22b_dev, 0x1D, reg_1D[datarate]); + /* + * RFM22_afc_timing_control */ + rfm22_write ( rfm22b_dev, 0x1E, reg_1E[datarate]); + + /* + * RFM22_clk_recovery_gearshift_override */ + rfm22_write ( rfm22b_dev, 0x1F, reg_1F[datarate]); + /* + * rfm22_clk_recovery_oversampling_ratio */ + rfm22_write ( rfm22b_dev, 0x20, reg_20[datarate]); + /* + * rfm22_clk_recovery_offset2 */ + rfm22_write ( rfm22b_dev, 0x21, reg_21[datarate]); + /* + * rfm22_clk_recovery_offset1 */ + rfm22_write ( rfm22b_dev, 0x22, reg_22[datarate]); + /* + * rfm22_clk_recovery_offset0 */ + rfm22_write ( rfm22b_dev, 0x23, reg_23[datarate]); + /* + * rfm22_clk_recovery_timing_loop_gain1 */ + rfm22_write ( rfm22b_dev, 0x24, reg_24[datarate]); + /* + * rfm22_clk_recovery_timing_loop_gain0 */ + rfm22_write ( rfm22b_dev, 0x25, reg_25[datarate]); + /* + * rfm22_agc_override1 */ + rfm22_write ( rfm22b_dev, RFM22_agc_override1,reg_69[datarate]); + + /* + * rfm22_afc_limiter */ + rfm22_write ( rfm22b_dev, 0x2A, reg_2A[datarate]); + + /* + * rfm22_tx_data_rate1 */ + rfm22_write ( rfm22b_dev, 0x6E, reg_6E[datarate]); + /* + * rfm22_tx_data_rate0 */ + rfm22_write ( rfm22b_dev, 0x6F, reg_6F[datarate]); + if (!data_whitening){ + /* + * rfm22_modulation_mode_control1 */ + rfm22_write ( rfm22b_dev, 0x70, reg_70[datarate] & ~RFM22_mmc1_enwhite); + } + else { + /* + * rfm22_modulation_mode_control1 */ + rfm22_write (rfm22b_dev,0x70,reg_70[datarate] | RFM22_mmc1_enwhite); + } + + /* + * rfm22_modulation_mode_control2 */ + rfm22_write ( rfm22b_dev, 0x71, reg_71[datarate]); + + /* + * rfm22_frequency_deviation */ + rfm22_write ( rfm22b_dev, 0x72, reg_72[datarate]); + + /* + * rfm22_cpcuu */ + rfm22_write ( rfm22b_dev, 0x58, reg_58[datarate]); + + rfm22_write ( rfm22b_dev, RFM22_ook_counter_value1, 0x00); + rfm22_write ( rfm22b_dev, RFM22_ook_counter_value2, 0x00); + + /* + * Release + * the + * bus */ + rfm22_releaseBus (rfm22b_dev); } /** - * Add a status value to the RX packet status array. - * - * @param[in] rfm22b_dev The device structure - * @param[in] status The packet status value - */ -static void rfm22b_add_rx_status(struct pios_rfm22b_dev *rfm22b_dev, enum pios_rfm22b_rx_packet_status status) -{ - // Shift the status registers - for (uint8_t i = RFM22B_RX_PACKET_STATS_LEN - 1; i > 0; --i) { - rfm22b_dev->rx_packet_stats[i] = (rfm22b_dev->rx_packet_stats[i] << 2) | (rfm22b_dev->rx_packet_stats[i - 1] >> 30); - } - rfm22b_dev->rx_packet_stats[0] = (rfm22b_dev->rx_packet_stats[0] << 2) | status; + * + * Set + * the + * nominal + * carrier + * frequency, + * channel + * step + * size, + * and + * initial + * channel + * + * + * @param[in] + * rfm33b_dev + * + * The + * device + * structure + * pointer. + * + * @param[in] + * init_chan + * + * The + * initial + * channel + * to + * tune + * to. + */ +static void rfm22_setNominalCarrierFrequency +( + struct + pios_rfm22b_dev + * + rfm22b_dev, + uint8_t + init_chan +){ + /* + * Set + * the + * frequency + * channels + * to + * start + * at + * 430MHz */ + uint32_t frequency_hz = RFM22B_NOMINAL_CARRIER_FREQUENCY; + /* + * The + * step + * size + * is + * 10MHz + * / + * 250 + * channels + * = + * 40khz, + * and + * the + * step + * size + * is + * specified + * in + * 10khz + * increments. */ + uint8_t freq_hop_step_size = 4; + + /* + * holds + * the + * hbsel + * (1 + * or + * 2) */ + uint8_t hbsel; + + if (frequency_hz < 480000000){ + hbsel = 0; + } + else { + hbsel = 1; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + float freq_mhz = (float)(frequency_hz) / 1000000.0f; + float xtal_freq_khz = 30000.0f; + float sfreq = freq_mhz / (10.0f * (xtal_freq_khz / 30000.0f) * (1 + hbsel)); + uint32_t fb = (uint32_t)sfreq - 24 + (64 + 32 * hbsel); + uint32_t fc = (uint32_t)((sfreq - (uint32_t)sfreq) * 64000.0f); + uint8_t fch = (fc >> 8) & 0xff; + uint8_t fcl = fc & 0xff; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * Claim + * the + * SPI + * bus. */ + rfm22_claimBus (rfm22b_dev); + + /* + * Setthe + * frequency + * hopping + * step + * size. */ + rfm22_write (rfm22b_dev,RFM22_frequency_hopping_step_size,freq_hop_step_size); + + /* + * frequency + * hopping + * channel + * (0-255) */ + rfm22b_dev->frequency_step_size = 156.25f * hbsel; + + /* + * frequency + * hopping + * channel + * (0-255) */ + rfm22b_dev->channel = init_chan; + rfm22_write ( rfm22b_dev, RFM22_frequency_hopping_channel_select, init_chan); + + /* + * no + * frequency + * offset */ + rfm22_write ( rfm22b_dev, RFM22_frequency_offset1, 0); + rfm22_write ( rfm22b_dev, RFM22_frequency_offset2, 0); + + /* + * set + * the + * carrier + * frequency */ + rfm22_write ( rfm22b_dev, RFM22_frequency_band_select, fb & 0xff); + rfm22_write ( rfm22b_dev, RFM22_nominal_carrier_frequency1, fch); + rfm22_write ( rfm22b_dev, RFM22_nominal_carrier_frequency0, fcl); + + /* + * Release + * the + * bus */ + rfm22_releaseBus (rfm22b_dev); } -/***************************************************************************** -* Connection Handling Functions -*****************************************************************************/ - /** - * Are we a coordinator modem? - * - * @param[in] rfm22b_dev The device structure - */ -static bool rfm22_isCoordinator(struct pios_rfm22b_dev *rfm22b_dev) -{ - return rfm22b_dev->coordinator; -} + * + * Set + * the + * frequency + * hopping + * channel. + * + * + * @param[in] + * rfm33b_dev + * + * The + * device + * structure + * pointer. + */ +static bool rfm22_setFreqHopChannel +( + struct + pios_rfm22b_dev + * + rfm22b_dev, + uint8_t + channel +){ + /* + * set + * the + * frequency + * hopping + * channel */ + if (rfm22b_dev->channel == channel){ + return false; + } -/** - * Returns the destination ID to send packets to. - * - * @param[in] rfm22b_id The RFM22B device index. - * @return The destination ID - */ -uint32_t rfm22_destinationID(struct pios_rfm22b_dev *rfm22b_dev) -{ - if (rfm22_isCoordinator(rfm22b_dev)) { - return rfm22b_dev->deviceID; - } else if (rfm22b_dev->coordinatorID) { - return rfm22b_dev->coordinatorID; - } else { - return 0xffffffff; - } -} - - -/***************************************************************************** -* Frequency Hopping Functions -*****************************************************************************/ - -/** - * Synchronize the clock after a packet receive from our coordinator on the syncronization channel. - * This function should be called when a packet is received on the synchronization channel. - * - * @param[in] rfm22b_dev The device structure - */ -static void rfm22_synchronizeClock(struct pios_rfm22b_dev *rfm22b_dev) -{ - portTickType start_time = rfm22b_dev->packet_start_ticks; - - // This packet was transmitted on channel 0, calculate the time delta that will force us to transmit on channel 0 at the time this packet started. - uint8_t num_chan = num_channels[rfm22b_dev->datarate]; - uint16_t frequency_hop_cycle_time = rfm22b_dev->packet_time * num_chan; - uint16_t time_delta = start_time % frequency_hop_cycle_time; - - // Calculate the adjustment for the preamble - uint8_t offset = (uint8_t)ceil(35000.0F / data_rate[rfm22b_dev->datarate]); - - rfm22b_dev->time_delta = frequency_hop_cycle_time - time_delta + offset; -} - -/** - * Return the extimated current clock ticks count on the coordinator modem. - * This is the master clock used for all synchronization. - * - * @param[in] rfm22b_dev The device structure - */ -static portTickType rfm22_coordinatorTime(struct pios_rfm22b_dev *rfm22b_dev, portTickType ticks) -{ - if (rfm22_isCoordinator(rfm22b_dev)) { - return ticks; - } - return ticks + rfm22b_dev->time_delta; -} - -/** - * Return true if this modem is in the send interval, which allows the modem to initiate a transmit. - * - * @param[in] rfm22b_dev The device structure - */ -static bool rfm22_timeToSend(struct pios_rfm22b_dev *rfm22b_dev) -{ - portTickType time = rfm22_coordinatorTime(rfm22b_dev, xTaskGetTickCount()); - bool is_coordinator = rfm22_isCoordinator(rfm22b_dev); - - // If this is a one-way link, only the coordinator can send. - uint8_t packet_period = rfm22b_dev->packet_time; - - if (rfm22b_dev->one_way_link) { - if (is_coordinator) { - return ((time - 1) % (packet_period)) == 0; - } else { - return false; - } - } - - if (!is_coordinator) { - time += packet_period - 1; - } else { - time -= 1; - } - return (time % (packet_period * 2)) == 0; -} - -/** - * Calculate the nth channel index. - * - * @param[in] rfm22b_dev The device structure - * @param[in] index The channel index to calculate - */ -static uint8_t rfm22_calcChannel(struct pios_rfm22b_dev *rfm22b_dev, uint8_t index) -{ - // Make sure we don't index outside of the range. - uint8_t num_chan = num_channels[rfm22b_dev->datarate]; - uint8_t idx = index % num_chan; - - // Are we switching to a new channel? - if (idx != rfm22b_dev->channel_index) { - // If the on_sync_channel flag is set, it means that we were on the sync channel, but no packet was received, so transition to a non-connected state. - if (!rfm22_isCoordinator(rfm22b_dev) && (rfm22b_dev->channel_index == 0) && rfm22b_dev->on_sync_channel) { - rfm22b_dev->on_sync_channel = false; - - // Set the link state to disconnected. - if (rfm22b_dev->stats.link_state == OPLINKSTATUS_LINKSTATE_CONNECTED) { - rfm22b_dev->stats.link_state = OPLINKSTATUS_LINKSTATE_DISCONNECTED; - // Set the PPM outputs to INVALID - for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS; ++i) { - rfm22b_dev->ppm[i] = PIOS_RCVR_INVALID; - } - } - - // Stay on the sync channel. - idx = 0; - } else if (idx == 0) { - // If we're switching to the sync channel, set a flag that can be used to detect if a packet was received. - rfm22b_dev->on_sync_channel = true; - } - - rfm22b_dev->channel_index = idx; - } - - return rfm22b_dev->channels[idx]; -} - -/** - * Calculate what the current channel shold be. - * - * @param[in] rfm22b_dev The device structure - */ -static uint8_t rfm22_calcChannelFromClock(struct pios_rfm22b_dev *rfm22b_dev) -{ - portTickType time = rfm22_coordinatorTime(rfm22b_dev, xTaskGetTickCount()); - // Divide time into 8ms blocks. Coordinator sends in first 2 ms, and remote send in 5th and 6th ms. - // Channel changes occur in the last 2 ms. - uint8_t num_chan = num_channels[rfm22b_dev->datarate]; - uint8_t n = (time / rfm22b_dev->packet_time) % num_chan; - - return rfm22_calcChannel(rfm22b_dev, n); -} - -/** - * Change channels to the calculated current channel. - * - * @param[in] rfm22b_dev The device structure - */ -static bool rfm22_changeChannel(struct pios_rfm22b_dev *rfm22b_dev) -{ - // A disconnected non-coordinator modem should sit on the sync channel until connected. - if (!rfm22_isCoordinator(rfm22b_dev) && !rfm22_isConnected(rfm22b_dev)) { - return rfm22_setFreqHopChannel(rfm22b_dev, rfm22_calcChannel(rfm22b_dev, 0)); - } else { - return rfm22_setFreqHopChannel(rfm22b_dev, rfm22_calcChannelFromClock(rfm22b_dev)); - } -} - - -/***************************************************************************** -* Error Handling Functions -*****************************************************************************/ - -/** - * Recover from a transmit failure. - * - * @param[in] rfm22b_dev The device structure - * @return enum pios_radio_event The next event to inject - */ -static enum pios_radio_event rfm22_txFailure(struct pios_rfm22b_dev *rfm22b_dev) -{ - rfm22b_dev->stats.tx_failure++; - rfm22b_dev->packet_start_ticks = 0; - rfm22b_dev->tx_data_wr = rfm22b_dev->tx_data_rd = 0; - return RADIO_EVENT_TX_START; -} - -/** - * Recover from a timeout event. - * - * @param[in] rfm22b_dev The device structure - * @return enum pios_radio_event The next event to inject - */ -static enum pios_radio_event rfm22_timeout(struct pios_rfm22b_dev *rfm22b_dev) -{ - rfm22b_dev->stats.timeouts++; - rfm22b_dev->packet_start_ticks = 0; - // Release the Tx packet if it's set. - if (rfm22b_dev->tx_packet_handle != 0) { - rfm22b_dev->tx_data_rd = rfm22b_dev->tx_data_wr = 0; - } - rfm22b_dev->rfm22b_state = RFM22B_STATE_TRANSITION; - rfm22b_dev->rx_buffer_wr = 0; - TX_LED_OFF; - RX_LED_OFF; #ifdef PIOS_RFM22B_DEBUG_ON_TELEM - D1_LED_OFF; - D2_LED_OFF; - D3_LED_OFF; - D4_LED_OFF; -#endif - return RADIO_EVENT_RX_MODE; + D3_LED_TOGGLE; +#endif /* + * PIOS_RFM22B_DEBUG_ON_TELEM */ + rfm22b_dev->channel = channel; + rfm22_write_claim (rfm22b_dev,RFM22_frequency_hopping_channel_select,channel); + + return true; } /** - * Recover from a severe error. - * - * @param[in] rfm22b_dev The device structure - * @return enum pios_radio_event The next event to inject - */ -static enum pios_radio_event rfm22_error(struct pios_rfm22b_dev *rfm22b_dev) -{ - rfm22b_dev->stats.resets++; - rfm22_clearLEDs(); - return RADIO_EVENT_INITIALIZE; + * + * Read + * the + * RFM22B + * interrupt + * and + * device + * status + * registers + * + * + * @param[in] + * rfm22b_dev + * + * The + * device + * structure + */ +static bool pios_rfm22_readStatus + (struct pios_rfm22b_dev* rfm22b_dev){ + /* + * 1. + * Read + * the + * interrupt + * statuses + * with + * burst + * read */ + rfm22_claimBus (rfm22b_dev); /* + * Set + * RC + * and + * the + * semaphore */ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + uint8_t write_buf[3] = { RFM22_interrupt_status1 &0x7f, 0xFF, 0xFF }; + uint8_t read_buf[3]; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + rfm22_assertCs (rfm22b_dev); + PIOS_SPI_TransferBlock (rfm22b_dev->spi_id,write_buf,read_buf,sizeof(write_buf),NULL); + rfm22_deassertCs (rfm22b_dev); + rfm22b_dev->status_regs.int_status_1.raw = read_buf[1]; + rfm22b_dev->status_regs.int_status_2.raw = read_buf[2]; + + /* + * Device + * status */ + rfm22b_dev->status_regs.device_status.raw = rfm22_read(rfm22b_dev, RFM22_device_status); + + /* + * EzMAC + * status */ + rfm22b_dev->status_regs.ezmac_status.raw = rfm22_read(rfm22b_dev, RFM22_ezmac_status); + + /* + * Release + * the + * bus */ + rfm22_releaseBus (rfm22b_dev); + /* + * the + * RF + * module + * has + * gone + * and + * done + * a + * reset + * - + * we + * need + * to + * re-initialize + * the + * rf + * module */ + if (rfm22b_dev->status_regs.int_status_2.poweron_reset){ + return false; + } + + return true; } /** - * A fatal error has occured in the state machine. - * this should not happen. - * - * @parem [in] rfm22b_dev The device structure - * @return enum pios_radio_event The next event to inject - */ -static enum pios_radio_event rfm22_fatal_error(__attribute__((unused)) struct pios_rfm22b_dev *rfm22b_dev) -{ - // RF module error .. flash the LED's - rfm22_clearLEDs(); - for (unsigned int j = 0; j < 16; j++) { - USB_LED_ON; - LINK_LED_ON; - RX_LED_OFF; - TX_LED_OFF; - - PIOS_DELAY_WaitmS(200); - - USB_LED_OFF; - LINK_LED_OFF; - RX_LED_ON; - TX_LED_ON; - - PIOS_DELAY_WaitmS(200); - } - - PIOS_DELAY_WaitmS(1000); - - PIOS_Assert(0); - - return RADIO_EVENT_FATAL_ERROR; + * + * Recover + * from + * a + * failure + * in + * receiving + * a + * packet. + * + * + * @param[in] + * rfm22b_dev + * + * The + * device + * structure + * + * @return + * enum + * pios_radio_event + * + * The + * next + * event + * to + * inject + */ +static void rfm22_rxFailure + (struct pios_rfm22b_dev* rfm22b_dev){ + rfm22b_dev->stats.rx_failure ++; + rfm22b_dev->rx_buffer_wr = 0; + rfm22b_dev->packet_start_ticks = 0; + rfm22b_dev->rfm22b_state = RFM22B_STATE_TRANSITION; } /***************************************************************************** -* Utility Functions -*****************************************************************************/ + * + * Radio + * Transmit + * and + * Receive + * functions. + *****************************************************************************/ /** - * Calculate the time difference between the start time and end time. - * Times are in ticks. Also handles rollover. - * - * @param[in] start_time The start time in ticks. - * @param[in] end_time The end time in ticks. - */ -static uint32_t pios_rfm22_time_difference_ms(portTickType start_time, portTickType end_time) -{ - if (end_time >= start_time) { - return (end_time - start_time) * portTICK_RATE_MS; - } - // Rollover - return ((portMAX_DELAY - start_time) + end_time) * portTICK_RATE_MS; + * + * Start + * a + * transmit + * if + * possible + * + * + * @param[in] + * radio_dev + * The + * device + * structure + * + * @return + * enum + * pios_radio_event + * + * The + * next + * event + * to + * inject + */ +static enum pios_radio_event radio_txStart + (struct pios_rfm22b_dev* radio_dev){ + uint8_t * p = radio_dev->tx_packet; + uint8_t len = 0; + uint8_t max_data_len = radio_dev->max_packet_len - (radio_dev->ppm_only_mode ? 0 : RS_ECC_NPARITY); + + /* + * Don't + * send + * if + * it's + * not + * our + * turn, + * or + * if + * we're + * receiving + * a + * packet. */ + if (!rfm22_timeToSend (radio_dev) || ! PIOS_RFM22B_InRxWait ((uint32_t)radio_dev)){ + return RADIO_EVENT_RX_MODE; + } + /* + * Don't + * send + * anything + * if + * we're + * bound + * to + * a + * coordinator + * and + * not + * yet + * connected. */ + if (!rfm22_isCoordinator (radio_dev) && ! rfm22_isConnected (radio_dev)){ + return RADIO_EVENT_RX_MODE; + } + /* + * Should + * we + * append + * PPM + * data + * to + * the + * packet? */ + if (radio_dev->ppm_send_mode){ + len = RFM22B_PPM_NUM_CHANNELS + (radio_dev->ppm_only_mode ? 2 : 1); + /* + * Ensure + * we + * can + * fit + * the + * PPM + * data + * in + * the + * packet. */ + if (max_data_len < len){ + return RADIO_EVENT_RX_MODE; + } + + /* + * The + * first + * byte + * is + * a + * bitmask + * of + * valid + * channels. */ + p[0] = 0; + + /* + * Read + * the + * PPM + * input. */ + for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS; ++i) + { + int32_t val = radio_dev->ppm[i]; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + if ((val == PIOS_RCVR_INVALID) || (val == PIOS_RCVR_TIMEOUT)){ + p[i + 1] = 0; + } + else { + p[0] |= 1<< i; + p[i + 1] = (val < 1000) ? 0 : ((val >= 1900) ? 255 : (uint8_t)(256 * (val - 1000) / 900)); + } + } + /* + * The + * last + * byte + * is + * a + * CRC. */ + if (radio_dev->ppm_only_mode){ + uint8_t crc = 0; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS + 1; ++i) + { + crc = PIOS_CRC_updateByte(crc, p[i]); + } + p[RFM22B_PPM_NUM_CHANNELS + 1] = crc; + } + } + /* + * Append + * data + * from + * the + * com + * interface + * if + * applicable. */ + if (!radio_dev->ppm_only_mode && radio_dev->tx_out_cb){ + /* + * Try + * to + * get + * some + * data + * to + * send */ + bool need_yield = false; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + len += (radio_dev->tx_out_cb)(radio_dev->tx_out_context, p + len, max_data_len - len, NULL, &need_yield); + } + /* + * Always + * send + * a + * packet + * on + * the + * sync + * channel + * if + * this + * modem + * is + * a + * coordinator. */ + if ((len == 0) && ((radio_dev->channel_index != 0) || !rfm22_isCoordinator(radio_dev))){ + return RADIO_EVENT_RX_MODE; + } + + /* + * Increment + * the + * packet + * sequence + * number. */ + radio_dev->stats.tx_seq ++; + /* + * Add + * the + * error + * correcting + * code. */ + if (!radio_dev->ppm_only_mode){ + if (len != 0){ + encode_data ((unsignedchar *)p,len,(unsigned char *)p); + } + + len += RS_ECC_NPARITY; + } + + /* + * Transmit + * the + * packet. */ + PIOS_RFM22B_TransmitPacket ((uint32_t)radio_dev,p,len); + + return RADIO_EVENT_NUM_EVENTS; } /** - * Allocate the device structure - */ + * + * Transmit + * packet + * data. + * + * + * @param[in] + * rfm22b_dev + * The + * device + * structure + * + * @return + * enum + * pios_radio_event + * + * The + * next + * event + * to + * inject + */ +static enum pios_radio_event radio_txData + (struct pios_rfm22b_dev* radio_dev){ + enum pios_radio_event ret_event = RADIO_EVENT_NUM_EVENTS; + pios_rfm22b_int_result res = PIOS_RFM22B_ProcessTx((uint32_t)radio_dev); + + /* + * Is + * the + * transmition + * complete */ + if (res == PIOS_RFM22B_TX_COMPLETE){ + radio_dev->tx_complete_ticks = xTaskGetTickCount(); + + /* + * Is + * this + * an + * ACK? */ + ret_event = RADIO_EVENT_RX_MODE; + radio_dev->tx_packet_handle = 0; + radio_dev->tx_data_wr = radio_dev->tx_data_rd = 0; + /* + * Start + * a + * new + * transaction */ + radio_dev->packet_start_ticks = 0; + +#ifdef PIOS_RFM22B_DEBUG_ON_TELEM + D1_LED_OFF; +#endif + } + + return ret_event; +} + +/** + * + * Switch + * the + * radio + * into + * receive + * mode. + * + * + * @param[in] + * rfm22b_dev + * The + * device + * structure + * + * @return + * enum + * pios_radio_event + * + * The + * next + * event + * to + * inject + */ +static enum pios_radio_event radio_setRxMode + (struct pios_rfm22b_dev* rfm22b_dev){ + if (!PIOS_RFM22B_ReceivePacket ((uint32_t)rfm22b_dev,rfm22b_dev->rx_packet)){ + return RADIO_EVENT_NUM_EVENTS; + } + + rfm22b_dev->packet_start_ticks = 0; + + /* + * No + * event + * generated */ + return RADIO_EVENT_NUM_EVENTS; +} + +/** + * + * Complete + * the + * receipt + * of + * a + * packet. + * + * + * @param[in] + * radio_dev + * + * The + * device + * structure + * + * @param[in] + * p + * + * The + * packet + * handle + * of + * the + * received + * packet. + * + * @param[in] + * rc_len + * + * The + * number + * of + * bytes + * received. + * + * @return + * enum + * pios_radio_event + * + * The + * next + * event + * to + * inject + */ +static enum pios_radio_event radio_receivePacket +( + struct + pios_rfm22b_dev + * + radio_dev, + uint8_t + * + p, + uint16_t + rx_len +){ + bool good_packet = true; + bool corrected_packet = false; + uint8_t data_len = rx_len; + + /* + * We + * don't + * rsencode + * ppm + * only + * packets. */ + if (!radio_dev->ppm_only_mode){ + data_len -= RS_ECC_NPARITY; + /* + * Attempt + * to + * correct + * any + * errors + * in + * the + * packet. */ + if (data_len > 0){ + decode_data ((unsignedchar *)p,rx_len); + good_packet = check_syndrome() == 0; + /* + * We + * have + * an + * error. + * + * Try + * to + * correct + * it. */ + if (!good_packet && (correct_errors_erasures ((unsignedchar *)p, rx_len, 0, 0) != 0)){ + /* + * We + * corrected + * it */ + corrected_packet = true; + } + } + } + /* + * Should + * we + * pull + * PPM + * data + * off + * of + * the + * head + * of + * the + * packet? */ + if ((good_packet || corrected_packet) && radio_dev->ppm_recv_mode){ + uint8_t ppm_len = RFM22B_PPM_NUM_CHANNELS + (radio_dev->ppm_only_mode ? 2 : 1); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /* + * Ensure + * the + * packet + * it + * long + * enough */ + if (data_len < ppm_len){ + good_packet = false; + } + /* + * Verify + * the + * CRC + * if + * this + * is + * a + * PPM + * only + * packet. */ + if ((good_packet || corrected_packet) && radio_dev->ppm_only_mode){ + uint8_t crc = 0; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS + 1; ++i) + { + crc = PIOS_CRC_updateByte(crc, p[i]); + } + if (p[RFM22B_PPM_NUM_CHANNELS + 1] != crc){ + good_packet = false; + corrected_packet = false; + } + } + if (good_packet || corrected_packet){ + for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS; ++i) + { + /* + * Is + * this + * a + * valid + * channel? */ + if (p[0] & (1<< i)){ + uint32_t val = p[i + 1]; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + radio_dev->ppm[i] = (uint16_t)(1000 + val * 900 / 256); + } + else { + radio_dev->ppm[i] = PIOS_RCVR_INVALID; + } + } + p += RFM22B_PPM_NUM_CHANNELS + 1; + data_len -= RFM22B_PPM_NUM_CHANNELS + 1; + /* + * Call + * the + * PPM + * received + * callback + * if + * it's + * available. */ + if (radio_dev->ppm_callback){ + radio_dev->ppm_callback (radio_dev->ppm); + } + } + } + /* + * Set + * the + * packet + * status */ + if (good_packet){ + rfm22b_add_rx_status (radio_dev,RADIO_GOOD_RX_PACKET); + } + else if (corrected_packet) + { + /* + * We + * corrected + * the + * error. */ + rfm22b_add_rx_status (radio_dev,RADIO_CORRECTED_RX_PACKET); + } + else { + /* + * We + * couldn't + * correct + * the + * error, + * so + * drop + * the + * packet. */ + rfm22b_add_rx_status (radio_dev,RADIO_ERROR_RX_PACKET); + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + enum pios_radio_event ret_event = RADIO_EVENT_RX_COMPLETE; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + if (good_packet || corrected_packet){ + /* + * Send + * the + * data + * to + * the + * com + * port */ + bool rx_need_yield; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + if (radio_dev->rx_in_cb && (data_len > 0) && !radio_dev->ppm_only_mode){ + (radio_dev->rx_in_cb)(radio_dev->rx_in_context, p, data_len, NULL, &rx_need_yield); + } + /* + * We + * only + * synchronize + * the + * clock + * on + * packets + * from + * our + * coordinator + * on + * the + * sync + * channel. */ + if (!rfm22_isCoordinator (radio_dev) && (radio_dev->rx_destination_id== rfm22_destinationID(radio_dev)) && (radio_dev->channel_index == 0)){ + rfm22_synchronizeClock (radio_dev); + radio_dev->stats.link_state = OPLINKSTATUS_LINKSTATE_CONNECTED; + radio_dev->on_sync_channel = false; + } + } + else { + ret_event = RADIO_EVENT_RX_COMPLETE; + } + + return ret_event; +} + +/** + * + * Receive + * the + * packet + * data. + * + * + * @param[in] + * rfm22b_dev + * The + * device + * structure + * + * @return + * enum + * pios_radio_event + * + * The + * next + * event + * to + * inject + */ +static enum pios_radio_event + radio_rxData + (struct pios_rfm22b_dev* radio_dev){ + enum pios_radio_event ret_event = RADIO_EVENT_NUM_EVENTS; + pios_rfm22b_int_result res = PIOS_RFM22B_ProcessRx((uint32_t)radio_dev); + + switch (res){ + case PIOS_RFM22B_RX_COMPLETE: + + /* + * Receive + * the + * packet. */ + ret_event = radio_receivePacket(radio_dev, radio_dev->rx_packet_handle, radio_dev->rx_buffer_wr); + radio_dev->rx_buffer_wr = 0; +#ifdef PIOS_RFM22B_DEBUG_ON_TELEM + D2_LED_OFF; +#endif + + /* + * Start + * a + * new + * transaction */ + radio_dev->packet_start_ticks = 0; + break; + + case PIOS_RFM22B_INT_FAILURE: + + ret_event = RADIO_EVENT_RX_MODE; + break; + + default: + /* + * do + * nothing. */ + break; + } + + return ret_event; +} + +/***************************************************************************** + * + * Link + * Statistics + * Functions + *****************************************************************************/ + +/** + * + * Update + * the + * modem + * pair + * status. + * + * + * @param[in] + * rfm22b_dev + * + * The + * device + * structure + */ +static void + rfm22_updatePairStatus + (struct pios_rfm22b_dev* radio_dev){ + int8_t rssi = radio_dev->rssi_dBm; + int8_t afc = radio_dev->afc_correction_Hz; + uint32_t id = radio_dev->rx_destination_id; + + /* + * Have + * we + * seen + * this + * device + * recently? */ + boolfound = false; + uint8_tid_idx = 0; + + for (; id_idx < OPLINKSTATUS_PAIRIDS_NUMELEM; ++id_idx) + { + if (radio_dev->pair_stats[id_idx].pairID == id){ + found = true; + break; + } + } + /* + * If + * we + * have + * seen + * it, + * update + * the + * RSSI + * and + * reset + * the + * last + * contact + * counter */ + if (found){ + radio_dev->pair_stats[id_idx].rssi = rssi; + radio_dev->pair_stats[id_idx].afc_correction = afc; + radio_dev->pair_stats[id_idx].lastContact = 0; + } + else { + /* + * If + * we + * haven't + * seen + * it, + * find + * a + * slot + * to + * put + * it + * in. */ + uint8_t min_idx = 0; + int8_t min_rssi = radio_dev->pair_stats[0].rssi; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + for (id_idx = 1; id_idx < OPLINKSTATUS_PAIRIDS_NUMELEM; ++id_idx) + { + if (radio_dev->pair_stats[id_idx].rssi < min_rssi){ + min_rssi = radio_dev->pair_stats[id_idx].rssi; + min_idx = id_idx; + } + } + radio_dev->pair_stats[min_idx].pairID = id; + radio_dev->pair_stats[min_idx].rssi = rssi; + radio_dev->pair_stats[min_idx].afc_correction = afc; + radio_dev->pair_stats[min_idx].lastContact = 0; + } +} + +/** + * + * Calculate + * the + * link + * quality + * from + * the + * packet + * receipt, + * tranmittion + * statistics. + * + * + * @param[in] + * rfm22b_dev + * + * The + * device + * structure + */ +static void + rfm22_calculateLinkQuality + (struct pios_rfm22b_dev* rfm22b_dev){ + /* + * Add + * the + * RX + * packet + * statistics */ + rfm22b_dev->stats.rx_good = 0; + rfm22b_dev->stats.rx_corrected = 0; + rfm22b_dev->stats.rx_error = 0; + rfm22b_dev->stats.tx_resent = 0; + + for (uint8_t i = 0; i < RFM22B_RX_PACKET_STATS_LEN; ++i) + { + uint32_t val = rfm22b_dev->rx_packet_stats[i]; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + for (uint8_t j = 0; j < 16; ++j) + { + switch ((val >> (j * 2)) & 0x3){ + case RADIO_GOOD_RX_PACKET: + rfm22b_dev->stats.rx_good ++; + break; + + case RADIO_CORRECTED_RX_PACKET: + rfm22b_dev->stats.rx_corrected ++; + break; + + case RADIO_ERROR_RX_PACKET: + rfm22b_dev->stats.rx_error ++; + break; + + case RADIO_RESENT_TX_PACKET: + rfm22b_dev->stats.tx_resent ++; + break; + } + } + } + /* + * Calculate + * the + * link + * quality + * metric, + * which + * is + * related + * to + * the + * number + * of + * good + * packets + * in + * relation + * to + * the + * number + * of + * bad + * packets. + * Note: + * This + * assumes + * that + * the + * number + * of + * packets + * sampled + * for + * the + * stats + * is + * 64. + * Using + * this + * equation, + * error + * and + * resent + * packets + * are + * counted + * as + * -2, + * and + * corrected + * packets + * are + * counted + * as + * -1. + * The + * range + * is + * 0 + * (all + * error + * or + * resent + * packets) + * to + * 128 + * (all + * good + * packets). + + */ + rfm22b_dev->stats.link_quality = 64 + rfm22b_dev->stats.rx_good - rfm22b_dev->stats.rx_error - rfm22b_dev->stats.tx_resent; +} + +/** + * + * Add + * a + * status + * value + * to + * the + * RX + * packet + * status + * array. + * + * + * @param[in] + * rfm22b_dev + * + * The + * device + * structure + * + * @param[in] + * status + * + * The + * packet + * status + * value + */ +static void + rfm22b_add_rx_status +( + struct + pios_rfm22b_dev + * + rfm22b_dev, + enum + pios_rfm22b_rx_packet_status + status +){ + /* + * Shift + * the + * status + * registers */ + for (uint8_t i = RFM22B_RX_PACKET_STATS_LEN - 1; i > 0; --i) + { + rfm22b_dev->rx_packet_stats[i] = (rfm22b_dev->rx_packet_stats[i]<< 2) | (rfm22b_dev->rx_packet_stats[i - 1] >> 30); + } + rfm22b_dev->rx_packet_stats[0] = (rfm22b_dev->rx_packet_stats[0]<< 2) | status; +} + + +/***************************************************************************** + * + * Connection + * Handling + * Functions + *****************************************************************************/ + +/** + * + * Are + * we + * a + * coordinator + * modem? + * + * + * @param[in] + * rfm22b_dev + * + * The + * device + * structure + */ +static bool + rfm22_isCoordinator + (struct pios_rfm22b_dev* rfm22b_dev){ + return rfm22b_dev->coordinator; +} + +/** + * + * Returns + * the + * destination + * ID + * to + * send + * packets + * to. + * + * + * @param[in] + * rfm22b_id + * The + * RFM22B + * device + * index. + * + * @return + * The + * destination + * ID + */ +uint32_t + rfm22_destinationID + (struct pios_rfm22b_dev* rfm22b_dev){ + if (rfm22_isCoordinator(rfm22b_dev)){ + return rfm22b_dev->deviceID; + } + else if (rfm22b_dev->coordinatorID) + { + return rfm22b_dev->coordinatorID; + } + else { + return 0xffffffff; + } +} + + +/***************************************************************************** + * + * Frequency + * Hopping + * Functions + *****************************************************************************/ + +/** + * + * Synchronize + * the + * clock + * after + * a + * packet + * receive + * from + * our + * coordinator + * on + * the + * syncronization + * channel. + * + * This + * function + * should + * be + * called + * when + * a + * packet + * is + * received + * on + * the + * synchronization + * channel. + * + * + * @param[in] + * rfm22b_dev + * + * The + * device + * structure + */ +static void + rfm22_synchronizeClock + (struct pios_rfm22b_dev* rfm22b_dev){ + portTickType start_time = rfm22b_dev->packet_start_ticks; + + /* + * This + * packet + * was + * transmitted + * on + * channel + * 0, + * calculate + * the + * time + * delta + * that + * will + * force + * us + * to + * transmit + * on + * channel + * 0 + * at + * the + * time + * this + * packet + * started. */ + uint8_tnum_chan = num_channels[rfm22b_dev->datarate]; + uint16_tfrequency_hop_cycle_time = rfm22b_dev->packet_time * num_chan; + uint16_ttime_delta = start_time % frequency_hop_cycle_time; + + /* + * Calculate + * the + * adjustment + * for + * the + * preamble */ + uint8_toffset = (uint8_t)ceil(35000.0F / data_rate[rfm22b_dev->datarate]); + + rfm22b_dev->time_delta = frequency_hop_cycle_time - time_delta + offset; +} + +/** + * + * Return + * the + * extimated + * current + * clock + * ticks + * count + * on + * the + * coordinator + * modem. + * + * This + * is + * the + * master + * clock + * used + * for + * all + * synchronization. + * + * + * @param[in] + * rfm22b_dev + * + * The + * device + * structure + */ +static portTickType + rfm22_coordinatorTime +( + struct + pios_rfm22b_dev + * + rfm22b_dev, + portTickType + ticks +){ + if (rfm22_isCoordinator(rfm22b_dev)){ + return ticks; + } + + return ticks + rfm22b_dev->time_delta; +} + +/** + * + * Return + * true + * if + * this + * modem + * is + * in + * the + * send + * interval, + * which + * allows + * the + * modem + * to + * initiate + * a + * transmit. + * + * + * @param[in] + * rfm22b_dev + * + * The + * device + * structure + */ +static bool + rfm22_timeToSend + (struct pios_rfm22b_dev* rfm22b_dev){ + portTickType time = rfm22_coordinatorTime(rfm22b_dev, xTaskGetTickCount()); + bool is_coordinator = rfm22_isCoordinator(rfm22b_dev); + + /* + * If + * this + * is + * a + * one-way + * link, + * only + * the + * coordinator + * can + * send. */ + uint8_tpacket_period = rfm22b_dev->packet_time; + + if (rfm22b_dev->one_way_link){ + if (is_coordinator){ + return ((time - 1) % (packet_period)) == 0; + } + else { + return false; + } + } + if (!is_coordinator){ + time += packet_period - 1; + } + else { + time -= 1; + } + + return (time % (packet_period * 2)) == 0; +} + +/** + * + * Calculate + * the + * nth + * channel + * index. + * + * + * @param[in] + * rfm22b_dev + * + * The + * device + * structure + * + * @param[in] + * index + * + * The + * channel + * index + * to + * calculate + */ +static uint8_t + rfm22_calcChannel +( + struct + pios_rfm22b_dev + * + rfm22b_dev, + uint8_t + index +){ + /* + * Make + * sure + * we + * don't + * index + * outside + * of + * the + * range. */ + uint8_t num_chan = num_channels[rfm22b_dev->datarate]; + uint8_t idx = index % num_chan; + + /* + * Are + * we + * switching + * to + * a + * new + * channel? */ + if (idx != rfm22b_dev->channel_index){ + /* + * If + * the + * on_sync_channel + * flag + * is + * set, + * it + * means + * that + * we + * were + * on + * the + * sync + * channel, + * but + * no + * packet + * was + * received, + * so + * transition + * to + * a + * non-connected + * state. */ + if (!rfm22_isCoordinator (rfm22b_dev) && (rfm22b_dev->channel_index== 0) && rfm22b_dev->on_sync_channel){ + rfm22b_dev->on_sync_channel = false; + /* + * Set + * the + * link + * state + * to + * disconnected. */ + if (rfm22b_dev->stats.link_state == OPLINKSTATUS_LINKSTATE_CONNECTED){ + rfm22b_dev->stats.link_state = OPLINKSTATUS_LINKSTATE_DISCONNECTED; + + /* + * Set + * the + * PPM + * outputs + * to + * INVALID */ + for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS; ++i) + { + rfm22b_dev->ppm[i] = PIOS_RCVR_INVALID; + } + } + + /* + * Stay + * on + * the + * sync + * channel. */ + idx = 0; + } + else if (idx == 0) + { + /* + * If + * we're + * switching + * to + * the + * sync + * channel, + * set + * a + * flag + * that + * can + * be + * used + * to + * detect + * if + * a + * packet + * was + * received. */ + rfm22b_dev->on_sync_channel = true; + } + + rfm22b_dev->channel_index = idx; + } + + return rfm22b_dev->channels[idx]; +} + +/** + * + * Calculate + * what + * the + * current + * channel + * shold + * be. + * + * + * @param[in] + * rfm22b_dev + * + * The + * device + * structure + */ +static uint8_t + rfm22_calcChannelFromClock + (struct pios_rfm22b_dev* rfm22b_dev){ + portTickType time = rfm22_coordinatorTime(rfm22b_dev, xTaskGetTickCount()); + /* + * Divide + * time + * into + * 8ms + * blocks. + * + * Coordinator + * sends + * in + * first + * 2 + * ms, + * and + * remote + * send + * in + * 5th + * and + * 6th + * ms. + * Channel + * changes + * occur + * in + * the + * last + * 2 + * ms. + + */ + uint8_tnum_chan = num_channels[rfm22b_dev->datarate]; + uint8_tn = (time / rfm22b_dev->packet_time) % num_chan; + + return rfm22_calcChannel (rfm22b_dev,n); +} + +/** + * + * Change + * channels + * to + * the + * calculated + * current + * channel. + * + * + * @param[in] + * rfm22b_dev + * + * The + * device + * structure + */ +static bool + rfm22_changeChannel + (struct pios_rfm22b_dev* rfm22b_dev){ + /* + * A + * disconnected + * non-coordinator + * modem + * should + * sit + * on + * the + * sync + * channel + * until + * connected. */ + if (!rfm22_isCoordinator (rfm22b_dev) && ! rfm22_isConnected (rfm22b_dev)){ + return rfm22_setFreqHopChannel (rfm22b_dev,rfm22_calcChannel (rfm22b_dev,0)); + } + else { + return rfm22_setFreqHopChannel (rfm22b_dev,rfm22_calcChannelFromClock (rfm22b_dev)); + } +} + + +/***************************************************************************** + * + * Error + * Handling + * Functions + *****************************************************************************/ + +/** + * + * Recover + * from + * a + * transmit + * failure. + * + * + * @param[in] + * rfm22b_dev + * The + * device + * structure + * + * @return + * enum + * pios_radio_event + * + * The + * next + * event + * to + * inject + */ +static enum pios_radio_event + rfm22_txFailure + (struct pios_rfm22b_dev* rfm22b_dev){ + rfm22b_dev->stats.tx_failure ++; + rfm22b_dev->packet_start_ticks = 0; + rfm22b_dev->tx_data_wr = rfm22b_dev->tx_data_rd = 0; + + return RADIO_EVENT_TX_START; +} + +/** + * + * Recover + * from + * a + * timeout + * event. + * + * + * @param[in] + * rfm22b_dev + * + * The + * device + * structure + * + * @return + * enum + * pios_radio_event + * + * The + * next + * event + * to + * inject + */ +static enum pios_radio_event + rfm22_timeout + (struct pios_rfm22b_dev* rfm22b_dev){ + rfm22b_dev->stats.timeouts ++; + rfm22b_dev->packet_start_ticks = 0; + /* + * Release + * the + * Tx + * packet + * if + * it's + * set. */ + if (rfm22b_dev->tx_packet_handle != 0){ + rfm22b_dev->tx_data_rd = rfm22b_dev->tx_data_wr = 0; + } + + rfm22b_dev->rfm22b_state = RFM22B_STATE_TRANSITION; + rfm22b_dev->rx_buffer_wr = 0; + TX_LED_OFF; + RX_LED_OFF; +#ifdef PIOS_RFM22B_DEBUG_ON_TELEM + D1_LED_OFF; + D2_LED_OFF; + D3_LED_OFF; + D4_LED_OFF; +#endif + + return RADIO_EVENT_RX_MODE; +} + +/** + * + * Recover + * from + * a + * severe + * error. + * + * + * @param[in] + * rfm22b_dev + * + * The + * device + * structure + * + * @return + * enum + * pios_radio_event + * + * The + * next + * event + * to + * inject + */ +static enum pios_radio_event + rfm22_error + (struct pios_rfm22b_dev* rfm22b_dev){ + rfm22b_dev->stats.resets ++; + rfm22_clearLEDs(); + + return RADIO_EVENT_INITIALIZE; +} + +/** + * + * A + * fatal + * error + * has + * occured + * in + * the + * state + * machine. + * + * this + * should + * not + * happen. + * + * + * @parem + * [in] + * rfm22b_dev + * + * The + * device + * structure + * + * @return + * enum + * pios_radio_event + * + * The + * next + * event + * to + * inject + */ +static enum pios_radio_event + rfm22_fatal_error + (__attribute__((unused)) struct pios_rfm22b_dev* rfm22b_dev){ + /* + * RF + * module + * error + * .. + * flash + * the + * LED's */ + rfm22_clearLEDs(); + + for (unsigned int j = 0; j < 16; j++) + { + USB_LED_ON; + LINK_LED_ON; + RX_LED_OFF; + TX_LED_OFF; + + PIOS_DELAY_WaitmS (200); + + USB_LED_OFF; + LINK_LED_OFF; + RX_LED_ON; + TX_LED_ON; + + PIOS_DELAY_WaitmS ( 200); + } + PIOS_DELAY_WaitmS ( 1000); + + PIOS_Assert (0); + + return RADIO_EVENT_FATAL_ERROR; +} + + +/***************************************************************************** + * + * Utility + * Functions + *****************************************************************************/ + +/** + * + * Calculate + * the + * time + * difference + * between + * the + * start + * time + * and + * end + * time. + * + * Times + * are + * in + * ticks. + * + * Also + * handles + * rollover. + * + * + * @param[in] + * start_time + * + * The + * start + * time + * in + * ticks. + * + * @param[in] + * end_time + * + * The + * end + * time + * in + * ticks. + */ +static uint32_t + pios_rfm22_time_difference_ms +( + portTickType + start_time, + portTickType + end_time +){ + if (end_time >= start_time){ + return (end_time - start_time) * portTICK_RATE_MS; + } + + /* + * Rollover */ + return ((portMAX_DELAY - start_time) + end_time) * portTICK_RATE_MS; +} + +/** + * + * Allocate + * the + * device + * structure + */ #if defined(PIOS_INCLUDE_FREERTOS) -static struct pios_rfm22b_dev *pios_rfm22_alloc(void) -{ - struct pios_rfm22b_dev *rfm22b_dev; +static struct +pios_rfm22b_dev +* + pios_rfm22_alloc + (void){ + struct pios_rfm22b_dev * rfm22b_dev; - rfm22b_dev = (struct pios_rfm22b_dev *)pvPortMalloc(sizeof(*rfm22b_dev)); - rfm22b_dev->spi_id = 0; - if (!rfm22b_dev) { - return NULL; - } + rfm22b_dev = (struct pios_rfm22b_dev *)pvPortMalloc(sizeof(*rfm22b_dev)); + rfm22b_dev->spi_id = 0; + if (!rfm22b_dev){ + return NULL; + } - rfm22b_dev->magic = PIOS_RFM22B_DEV_MAGIC; - return rfm22b_dev; + rfm22b_dev->magic = PIOS_RFM22B_DEV_MAGIC; + + return rfm22b_dev; } #else -static struct pios_rfm22b_dev pios_rfm22b_devs[PIOS_RFM22B_MAX_DEVS]; -static uint8_t pios_rfm22b_num_devs; -static struct pios_rfm22b_dev *pios_rfm22_alloc(void) -{ - struct pios_rfm22b_dev *rfm22b_dev; + static + struct + pios_rfm22b_dev + pios_rfm22b_devs + [PIOS_RFM22B_MAX_DEVS]; + static + uint8_t + pios_rfm22b_num_devs; +static struct pios_rfm22b_dev *pios_rfm22_alloc + (void){ + struct pios_rfm22b_dev * rfm22b_dev; - if (pios_rfm22b_num_devs >= PIOS_RFM22B_MAX_DEVS) { - return NULL; - } + if (pios_rfm22b_num_devs >= PIOS_RFM22B_MAX_DEVS){ + return NULL; + } - rfm22b_dev = &pios_rfm22b_devs[pios_rfm22b_num_devs++]; - rfm22b_dev->magic = PIOS_RFM22B_DEV_MAGIC; + rfm22b_dev = &pios_rfm22b_devs[pios_rfm22b_num_devs++]; + rfm22b_dev->magic = PIOS_RFM22B_DEV_MAGIC; - return rfm22b_dev; + return rfm22b_dev; } #endif /* if defined(PIOS_INCLUDE_FREERTOS) */ /** - * Turn off all of the LEDs - */ -static void rfm22_clearLEDs(void) -{ - LINK_LED_OFF; - RX_LED_OFF; - TX_LED_OFF; + * + * Turn + * off + * all + * of + * the + * LEDs + */ +static void rfm22_clearLEDs + (void){ + LINK_LED_OFF; + RX_LED_OFF; + TX_LED_OFF; #ifdef PIOS_RFM22B_DEBUG_ON_TELEM - D1_LED_OFF; - D2_LED_OFF; - D3_LED_OFF; - D4_LED_OFF; + D1_LED_OFF; + D2_LED_OFF; + D3_LED_OFF; + D4_LED_OFF; #endif } /***************************************************************************** -* SPI Read/Write Functions -*****************************************************************************/ + * + * SPI + * Read/Write + * Functions + *****************************************************************************/ /** - * Assert the chip select line. - * - * @param[in] rfm22b_dev The RFM22B device. - */ -static void rfm22_assertCs(struct pios_rfm22b_dev *rfm22b_dev) -{ - PIOS_DELAY_WaituS(1); - if (rfm22b_dev->spi_id != 0) { - PIOS_SPI_RC_PinSet(rfm22b_dev->spi_id, rfm22b_dev->slave_num, 0); - } + * + * Assert + * the + * chip + * select + * line. + * + * + * @param[in] + * rfm22b_dev + * + * The + * RFM22B + * device. + */ +static void rfm22_assertCs + (struct pios_rfm22b_dev* rfm22b_dev){ + PIOS_DELAY_WaituS (1); + if (rfm22b_dev->spi_id != 0){ + PIOS_SPI_RC_PinSet (rfm22b_dev->spi_id,rfm22b_dev->slave_num,0); + } } /** - * Deassert the chip select line. - * - * @param[in] rfm22b_dev The RFM22B device structure pointer. - */ -static void rfm22_deassertCs(struct pios_rfm22b_dev *rfm22b_dev) -{ - if (rfm22b_dev->spi_id != 0) { - PIOS_SPI_RC_PinSet(rfm22b_dev->spi_id, rfm22b_dev->slave_num, 1); - } + * + * Deassert + * the + * chip + * select + * line. + * + * + * @param[in] + * rfm22b_dev + * + * The + * RFM22B + * device + * structure + * pointer. + */ +static void rfm22_deassertCs + (struct pios_rfm22b_dev* rfm22b_dev){ + if (rfm22b_dev->spi_id != 0){ + PIOS_SPI_RC_PinSet (rfm22b_dev->spi_id,rfm22b_dev->slave_num,1); + } } /** - * Claim the SPI bus. - * - * @param[in] rfm22b_dev The RFM22B device structure pointer. - */ -static void rfm22_claimBus(struct pios_rfm22b_dev *rfm22b_dev) -{ - if (rfm22b_dev->spi_id != 0) { - PIOS_SPI_ClaimBus(rfm22b_dev->spi_id); - } + * + * Claim + * the + * SPI + * bus. + * + * + * @param[in] + * rfm22b_dev + * + * The + * RFM22B + * device + * structure + * pointer. + */ +static void rfm22_claimBus + (struct pios_rfm22b_dev* rfm22b_dev){ + if (rfm22b_dev->spi_id != 0){ + PIOS_SPI_ClaimBus (rfm22b_dev->spi_id); + } } /** - * Release the SPI bus. - * - * @param[in] rfm22b_dev The RFM22B device structure pointer. - */ -static void rfm22_releaseBus(struct pios_rfm22b_dev *rfm22b_dev) -{ - if (rfm22b_dev->spi_id != 0) { - PIOS_SPI_ReleaseBus(rfm22b_dev->spi_id); - } + * + * Release + * the + * SPI + * bus. + * + * + * @param[in] + * rfm22b_dev + * + * The + * RFM22B + * device + * structure + * pointer. + */ +static void rfm22_releaseBus + (struct pios_rfm22b_dev* rfm22b_dev){ + if (rfm22b_dev->spi_id != 0){ + PIOS_SPI_ReleaseBus (rfm22b_dev->spi_id); + } } /** - * Claim the semaphore and write a byte to a register - * - * @param[in] rfm22b_dev The RFM22B device. - * @param[in] addr The address to write to - * @param[in] data The datat to write to that address - */ -static void rfm22_write_claim(struct pios_rfm22b_dev *rfm22b_dev, uint8_t addr, uint8_t data) -{ - rfm22_claimBus(rfm22b_dev); - rfm22_assertCs(rfm22b_dev); - uint8_t buf[2] = { addr | 0x80, data }; - PIOS_SPI_TransferBlock(rfm22b_dev->spi_id, buf, NULL, sizeof(buf), NULL); - rfm22_deassertCs(rfm22b_dev); - rfm22_releaseBus(rfm22b_dev); + * + * Claim + * the + * semaphore + * and + * write + * a + * byte + * to + * a + * register + * + * + * @param[in] + * rfm22b_dev + * + * The + * RFM22B + * device. + * + * @param[in] + * addr + * The + * address + * to + * write + * to + * + * @param[in] + * data + * The + * datat + * to + * write + * to + * that + * address + */ +static void rfm22_write_claim +( + struct + pios_rfm22b_dev + * + rfm22b_dev, + uint8_t + addr, + uint8_t + data +){ + rfm22_claimBus (rfm22b_dev); + rfm22_assertCs (rfm22b_dev); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + uint8_t buf[2] = { addr | 0x80, data }; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PIOS_SPI_TransferBlock (rfm22b_dev->spi_id,buf,NULL,sizeof(buf),NULL); + rfm22_deassertCs (rfm22b_dev); + rfm22_releaseBus (rfm22b_dev); } /** - * Write a byte to a register without claiming the semaphore - * - * @param[in] rfm22b_dev The RFM22B device. - * @param[in] addr The address to write to - * @param[in] data The datat to write to that address - */ -static void rfm22_write(struct pios_rfm22b_dev *rfm22b_dev, uint8_t addr, uint8_t data) -{ - rfm22_assertCs(rfm22b_dev); - uint8_t buf[2] = { addr | 0x80, data }; - PIOS_SPI_TransferBlock(rfm22b_dev->spi_id, buf, NULL, sizeof(buf), NULL); - rfm22_deassertCs(rfm22b_dev); + * + * Write + * a + * byte + * to + * a + * register + * without + * claiming + * the + * semaphore + * + * + * @param[in] + * rfm22b_dev + * + * The + * RFM22B + * device. + * + * @param[in] + * addr + * The + * address + * to + * write + * to + * + * @param[in] + * data + * The + * datat + * to + * write + * to + * that + * address + */ +static void rfm22_write +( + struct + pios_rfm22b_dev + * + rfm22b_dev, + uint8_t + addr, + uint8_t + data +){ + rfm22_assertCs (rfm22b_dev); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + uint8_t buf[2] = { addr | 0x80, data }; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PIOS_SPI_TransferBlock (rfm22b_dev->spi_id,buf,NULL,sizeof(buf),NULL); + rfm22_deassertCs (rfm22b_dev); } /** - * Read a byte from an RFM22b register without claiming the bus - * - * @param[in] rfm22b_dev The RFM22B device structure pointer. - * @param[in] addr The address to read from - * @return Returns the result of the register read - */ -static uint8_t rfm22_read(struct pios_rfm22b_dev *rfm22b_dev, uint8_t addr) -{ - uint8_t out[2] = { addr &0x7F, 0xFF }; - uint8_t in[2]; + * + * Read + * a + * byte + * from + * an + * RFM22b + * register + * without + * claiming + * the + * bus + * + * + * @param[in] + * rfm22b_dev + * + * The + * RFM22B + * device + * structure + * pointer. + * + * @param[in] + * addr + * The + * address + * to + * read + * from + * + * @return + * Returns + * the + * result + * of + * the + * register + * read + */ +static uint8_t rfm22_read +( + struct + pios_rfm22b_dev + * + rfm22b_dev, + uint8_t + addr +){ + uint8_t out[2] = { addr &0x7F, 0xFF }; + uint8_t in[2]; - rfm22_assertCs(rfm22b_dev); - PIOS_SPI_TransferBlock(rfm22b_dev->spi_id, out, in, sizeof(out), NULL); - rfm22_deassertCs(rfm22b_dev); - return in[1]; + rfm22_assertCs (rfm22b_dev); + PIOS_SPI_TransferBlock (rfm22b_dev->spi_id,out,in,sizeof(out),NULL); + rfm22_deassertCs (rfm22b_dev); + + return in[1]; } #endif /* PIOS_INCLUDE_RFM22B */ /** - * @} - * @} - */ + * + * @} + * + * @} + */ From 48984a25fd78d6a9a9a4a8fa0ba313c0be935adc Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Tue, 14 Jan 2014 21:23:43 +0100 Subject: [PATCH 45/45] OP-984 fixed corrupt file. --- flight/pios/common/pios_rfm22b.c | 6204 ++++-------------------------- 1 file changed, 838 insertions(+), 5366 deletions(-) diff --git a/flight/pios/common/pios_rfm22b.c b/flight/pios/common/pios_rfm22b.c index 81e2509ad..c663da70d 100644 --- a/flight/pios/common/pios_rfm22b.c +++ b/flight/pios/common/pios_rfm22b.c @@ -1,321 +1,57 @@ /** ****************************************************************************** + * @addtogroup PIOS PIOS Core hardware abstraction layer + * @{ + * @addtogroup PIOS_RFM22B Radio Functions + * @brief PIOS interface for for the RFM22B radio + * @{ * - * @addtogroup - * PIOS - * PIOS - * Core - * hardware - * abstraction - * layer - * - * @{ - * - * @addtogroup - * - * - * PIOS_RFM22B - * Radio - * Functions - * - * @brief - * PIOS - * interface - * for - * for - * the - * RFM22B - * radio - * - * @{ - * - * - * @file - * - * - * - * - * - * - * pios_rfm22b.c - * - * @author - * - * - * - * - * The - * OpenPilot - * Team, - * http://www.openpilot.org - * Copyright - * (C) - * 2012. - * - * @brief - * - * - * - * - * - * Implements - * a - * driver - * the - * the - * RFM22B - * driver - * - * @see - * - * - * - * - * - * - * - * The - * GNU - * Public - * License - * (GPL) - * Version - * 3 + * @file pios_rfm22b.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @brief Implements a driver the the RFM22B driver + * @see The GNU Public License (GPL) Version 3 * *****************************************************************************/ /* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. * - * This - * program - * is - * free - * software; - * you - * can - * redistribute - * it - * and/or - * modify + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. * - * it - * under - * the - * terms - * of - * the - * GNU - * General - * Public - * License - * as - * published - * by - * - * the - * Free - * Software - * Foundation; - * either - * version - * 3 - * of - * the - * License, - * or - * - * (at - * your - * option) - * any - * later - * version. - * - * - * This - * program - * is - * distributed - * in - * the - * hope - * that - * it - * will - * be - * useful, - * but - * - * WITHOUT - * ANY - * WARRANTY; - * without - * even - * the - * implied - * warranty - * of - * MERCHANTABILITY - * - * or - * FITNESS - * FOR - * A - * PARTICULAR - * PURPOSE. - * See - * the - * GNU - * General - * Public - * License - * - * for - * more - * details. - * - * - * You - * should - * have - * received - * a - * copy - * of - * the - * GNU - * General - * Public - * License - * along - * - * with - * this - * program; - * if - * not, - * write - * to - * the - * Free - * Software - * Foundation, - * Inc., - * - * 59 - * Temple - * Place, - * Suite - * 330, - * Boston, - * MA - * 02111-1307 - * USA + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* - * ***************************************************************** - * RFM22B - * hardware - * layer - * - * This - * module - * uses - * the - * RFM22B's - * internal - * packet - * handling - * hardware - * to - * encapsulate - * our - * own - * packet - * data. - * - * The - * RFM22B - * internal - * hardware - * packet - * handler - * configuration - * is - * as - * follows: - * - * 6-byte - * (32-bit) - * preamble - * .. - * alternating - * 0's - * & - * 1's - * 4-byte - * (32-bit) - * sync - * 1-byte - * packet - * length - * (number - * of - * data - * bytes - * to - * follow) - * 0 - * to - * 255 - * user - * data - * bytes - * 4 - * byte - * ECC - * - * OR - * in - * PPM - * only - * mode: - * - * 6-byte - * (32-bit) - * preamble - * .. - * alternating - * 0's - * & - * 1's - * 4-byte - * (32-bit) - * sync - * 1-byte - * packet - * length - * (number - * of - * data - * bytes - * to - * follow) - * 1 - * byte - * valid - * bitmask - * 8 - * PPM - * values - * (0-255) - * 1 - * byte - * CRC - * - * ***************************************************************** - - */ +// ***************************************************************** +// RFM22B hardware layer +// +// This module uses the RFM22B's internal packet handling hardware to +// encapsulate our own packet data. +// +// The RFM22B internal hardware packet handler configuration is as follows: +// +// 6-byte (32-bit) preamble .. alternating 0's & 1's +// 4-byte (32-bit) sync +// 1-byte packet length (number of data bytes to follow) +// 0 to 255 user data bytes +// 4 byte ECC +// +// OR in PPM only mode: +// +// 6-byte (32-bit) preamble .. alternating 0's & 1's +// 4-byte (32-bit) sync +// 1-byte packet length (number of data bytes to follow) +// 1 byte valid bitmask +// 8 PPM values (0-255) +// 1 byte CRC +// +// ***************************************************************** #include "pios.h" @@ -326,14 +62,10 @@ #include #include -/* - * Local - * Defines - * */ +/* Local Defines */ #define STACK_SIZE_BYTES 200 #define TASK_PRIORITY (tskIDLE_PRIORITY + 2) -#define ISR_TIMEOUT 1 /* - * ms */ +#define ISR_TIMEOUT 1 // ms #define EVENT_QUEUE_SIZE 5 #define RFM22B_DEFAULT_RX_DATARATE RFM22_datarate_9600 #define RFM22B_DEFAULT_TX_POWER RFM22_tx_pwr_txpow_0 @@ -344,94 +76,30 @@ #define RFM22B_DEFAULT_CHANNEL_SET 24 #define RFM22B_PPM_ONLY_DATARATE RFM22_datarate_9600 -/* - * The - * maximum - * amount - * of - * time - * without - * activity - * before - * initiating - * a - * reset. */ -#define PIOS_RFM22B_SUPERVISOR_TIMEOUT 150 /* - * ms */ +// The maximum amount of time without activity before initiating a reset. +#define PIOS_RFM22B_SUPERVISOR_TIMEOUT 150 // ms -/* - * this - * is - * too - * adjust - * the - * RF - * module - * so - * that - * it - * is - * on - * frequency */ -#define OSC_LOAD_CAP 0x7F /* - * cap - * = - * 12.5pf - * .. - * default */ +// this is too adjust the RF module so that it is on frequency +#define OSC_LOAD_CAP 0x7F // cap = 12.5pf .. default -#define TX_PREAMBLE_NIBBLES 12 /* - * 7 - * to - * 511 - * (number - * of - * nibbles) */ -#define RX_PREAMBLE_NIBBLES 6 /* - * 5 - * to - * 31 - * (number - * of - * nibbles) */ +#define TX_PREAMBLE_NIBBLES 12 // 7 to 511 (number of nibbles) +#define RX_PREAMBLE_NIBBLES 6 // 5 to 31 (number of nibbles) #define SYNC_BYTES 4 #define HEADER_BYTES 4 #define LENGTH_BYTES 1 -/* - * the - * size - * of - * the - * rf - * modules - * internal - * FIFO - * buffers */ +// the size of the rf modules internal FIFO buffers #define FIFO_SIZE 64 -#define TX_FIFO_HI_WATERMARK 62 /* - * 0-63 */ -#define TX_FIFO_LO_WATERMARK 32 /* - * 0-63 */ +#define TX_FIFO_HI_WATERMARK 62 // 0-63 +#define TX_FIFO_LO_WATERMARK 32 // 0-63 -#define RX_FIFO_HI_WATERMARK 32 /* - * 0-63 */ +#define RX_FIFO_HI_WATERMARK 32 // 0-63 -/* - * preamble - * byte - * (preceeds - * SYNC_BYTE's) */ +// preamble byte (preceeds SYNC_BYTE's) #define PREAMBLE_BYTE 0x55 -/* - * RF - * sync - * bytes - * (32-bit - * in - * all) */ +// RF sync bytes (32-bit in all) #define SYNC_BYTE_1 0x2D #define SYNC_BYTE_2 0xD4 #define SYNC_BYTE_3 0x4B @@ -448,1056 +116,279 @@ #define USB_LED_OFF #endif - -/* - * Local - * type - * definitions - * */ +/* Local type definitions */ struct pios_rfm22b_transition { - enum - pios_radio_event - ( - * - entry_fn)( - struct - pios_rfm22b_dev - * - rfm22b_dev); - enum - pios_radio_state - next_state - [ - RADIO_EVENT_NUM_EVENTS]; + enum pios_radio_event (*entry_fn)(struct pios_rfm22b_dev *rfm22b_dev); + enum pios_radio_state next_state[RADIO_EVENT_NUM_EVENTS]; }; -/* - * Must - * ensure - * these - * prefilled - * arrays - * match - * the - * define - * sizes */ +// Must ensure these prefilled arrays match the define sizes static const uint8_t FULL_PREAMBLE[FIFO_SIZE] = { - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE, - PREAMBLE_BYTE -}; /* - * 64 - * bytes */ + PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, + PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, + PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, + PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, + PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, + PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, + PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, + PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, + PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, + PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, + PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, + PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, + PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE +}; // 64 bytes static const uint8_t HEADER[(TX_PREAMBLE_NIBBLES + 1) / 2 + 2] = { PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, PREAMBLE_BYTE, SYNC_BYTE_1, SYNC_BYTE_2 }; static const uint8_t OUT_FF[64] = { - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF,0xFF, 0xFF, 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF,0xFF, 0xFF, 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF,0xFF, 0xFF, 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF,0xFF, 0xFF, 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF,0xFF, 0xFF, 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF,0xFF, 0xFF, 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF,0xFF, 0xFF, 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF,0xFF, 0xFF, 0xFF -}; -/* - * The - * randomized - * channel - * list. */ -static const uint8_t channel_list[] = { - 68, - 34, - 2, - 184,166, 94, 204, 18, 47, 118, 239, 176, 5, 213, 218, 186, 104, 160, 199, 209, 231, 197, 92, 191, 88, 129, 40, 19, 93, 200, 156, 14, 247, 182, 193, 194, 208, 210, 248, 76, 244, 48, 179, 105, 25, 74, 155, 203, - 39, - 97, - 195,81, 83, 180, 134, 172, 235, 132, 198, 119, 207, - 154, - 0, - 61, - 140,171, 245, 26, 95, 3, 22, 62, 169, 55, 127, 144, 45, 33, 170, 91, 158, 167, 63, 201, 41, 21, 190, 51, 103, 49, 189, 205, 240, 89, 181, 149, 6, 157, 249, 230, 115, 72, 163, 17, 29, 99, 28, 117, 219, - 73, - 78, - 53, 69, - 216, - 161, - 124, - 110,242, 214, 145, 13, 11, 220, 113, 138, 58, 54, 162, 237, 37, 152, 187, 232, 77, 126, 85, 38, 238, 173, 23, 188, 100, 131, 226, 31, 9, 114, 106, 221, 42, 233, 139, 4, 241, 96, 211, 8, 98, 121, 147, 24, - 217, - 27, - 87, - 122, - 125, - 135, - 148,178, 71, 206, 57, 141, 35, 30, 246, 159, 16, 32, 15, 229, 20, 12, 223, 150, 101, 79, 56, 102, 111, 174, 236, 137, 143, 52, 225, 64, 224, 112, 168, 243, 130, 108, 202, 123, 146, 228, 75, 46, 153, 7, 192, - 175, - 151, - 222, - 59, - 82, - 90, 1, 65, 109, 44, 165, 84, 43, 36, 128, 196, 67, 80, 136, 86, 70, 234, 66, 185, 10, 164, 177, 116, 50, 107, 183, 215, 212, 60, 227, 133, 120, 142 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; +// The randomized channel list. +static const uint8_t channel_list[] = { 68, 34, 2, 184, 166, 94, 204, 18, 47, 118, 239, 176, 5, 213, 218, 186, 104, 160, 199, 209, 231, 197, 92, 191, 88, 129, 40, 19, 93, 200, 156, 14, 247, 182, 193, 194, 208, 210, 248, 76, 244, 48, 179, 105, 25, 74, 155, 203, 39, 97, 195, 81, 83, 180, 134, 172, 235, 132, 198, 119, 207, 154, 0, 61, 140, 171, 245, 26, 95, 3, 22, 62, 169, 55, 127, 144, 45, 33, 170, 91, 158, 167, 63, 201, 41, 21, 190, 51, 103, 49, 189, 205, 240, 89, 181, 149, 6, 157, 249, 230, 115, 72, 163, 17, 29, 99, 28, 117, 219, 73, 78, 53, 69, 216, 161, 124, 110, 242, 214, 145, 13, 11, 220, 113, 138, 58, 54, 162, 237, 37, 152, 187, 232, 77, 126, 85, 38, 238, 173, 23, 188, 100, 131, 226, 31, 9, 114, 106, 221, 42, 233, 139, 4, 241, 96, 211, 8, 98, 121, 147, 24, 217, 27, 87, 122, 125, 135, 148, 178, 71, 206, 57, 141, 35, 30, 246, 159, 16, 32, 15, 229, 20, 12, 223, 150, 101, 79, 56, 102, 111, 174, 236, 137, 143, 52, 225, 64, 224, 112, 168, 243, 130, 108, 202, 123, 146, 228, 75, 46, 153, 7, 192, 175, 151, 222, 59, 82, 90, 1, 65, 109, 44, 165, 84, 43, 36, 128, 196, 67, 80, 136, 86, 70, 234, 66, 185, 10, 164, 177, 116, 50, 107, 183, 215, 212, 60, 227, 133, 120, 142 }; -/* - * Local - * function - * forwared - * declarations - * */ -static void pios_rfm22_task( - void - * - parameters); -static bool pios_rfm22_readStatus( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static void pios_rfm22_setDatarate( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static void rfm22_rxFailure( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static void pios_rfm22_inject_event( - struct - pios_rfm22b_dev - *rfm22b_dev, - enum - pios_radio_event - event, - bool - inISR); -static enum pios_radio_event rfm22_init( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static enum pios_radio_event radio_setRxMode( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static enum pios_radio_event radio_rxData( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static enum pios_radio_event radio_receivePacket( - struct - pios_rfm22b_dev - *rfm22b_dev, - uint8_t - * - p, - uint16_t - rx_len); -static enum pios_radio_event radio_txStart( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static enum pios_radio_event radio_txData( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static enum pios_radio_event rfm22_txFailure( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static enum pios_radio_event rfm22_process_state_transition( - struct - pios_rfm22b_dev - *rfm22b_dev, - enum - pios_radio_event - event); -static void rfm22_process_event( - struct - pios_rfm22b_dev - *rfm22b_dev, - enum - pios_radio_event - event); -static enum pios_radio_event rfm22_timeout( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static enum pios_radio_event rfm22_error( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static enum pios_radio_event rfm22_fatal_error( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static void rfm22b_add_rx_status( - struct - pios_rfm22b_dev - *rfm22b_dev, - enum - pios_rfm22b_rx_packet_status - status); -static void rfm22_setNominalCarrierFrequency( - struct - pios_rfm22b_dev - *rfm22b_dev, - uint8_t - init_chan); -static bool rfm22_setFreqHopChannel( - struct - pios_rfm22b_dev - *rfm22b_dev, - uint8_t - channel); -static void rfm22_updatePairStatus( - struct - pios_rfm22b_dev - * - radio_dev); -static void rfm22_calculateLinkQuality( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static bool rfm22_isConnected( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static bool rfm22_isCoordinator( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static uint32_t rfm22_destinationID( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static bool rfm22_timeToSend( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static void rfm22_synchronizeClock( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static portTickType rfm22_coordinatorTime( - struct - pios_rfm22b_dev - *rfm22b_dev, - portTickType - ticks); -static uint8_t rfm22_calcChannel( - struct - pios_rfm22b_dev - *rfm22b_dev, - uint8_t - index); -static uint8_t rfm22_calcChannelFromClock( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static bool rfm22_changeChannel( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static void rfm22_clearLEDs(); +/* Local function forwared declarations */ +static void pios_rfm22_task(void *parameters); +static bool pios_rfm22_readStatus(struct pios_rfm22b_dev *rfm22b_dev); +static void pios_rfm22_setDatarate(struct pios_rfm22b_dev *rfm22b_dev); +static void rfm22_rxFailure(struct pios_rfm22b_dev *rfm22b_dev); +static void pios_rfm22_inject_event(struct pios_rfm22b_dev *rfm22b_dev, enum pios_radio_event event, bool inISR); +static enum pios_radio_event rfm22_init(struct pios_rfm22b_dev *rfm22b_dev); +static enum pios_radio_event radio_setRxMode(struct pios_rfm22b_dev *rfm22b_dev); +static enum pios_radio_event radio_rxData(struct pios_rfm22b_dev *rfm22b_dev); +static enum pios_radio_event radio_receivePacket(struct pios_rfm22b_dev *rfm22b_dev, uint8_t *p, uint16_t rx_len); +static enum pios_radio_event radio_txStart(struct pios_rfm22b_dev *rfm22b_dev); +static enum pios_radio_event radio_txData(struct pios_rfm22b_dev *rfm22b_dev); +static enum pios_radio_event rfm22_txFailure(struct pios_rfm22b_dev *rfm22b_dev); +static enum pios_radio_event rfm22_process_state_transition(struct pios_rfm22b_dev *rfm22b_dev, enum pios_radio_event event); +static void rfm22_process_event(struct pios_rfm22b_dev *rfm22b_dev, enum pios_radio_event event); +static enum pios_radio_event rfm22_timeout(struct pios_rfm22b_dev *rfm22b_dev); +static enum pios_radio_event rfm22_error(struct pios_rfm22b_dev *rfm22b_dev); +static enum pios_radio_event rfm22_fatal_error(struct pios_rfm22b_dev *rfm22b_dev); +static void rfm22b_add_rx_status(struct pios_rfm22b_dev *rfm22b_dev, enum pios_rfm22b_rx_packet_status status); +static void rfm22_setNominalCarrierFrequency(struct pios_rfm22b_dev *rfm22b_dev, uint8_t init_chan); +static bool rfm22_setFreqHopChannel(struct pios_rfm22b_dev *rfm22b_dev, uint8_t channel); +static void rfm22_updatePairStatus(struct pios_rfm22b_dev *radio_dev); +static void rfm22_calculateLinkQuality(struct pios_rfm22b_dev *rfm22b_dev); +static bool rfm22_isConnected(struct pios_rfm22b_dev *rfm22b_dev); +static bool rfm22_isCoordinator(struct pios_rfm22b_dev *rfm22b_dev); +static uint32_t rfm22_destinationID(struct pios_rfm22b_dev *rfm22b_dev); +static bool rfm22_timeToSend(struct pios_rfm22b_dev *rfm22b_dev); +static void rfm22_synchronizeClock(struct pios_rfm22b_dev *rfm22b_dev); +static portTickType rfm22_coordinatorTime(struct pios_rfm22b_dev *rfm22b_dev, portTickType ticks); +static uint8_t rfm22_calcChannel(struct pios_rfm22b_dev *rfm22b_dev, uint8_t index); +static uint8_t rfm22_calcChannelFromClock(struct pios_rfm22b_dev *rfm22b_dev); +static bool rfm22_changeChannel(struct pios_rfm22b_dev *rfm22b_dev); +static void rfm22_clearLEDs(); -/* - * Utility - * functions. */ -static uint32_t pios_rfm22_time_difference_ms( - portTickType - start_time, - portTickType - end_time); -static struct pios_rfm22b_dev *pios_rfm22_alloc( - void); +// Utility functions. +static uint32_t pios_rfm22_time_difference_ms(portTickType start_time, portTickType end_time); +static struct pios_rfm22b_dev *pios_rfm22_alloc(void); -/* - * SPI - * read/write - * functions */ -static void rfm22_assertCs( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static void rfm22_deassertCs( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static void rfm22_claimBus( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static void rfm22_releaseBus( - struct - pios_rfm22b_dev - * - rfm22b_dev); -static void rfm22_write_claim( - struct - pios_rfm22b_dev - *rfm22b_dev, - uint8_t - addr, - uint8_t - data); -static void rfm22_write( - struct - pios_rfm22b_dev - *rfm22b_dev, - uint8_t - addr, - uint8_t - data); -static uint8_t rfm22_read( - struct - pios_rfm22b_dev - *rfm22b_dev, - uint8_t - addr); +// SPI read/write functions +static void rfm22_assertCs(struct pios_rfm22b_dev *rfm22b_dev); +static void rfm22_deassertCs(struct pios_rfm22b_dev *rfm22b_dev); +static void rfm22_claimBus(struct pios_rfm22b_dev *rfm22b_dev); +static void rfm22_releaseBus(struct pios_rfm22b_dev *rfm22b_dev); +static void rfm22_write_claim(struct pios_rfm22b_dev *rfm22b_dev, uint8_t addr, uint8_t data); +static void rfm22_write(struct pios_rfm22b_dev *rfm22b_dev, uint8_t addr, uint8_t data); +static uint8_t rfm22_read(struct pios_rfm22b_dev *rfm22b_dev, uint8_t addr); -/* - * The - * state - * transition - * table - * */ +/* The state transition table */ static const struct pios_rfm22b_transition rfm22b_transitions[RADIO_STATE_NUM_STATES] = { - /* - * Initialization - * thread */ - [ - RADIO_STATE_UNINITIALIZED - ] - = { - . - entry_fn - = - 0, - . - next_state - ={ - [ - RADIO_EVENT_INITIALIZE - ] - = - RADIO_STATE_INITIALIZING, - [ - RADIO_EVENT_ERROR - ] - = - RADIO_STATE_ERROR, - }, + // Initialization thread + [RADIO_STATE_UNINITIALIZED] = { + .entry_fn = 0, + .next_state = { + [RADIO_EVENT_INITIALIZE] = RADIO_STATE_INITIALIZING, + [RADIO_EVENT_ERROR] = RADIO_STATE_ERROR, }, - [ - RADIO_STATE_INITIALIZING - ] - = { - . - entry_fn - = - rfm22_init, - . - next_state - ={ - [ - RADIO_EVENT_INITIALIZED - ] - = - RADIO_STATE_RX_MODE, - [ - RADIO_EVENT_ERROR - ] - = - RADIO_STATE_ERROR, - [ - RADIO_EVENT_INITIALIZE - ] - = - RADIO_STATE_INITIALIZING, - [ - RADIO_EVENT_FATAL_ERROR - ] - = - RADIO_STATE_FATAL_ERROR, - }, + }, + [RADIO_STATE_INITIALIZING] = { + .entry_fn = rfm22_init, + .next_state = { + [RADIO_EVENT_INITIALIZED] = RADIO_STATE_RX_MODE, + [RADIO_EVENT_ERROR] = RADIO_STATE_ERROR, + [RADIO_EVENT_INITIALIZE] = RADIO_STATE_INITIALIZING, + [RADIO_EVENT_FATAL_ERROR] = RADIO_STATE_FATAL_ERROR, }, + }, - [ - RADIO_STATE_RX_MODE - ] - = { - . - entry_fn - = - radio_setRxMode, - . - next_state - ={ - [ - RADIO_EVENT_INT_RECEIVED - ] - = - RADIO_STATE_RX_DATA, - [ - RADIO_EVENT_TX_START - ] - = - RADIO_STATE_TX_START, - [ - RADIO_EVENT_RX_MODE - ] - = - RADIO_STATE_RX_MODE, - [ - RADIO_EVENT_TIMEOUT - ] - = - RADIO_STATE_TIMEOUT, - [ - RADIO_EVENT_ERROR - ] - = - RADIO_STATE_ERROR, - [ - RADIO_EVENT_INITIALIZE - ] - = - RADIO_STATE_INITIALIZING, - [ - RADIO_EVENT_FATAL_ERROR - ] - = - RADIO_STATE_FATAL_ERROR, - }, + [RADIO_STATE_RX_MODE] = { + .entry_fn = radio_setRxMode, + .next_state = { + [RADIO_EVENT_INT_RECEIVED] = RADIO_STATE_RX_DATA, + [RADIO_EVENT_TX_START] = RADIO_STATE_TX_START, + [RADIO_EVENT_RX_MODE] = RADIO_STATE_RX_MODE, + [RADIO_EVENT_TIMEOUT] = RADIO_STATE_TIMEOUT, + [RADIO_EVENT_ERROR] = RADIO_STATE_ERROR, + [RADIO_EVENT_INITIALIZE] = RADIO_STATE_INITIALIZING, + [RADIO_EVENT_FATAL_ERROR] = RADIO_STATE_FATAL_ERROR, }, - [ - RADIO_STATE_RX_DATA - ] - = { - . - entry_fn - = - radio_rxData, - . - next_state - ={ - [ - RADIO_EVENT_INT_RECEIVED - ] - = - RADIO_STATE_RX_DATA, - [ - RADIO_EVENT_TX_START - ] - = - RADIO_STATE_TX_START, - [ - RADIO_EVENT_RX_COMPLETE - ] - = - RADIO_STATE_TX_START, - [ - RADIO_EVENT_RX_MODE - ] - = - RADIO_STATE_RX_MODE, - [ - RADIO_EVENT_TIMEOUT - ] - = - RADIO_STATE_TIMEOUT, - [ - RADIO_EVENT_ERROR - ] - = - RADIO_STATE_ERROR, - [ - RADIO_EVENT_INITIALIZE - ] - = - RADIO_STATE_INITIALIZING, - [ - RADIO_EVENT_FATAL_ERROR - ] - = - RADIO_STATE_FATAL_ERROR, - }, + }, + [RADIO_STATE_RX_DATA] = { + .entry_fn = radio_rxData, + .next_state = { + [RADIO_EVENT_INT_RECEIVED] = RADIO_STATE_RX_DATA, + [RADIO_EVENT_TX_START] = RADIO_STATE_TX_START, + [RADIO_EVENT_RX_COMPLETE] = RADIO_STATE_TX_START, + [RADIO_EVENT_RX_MODE] = RADIO_STATE_RX_MODE, + [RADIO_EVENT_TIMEOUT] = RADIO_STATE_TIMEOUT, + [RADIO_EVENT_ERROR] = RADIO_STATE_ERROR, + [RADIO_EVENT_INITIALIZE] = RADIO_STATE_INITIALIZING, + [RADIO_EVENT_FATAL_ERROR] = RADIO_STATE_FATAL_ERROR, }, - [ - RADIO_STATE_TX_START - ] - = { - . - entry_fn - = - radio_txStart, - . - next_state - ={ - [ - RADIO_EVENT_INT_RECEIVED - ] - = - RADIO_STATE_TX_DATA, - [ - RADIO_EVENT_RX_MODE - ] - = - RADIO_STATE_RX_MODE, - [ - RADIO_EVENT_TIMEOUT - ] - = - RADIO_STATE_TIMEOUT, - [ - RADIO_EVENT_ERROR - ] - = - RADIO_STATE_ERROR, - [ - RADIO_EVENT_INITIALIZE - ] - = - RADIO_STATE_INITIALIZING, - [ - RADIO_EVENT_FATAL_ERROR - ] - = - RADIO_STATE_FATAL_ERROR, - }, + }, + [RADIO_STATE_TX_START] = { + .entry_fn = radio_txStart, + .next_state = { + [RADIO_EVENT_INT_RECEIVED] = RADIO_STATE_TX_DATA, + [RADIO_EVENT_RX_MODE] = RADIO_STATE_RX_MODE, + [RADIO_EVENT_TIMEOUT] = RADIO_STATE_TIMEOUT, + [RADIO_EVENT_ERROR] = RADIO_STATE_ERROR, + [RADIO_EVENT_INITIALIZE] = RADIO_STATE_INITIALIZING, + [RADIO_EVENT_FATAL_ERROR] = RADIO_STATE_FATAL_ERROR, }, - [ - RADIO_STATE_TX_DATA - ] - = { - . - entry_fn - = - radio_txData, - . - next_state - ={ - [ - RADIO_EVENT_INT_RECEIVED - ] - = - RADIO_STATE_TX_DATA, - [ - RADIO_EVENT_RX_MODE - ] - = - RADIO_STATE_RX_MODE, - [ - RADIO_EVENT_TIMEOUT - ] - = - RADIO_STATE_TIMEOUT, - [ - RADIO_EVENT_ERROR - ] - = - RADIO_STATE_ERROR, - [ - RADIO_EVENT_INITIALIZE - ] - = - RADIO_STATE_INITIALIZING, - [ - RADIO_EVENT_FATAL_ERROR - ] - = - RADIO_STATE_FATAL_ERROR, - }, + }, + [RADIO_STATE_TX_DATA] = { + .entry_fn = radio_txData, + .next_state = { + [RADIO_EVENT_INT_RECEIVED] = RADIO_STATE_TX_DATA, + [RADIO_EVENT_RX_MODE] = RADIO_STATE_RX_MODE, + [RADIO_EVENT_TIMEOUT] = RADIO_STATE_TIMEOUT, + [RADIO_EVENT_ERROR] = RADIO_STATE_ERROR, + [RADIO_EVENT_INITIALIZE] = RADIO_STATE_INITIALIZING, + [RADIO_EVENT_FATAL_ERROR] = RADIO_STATE_FATAL_ERROR, }, - [ - RADIO_STATE_TX_FAILURE - ] - = { - . - entry_fn - = - rfm22_txFailure, - . - next_state - ={ - [ - RADIO_EVENT_TX_START - ] - = - RADIO_STATE_TX_START, - [ - RADIO_EVENT_TIMEOUT - ] - = - RADIO_STATE_TIMEOUT, - [ - RADIO_EVENT_ERROR - ] - = - RADIO_STATE_ERROR, - [ - RADIO_EVENT_INITIALIZE - ] - = - RADIO_STATE_INITIALIZING, - [ - RADIO_EVENT_FATAL_ERROR - ] - = - RADIO_STATE_FATAL_ERROR, - }, + }, + [RADIO_STATE_TX_FAILURE] = { + .entry_fn = rfm22_txFailure, + .next_state = { + [RADIO_EVENT_TX_START] = RADIO_STATE_TX_START, + [RADIO_EVENT_TIMEOUT] = RADIO_STATE_TIMEOUT, + [RADIO_EVENT_ERROR] = RADIO_STATE_ERROR, + [RADIO_EVENT_INITIALIZE] = RADIO_STATE_INITIALIZING, + [RADIO_EVENT_FATAL_ERROR] = RADIO_STATE_FATAL_ERROR, }, - [ - RADIO_STATE_TIMEOUT - ] - = { - . - entry_fn - = - rfm22_timeout, - . - next_state - ={ - [ - RADIO_EVENT_TX_START - ] - = - RADIO_STATE_TX_START, - [ - RADIO_EVENT_RX_MODE - ] - = - RADIO_STATE_RX_MODE, - [ - RADIO_EVENT_ERROR - ] - = - RADIO_STATE_ERROR, - [ - RADIO_EVENT_INITIALIZE - ] - = - RADIO_STATE_INITIALIZING, - [ - RADIO_EVENT_FATAL_ERROR - ] - = - RADIO_STATE_FATAL_ERROR, - }, + }, + [RADIO_STATE_TIMEOUT] = { + .entry_fn = rfm22_timeout, + .next_state = { + [RADIO_EVENT_TX_START] = RADIO_STATE_TX_START, + [RADIO_EVENT_RX_MODE] = RADIO_STATE_RX_MODE, + [RADIO_EVENT_ERROR] = RADIO_STATE_ERROR, + [RADIO_EVENT_INITIALIZE] = RADIO_STATE_INITIALIZING, + [RADIO_EVENT_FATAL_ERROR] = RADIO_STATE_FATAL_ERROR, }, - [ - RADIO_STATE_ERROR - ] - = { - . - entry_fn - = - rfm22_error, - . - next_state - ={ - [ - RADIO_EVENT_INITIALIZE - ] - = - RADIO_STATE_INITIALIZING, - [ - RADIO_EVENT_FATAL_ERROR - ] - = - RADIO_STATE_FATAL_ERROR, - }, - }, - [ - RADIO_STATE_FATAL_ERROR - ] - = { - . - entry_fn - = - rfm22_fatal_error, - . - next_state - = - {}, + }, + [RADIO_STATE_ERROR] = { + .entry_fn = rfm22_error, + .next_state = { + [RADIO_EVENT_INITIALIZE] = RADIO_STATE_INITIALIZING, + [RADIO_EVENT_FATAL_ERROR] = RADIO_STATE_FATAL_ERROR, }, + }, + [RADIO_STATE_FATAL_ERROR] = { + .entry_fn = rfm22_fatal_error, + .next_state = {}, + }, }; -/* - * xtal - * 10 - * ppm, - * 434MHz */ +// xtal 10 ppm, 434MHz static const uint32_t data_rate[] = { - 9600, /* - * 96 - * kbps, - * 433 - * HMz, - * 30 - * khz - * freq - * dev */ - 19200, /* - * 19.2 - * kbps, - * 433 - * MHz, - * 45 - * khz - * freq - * dev */ - 32000, /* - * 32 - * kbps, - * 433 - * MHz, - * 45 - * khz - * freq - * dev */ - 57600, /* - * 57.6 - * kbps, - * 433 - * MHz, - * 45 - * khz - * freq - * dev */ - 64000, /* - * 64 - * kbps, - * 433 - * MHz, - * 45 - * khz - * freq - * dev */ - 100000, /* - * 100 - * kbps, - * 433 - * MHz, - * 60 - * khz - * freq - * dev */ - 128000, /* - * 128 - * kbps, - * 433 - * MHz, - * 90 - * khz - * freq - * dev */ - 192000, /* - * 192 - * kbps, - * 433 - * MHz, - * 128 - * khz - * freq - * dev */ - 256000, /* - * 256 - * kbps, - * 433 - * MHz, - * 150 - * khz - * freq - * dev */ + 9600, // 96 kbps, 433 HMz, 30 khz freq dev + 19200, // 19.2 kbps, 433 MHz, 45 khz freq dev + 32000, // 32 kbps, 433 MHz, 45 khz freq dev + 57600, // 57.6 kbps, 433 MHz, 45 khz freq dev + 64000, // 64 kbps, 433 MHz, 45 khz freq dev + 100000, // 100 kbps, 433 MHz, 60 khz freq dev + 128000, // 128 kbps, 433 MHz, 90 khz freq dev + 192000, // 192 kbps, 433 MHz, 128 khz freq dev + 256000, // 256 kbps, 433 MHz, 150 khz freq dev }; -static const uint8_t reg_1C[] = { 0x01, 0x05, 0x06, 0x95, 0x95, 0x81, 0x88, 0x8B, 0x8D }; /* - * rfm22_if_filter_bandwidth */ -static const uint8_t reg_1D[] = { 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40 }; /* - * rfm22_afc_loop_gearshift_override */ -static const uint8_t reg_1E[] = { 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x02 }; /* - * rfm22_afc_timing_control */ -static const uint8_t reg_1F[] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }; /* - * rfm22_clk_recovery_gearshift_override */ -static const uint8_t reg_20[] = { 0xA1, 0xD0, 0x7D, 0x68, 0x5E, 0x78, 0x5E, 0x3F, 0x2F }; /* - * rfm22_clk_recovery_oversampling_ratio */ -static const uint8_t reg_21[] = { 0x20, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02 }; /* - * rfm22_clk_recovery_offset2 */ -static const uint8_t reg_22[] = { 0x4E, 0x9D, 0x06, 0x3A, 0x5D, 0x11, 0x5D, 0x0C, 0xBB }; /* - * rfm22_clk_recovery_offset1 */ -static const uint8_t reg_23[] = { 0xA5, 0x49, 0x25, 0x93, 0x86, 0x11, 0x86, 0x4A, 0x0D }; /* - * rfm22_clk_recovery_offset0 */ -static const uint8_t reg_24[] = { 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x06, 0x07 }; /* - * rfm22_clk_recovery_timing_loop_gain1 */ -static const uint8_t reg_25[] = { 0x34, 0x88, 0x77, 0x29, 0xE2, 0x90, 0xE2, 0x1A, 0xFF }; /* - * rfm22_clk_recovery_timing_loop_gain0 */ -static const uint8_t reg_2A[] = { 0x1E, 0x24, 0x28, 0x3C, 0x3C, 0x50, 0x50, 0x50, 0x50 }; /* - * rfm22_afc_limiter - * .. - * AFC_pull_in_range - * = - * �AFCLimiter[7:0] - * x - * (hbsel+1) - * x - * 625 - * Hz */ -static const uint8_t reg_58[] = { 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xED }; /* - * rfm22_cpcuu */ -static const uint8_t reg_69[] = { 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60 }; /* - * rfm22_agc_override1 */ -static const uint8_t reg_6E[] = { 0x4E, 0x9D, 0x08, 0x0E, 0x10, 0x19, 0x20, 0x31, 0x41 }; /* - * rfm22_tx_data_rate1 */ -static const uint8_t reg_6F[] = { 0xA5, 0x49, 0x31, 0xBF, 0x62, 0x9A, 0xC5, 0x27, 0x89 }; /* - * rfm22_tx_data_rate0 */ -static const uint8_t reg_70[] = { 0x2C, 0x2C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C }; /* - * rfm22_modulation_mode_control1 */ -static const uint8_t reg_71[] = { 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23 }; /* - * rfm22_modulation_mode_control2 */ -static const uint8_t reg_72[] = { 0x30, 0x48, 0x48, 0x48, 0x48, 0x60, 0x90, 0xCD, 0x0F }; /* - * rfm22_frequency_deviation */ + +static const uint8_t reg_1C[] = { 0x01, 0x05, 0x06, 0x95, 0x95, 0x81, 0x88, 0x8B, 0x8D }; // rfm22_if_filter_bandwidth + +static const uint8_t reg_1D[] = { 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40 }; // rfm22_afc_loop_gearshift_override +static const uint8_t reg_1E[] = { 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x02 }; // rfm22_afc_timing_control + +static const uint8_t reg_1F[] = { 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }; // rfm22_clk_recovery_gearshift_override +static const uint8_t reg_20[] = { 0xA1, 0xD0, 0x7D, 0x68, 0x5E, 0x78, 0x5E, 0x3F, 0x2F }; // rfm22_clk_recovery_oversampling_ratio +static const uint8_t reg_21[] = { 0x20, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02 }; // rfm22_clk_recovery_offset2 +static const uint8_t reg_22[] = { 0x4E, 0x9D, 0x06, 0x3A, 0x5D, 0x11, 0x5D, 0x0C, 0xBB }; // rfm22_clk_recovery_offset1 +static const uint8_t reg_23[] = { 0xA5, 0x49, 0x25, 0x93, 0x86, 0x11, 0x86, 0x4A, 0x0D }; // rfm22_clk_recovery_offset0 +static const uint8_t reg_24[] = { 0x00, 0x00, 0x01, 0x03, 0x03, 0x03, 0x03, 0x06, 0x07 }; // rfm22_clk_recovery_timing_loop_gain1 +static const uint8_t reg_25[] = { 0x34, 0x88, 0x77, 0x29, 0xE2, 0x90, 0xE2, 0x1A, 0xFF }; // rfm22_clk_recovery_timing_loop_gain0 + +static const uint8_t reg_2A[] = { 0x1E, 0x24, 0x28, 0x3C, 0x3C, 0x50, 0x50, 0x50, 0x50 }; // rfm22_afc_limiter .. AFC_pull_in_range = �AFCLimiter[7:0] x (hbsel+1) x 625 Hz + +static const uint8_t reg_58[] = { 0x80, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0xC0, 0xED }; // rfm22_cpcuu +static const uint8_t reg_69[] = { 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60 }; // rfm22_agc_override1 +static const uint8_t reg_6E[] = { 0x4E, 0x9D, 0x08, 0x0E, 0x10, 0x19, 0x20, 0x31, 0x41 }; // rfm22_tx_data_rate1 +static const uint8_t reg_6F[] = { 0xA5, 0x49, 0x31, 0xBF, 0x62, 0x9A, 0xC5, 0x27, 0x89 }; // rfm22_tx_data_rate0 + +static const uint8_t reg_70[] = { 0x2C, 0x2C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C }; // rfm22_modulation_mode_control1 +static const uint8_t reg_71[] = { 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23 }; // rfm22_modulation_mode_control2 + +static const uint8_t reg_72[] = { 0x30, 0x48, 0x48, 0x48, 0x48, 0x60, 0x90, 0xCD, 0x0F }; // rfm22_frequency_deviation + static const uint8_t packet_time[] = { 80, 40, 25, 15, 13, 10, 8, 6, 5 }; static const uint8_t packet_time_ppm[] = { 26, 25, 25, 15, 13, 10, 8, 6, 5 }; static const uint8_t num_channels[] = { 4, 4, 4, 6, 8, 8, 10, 12, 16 }; + static struct pios_rfm22b_dev *g_rfm22b_dev = NULL; /***************************************************************************** -* -* External -* Interface -* Functions +* External Interface Functions *****************************************************************************/ /** + * Initialise an RFM22B device * - * Initialise - * an - * RFM22B - * device - * - * - * @param[out] - * rfm22b_id - * - * A - * pointer - * to - * store - * the - * device - * ID - * in. - * - * @param[in] - * spi_id - * - * The - * SPI - * bus - * index. - * - * @param[in] - * slave_num - * - * The - * SPI - * bus - * slave - * number. - * - * @param[in] - * cfg - * - * The - * device - * configuration. + * @param[out] rfm22b_id A pointer to store the device ID in. + * @param[in] spi_id The SPI bus index. + * @param[in] slave_num The SPI bus slave number. + * @param[in] cfg The device configuration. */ -int32_t PIOS_RFM22B_Init( - uint32_t - * - rfm22b_id, - uint32_t - spi_id, - uint32_t - slave_num, - const - struct - pios_rfm22b_cfg - *cfg) +int32_t PIOS_RFM22B_Init(uint32_t *rfm22b_id, uint32_t spi_id, uint32_t slave_num, const struct pios_rfm22b_cfg *cfg) { PIOS_DEBUG_Assert(rfm22b_id); PIOS_DEBUG_Assert(cfg); - - /* - * Allocate - * the - * device - * structure. */ + // Allocate the device structure. struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)pios_rfm22_alloc(); - - if (!rfm22b_dev) { return -1; } - *rfm22b_id = (uint32_t)rfm22b_dev; g_rfm22b_dev = rfm22b_dev; - /* - * Store - * the - * SPI - * handle */ + // Store the SPI handle rfm22b_dev->slave_num = slave_num; rfm22b_dev->spi_id = spi_id; - /* - * Initialize - * our - * configuration - * parameters */ + // Initialize our configuration parameters rfm22b_dev->datarate = RFM22B_DEFAULT_RX_DATARATE; rfm22b_dev->tx_power = RFM22B_DEFAULT_TX_POWER; rfm22b_dev->coordinator = false; rfm22b_dev->coordinatorID = 0; - /* - * Initialize - * the - * com - * callbacks. */ + // Initialize the com callbacks. rfm22b_dev->rx_in_cb = NULL; rfm22b_dev->tx_out_cb = NULL; - /* - * Initialzie - * the - * PPM - * callback. */ + // Initialzie the PPM callback. rfm22b_dev->ppm_callback = NULL; - /* - * Initialize - * the - * stats. */ + // Initialize the stats. rfm22b_dev->stats.packets_per_sec = 0; rfm22b_dev->stats.rx_good = 0; rfm22b_dev->stats.rx_corrected = 0; @@ -1513,301 +404,103 @@ int32_t PIOS_RFM22B_Init( rfm22b_dev->stats.rx_seq = 0; rfm22b_dev->stats.tx_failure = 0; - /* - * Initialize - * the - * channels. */ + // Initialize the channels. PIOS_RFM22B_SetChannelConfig(*rfm22b_id, RFM22B_DEFAULT_RX_DATARATE, RFM22B_DEFAULT_MIN_CHANNEL, RFM22B_DEFAULT_MAX_CHANNEL, RFM22B_DEFAULT_CHANNEL_SET, false, false, false, false); - /* - * Create - * the - * event - * queue */ + // Create the event queue rfm22b_dev->eventQueue = xQueueCreate(EVENT_QUEUE_SIZE, sizeof(enum pios_radio_event)); - /* - * Bind - * the - * configuration - * to - * the - * device - * instance */ + // Bind the configuration to the device instance rfm22b_dev->cfg = *cfg; - /* - * Create - * a - * semaphore - * to - * know - * if - * an - * ISR - * needs - * responding - * to */ + // Create a semaphore to know if an ISR needs responding to vSemaphoreCreateBinary(rfm22b_dev->isrPending); - - /* - * Create - * our - * (hopefully) - * unique - * 32 - * bit - * id - * from - * the - * processor - * serial - * number. */ + // Create our (hopefully) unique 32 bit id from the processor serial number. uint8_t crcs[] = { 0, 0, 0, 0 }; { char serial_no_str[33]; - - - PIOS_SYS_SerialNumberGet( - serial_no_str); - - /* - * Create - * a - * 32 - * bit - * value - * using - * 4 - * 8 - * bit - * CRC - * values. */ - for ( - uint8_t - i - = - 0; - serial_no_str - [ - i - ] - != - 0; - ++ - i) { - crcs - [ - i - % - 4 - ] - = - PIOS_CRC_updateByte( - crcs - [ - i - % - 4 - ], - serial_no_str - [ - i - ]); + PIOS_SYS_SerialNumberGet(serial_no_str); + // Create a 32 bit value using 4 8 bit CRC values. + for (uint8_t i = 0; serial_no_str[i] != 0; ++i) { + crcs[i % 4] = PIOS_CRC_updateByte(crcs[i % 4], serial_no_str[i]); } } - - rfm22b_dev->deviceID = crcs[0] | crcs[1] << 8 | crcs[2] << 16 | crcs[3] << 24; DEBUG_PRINTF(2, "RF device ID: %x\n\r", rfm22b_dev->deviceID); - /* - * Initialize - * the - * external - * interrupt. */ + // Initialize the external interrupt. PIOS_EXTI_Init(cfg->exti_cfg); - /* - * Register - * the - * watchdog - * timer - * for - * the - * radio - * driver - * task */ + // Register the watchdog timer for the radio driver task #if defined(PIOS_INCLUDE_WDG) && defined(PIOS_WDG_RFM22B) - PIOS_WDG_RegisterFlag( - PIOS_WDG_RFM22B); + PIOS_WDG_RegisterFlag(PIOS_WDG_RFM22B); #endif /* PIOS_WDG_RFM22B */ - /* - * Initialize - * the - * ECC - * library. */ + // Initialize the ECC library. initialize_ecc(); - /* - * Set - * the - * state - * to - * initializing. */ + // Set the state to initializing. rfm22b_dev->state = RADIO_STATE_UNINITIALIZED; - /* - * Initialize - * the - * radio - * device. */ + // Initialize the radio device. pios_rfm22_inject_event(rfm22b_dev, RADIO_EVENT_INITIALIZE, false); - /* - * Start - * the - * driver - * task. - * - * This - * task - * controls - * the - * radio - * state - * machine - * and - * removed - * all - * of - * the - * IO - * from - * the - * IRQ - * handler. */ - xTaskCreate(pios_rfm22_task, (signedchar *)"PIOS_RFM22B_Task", STACK_SIZE_BYTES, (void *)rfm22b_dev, TASK_PRIORITY, &(rfm22b_dev->taskHandle)); + // Start the driver task. This task controls the radio state machine and removed all of the IO from the IRQ handler. + xTaskCreate(pios_rfm22_task, (signed char *)"PIOS_RFM22B_Task", STACK_SIZE_BYTES, (void *)rfm22b_dev, TASK_PRIORITY, &(rfm22b_dev->taskHandle)); return 0; } /** + * Re-initialize the modem after a configuration change. * - * Re-initialize - * the - * modem - * after - * a - * configuration - * change. - * - * - * @param[in] - * rbm22b_id - * - * The - * RFM22B - * device - * ID. + * @param[in] rbm22b_id The RFM22B device ID. */ -void PIOS_RFM22B_Reinit(uint32_trfm22b_id) +void PIOS_RFM22B_Reinit(uint32_t rfm22b_id) { struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; - if (PIOS_RFM22B_Validate(rfm22b_dev)) { pios_rfm22_inject_event(rfm22b_dev, RADIO_EVENT_INITIALIZE, false); } } /** - * - * The - * RFM22B - * external - * interrupt - * routine. + * The RFM22B external interrupt routine. */ -bool PIOS_RFM22_EXT_Int(void) +bool PIOS_RFM22_EXT_Int(void) { if (!PIOS_RFM22B_Validate(g_rfm22b_dev)) { return false; } - /* - * Inject - * an - * interrupt - * event - * into - * the - * state - * machine. */ + // Inject an interrupt event into the state machine. pios_rfm22_inject_event(g_rfm22b_dev, RADIO_EVENT_INT_RECEIVED, true); - return false; } /** + * Returns the unique device ID for the RFM22B device. * - * Returns - * the - * unique - * device - * ID - * for - * the - * RFM22B - * device. - * - * - * @param[in] - * rfm22b_id - * The - * RFM22B - * device - * index. - * - * @return - * The - * unique - * device - * ID + * @param[in] rfm22b_id The RFM22B device index. + * @return The unique device ID */ -uint32_t PIOS_RFM22B_DeviceID(uint32_trfm22b_id) +uint32_t PIOS_RFM22B_DeviceID(uint32_t rfm22b_id) { struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; - if (PIOS_RFM22B_Validate(rfm22b_dev)) { return rfm22b_dev->deviceID; } - return 0; } - /** + * Are we connected to the remote modem? * - * Are - * we - * connected - * to - * the - * remote - * modem? - * - * - * @param[in] - * rfm22b_dev - * - * The - * device - * structure + * @param[in] rfm22b_dev The device structure */ static bool rfm22_isConnected(struct pios_rfm22b_dev *rfm22b_dev) { @@ -1815,241 +508,59 @@ static bool rfm22_isConnected(struct pios_rfm22b_dev *rfm22b_dev) } /** + * Returns true if the modem is not actively sending or receiving a packet. * - * Returns - * true - * if - * the - * modem - * is - * not - * actively - * sending - * or - * receiving - * a - * packet. - * - * - * @param[in] - * rfm22b_id - * The - * RFM22B - * device - * index. - * - * @return - * True - * if - * the - * modem - * is - * not - * actively - * sending - * or - * receiving - * a - * packet. + * @param[in] rfm22b_id The RFM22B device index. + * @return True if the modem is not actively sending or receiving a packet. */ -bool PIOS_RFM22B_InRxWait(uint32_trfm22b_id) +bool PIOS_RFM22B_InRxWait(uint32_t rfm22b_id) { struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; if (PIOS_RFM22B_Validate(rfm22b_dev)) { return (rfm22b_dev->rfm22b_state == RFM22B_STATE_RX_WAIT) || (rfm22b_dev->rfm22b_state == RFM22B_STATE_TRANSITION); } - return false; } /** + * Sets the radio device transmit power. * - * Sets - * the - * radio - * device - * transmit - * power. - * - * - * @param[in] - * rfm22b_id - * The - * RFM22B - * device - * index. - * - * @param[in] - * tx_pwr - * The - * transmit - * power. + * @param[in] rfm22b_id The RFM22B device index. + * @param[in] tx_pwr The transmit power. */ -void PIOS_RFM22B_SetTxPower( - uint32_t - rfm22b_id, - enum - rfm22b_tx_power - tx_pwr) +void PIOS_RFM22B_SetTxPower(uint32_t rfm22b_id, enum rfm22b_tx_power tx_pwr) { struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; if (!PIOS_RFM22B_Validate(rfm22b_dev)) { return; } - rfm22b_dev->tx_power = tx_pwr; } /** + * Sets the range and number of channels to use for the radio. + * The channels are 0 to 255 divided across the 430-440 MHz range. + * The number of channels configured will be spread across the selected channel range. + * The channel spacing is 10MHz / 250 = 40kHz * - * Sets - * the - * range - * and - * number - * of - * channels - * to - * use - * for - * the - * radio. - * - * The - * channels - * are - * 0 - * to - * 255 - * divided - * across - * the - * 430-440 - * MHz - * range. - * - * The - * number - * of - * channels - * configured - * will - * be - * spread - * across - * the - * selected - * channel - * range. - * - * The - * channel - * spacing - * is - * 10MHz - * / - * 250 - * = - * 40kHz - * - * - * @param[in] - * rfm22b_id - * - * The - * RFM22B - * device - * index. - * - * @param[in] - * datarate - * - * The - * desired - * datarate. - * - * @param[in] - * min_chan - * - * The - * minimum - * channel. - * - * @param[in] - * max_chan - * - * The - * maximum - * channel. - * - * @param[in] - * chan_set - * - * The - * "seed" - * for - * selecting - * a - * channel - * sequence. - * - * @param[in] - * coordinator - * Is - * this - * modem - * an - * coordinator. - * - * @param[in] - * ppm_mode - * Should - * this - * modem - * send/receive - * ppm - * packets? - * - * @param[in] - * oneway - * Only - * the - * coordinator - * can - * send - * packets - * if - * true. + * @param[in] rfm22b_id The RFM22B device index. + * @param[in] datarate The desired datarate. + * @param[in] min_chan The minimum channel. + * @param[in] max_chan The maximum channel. + * @param[in] chan_set The "seed" for selecting a channel sequence. + * @param[in] coordinator Is this modem an coordinator. + * @param[in] ppm_mode Should this modem send/receive ppm packets? + * @param[in] oneway Only the coordinator can send packets if true. */ -void PIOS_RFM22B_SetChannelConfig( - uint32_t - rfm22b_id, - enum - rfm22b_datarate - datarate, - uint8_t - min_chan, - uint8_t - max_chan, - uint8_t - chan_set, - bool - coordinator, - bool - oneway, - bool - ppm_mode, - bool - ppm_only) +void PIOS_RFM22B_SetChannelConfig(uint32_t rfm22b_id, enum rfm22b_datarate datarate, uint8_t min_chan, uint8_t max_chan, uint8_t chan_set, bool coordinator, bool oneway, bool ppm_mode, bool ppm_only) { struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; if (!PIOS_RFM22B_Validate(rfm22b_dev)) { return; } - ppm_mode = ppm_mode || ppm_only; rfm22b_dev->coordinator = coordinator; rfm22b_dev->ppm_send_mode = ppm_mode && coordinator; @@ -2057,7 +568,6 @@ void PIOS_RFM22B_SetChannelConfig( if (ppm_mode && (datarate <= RFM22B_PPM_ONLY_DATARATE)) { ppm_only = true; } - rfm22b_dev->ppm_only_mode = ppm_only; if (ppm_only) { rfm22b_dev->one_way_link = true; @@ -2067,53 +577,21 @@ void PIOS_RFM22B_SetChannelConfig( rfm22b_dev->one_way_link = oneway; rfm22b_dev->datarate = datarate; } - rfm22b_dev->packet_time = (ppm_mode ? packet_time_ppm[datarate] : packet_time[datarate]); - - /* - * Find - * the - * first - * N - * channels - * that - * meet - * the - * min/max - * criteria - * out - * of - * the - * random - * channel - * list. */ + // Find the first N channels that meet the min/max criteria out of the random channel list. uint8_t num_found = 0; - - for (uint16_t i = 0; (i < RFM22B_NUM_CHANNELS) && (num_found < num_channels[datarate]); ++i) { uint8_t idx = (i + chan_set) % RFM22B_NUM_CHANNELS; uint8_t chan = channel_list[idx]; - - if ((chan >= min_chan) && (chan <= max_chan)) { rfm22b_dev->channels[num_found++] = chan; } } - - /* - * Calculate - * the - * maximum - * packet - * length - * from - * the - * datarate. */ + // Calculate the maximum packet length from the datarate. float bytes_per_period = (float)data_rate[datarate] * (float)(rfm22b_dev->packet_time - 2) / 9000; - rfm22b_dev->max_packet_len = bytes_per_period - TX_PREAMBLE_NIBBLES / 2 - SYNC_BYTES - HEADER_BYTES - LENGTH_BYTES; if (rfm22b_dev->max_packet_len > RFM22B_MAX_PACKET_LEN) { rfm22b_dev->max_packet_len = RFM22B_MAX_PACKET_LEN; @@ -2121,43 +599,12 @@ void PIOS_RFM22B_SetChannelConfig( } /** + * Set a modem to be a coordinator or not. * - * Set - * a - * modem - * to - * be - * a - * coordinator - * or - * not. - * - * - * @param[in] - * rfm22b_id - * The - * RFM22B - * device - * index. - * - * @param[in] - * coordinator - * If - * true, - * this - * modem - * will - * be - * configured - * as - * a - * coordinator. + * @param[in] rfm22b_id The RFM22B device index. + * @param[in] coordinator If true, this modem will be configured as a coordinator. */ -extern void PIOS_RFM22B_SetCoordinator( - uint32_t - rfm22b_id, - bool - coordinator) +extern void PIOS_RFM22B_SetCoordinator(uint32_t rfm22b_id, bool coordinator) { struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; @@ -2167,32 +614,12 @@ extern void PIOS_RFM22B_SetCoordinator( } /** + * Sets the device coordinator ID. * - * Sets - * the - * device - * coordinator - * ID. - * - * - * @param[in] - * rfm22b_id - * The - * RFM22B - * device - * index. - * - * @param[in] - * coord_id - * The - * coordinator - * ID. + * @param[in] rfm22b_id The RFM22B device index. + * @param[in] coord_id The coordinator ID. */ -void PIOS_RFM22B_SetCoordinatorID( - uint32_t - rfm22b_id, - uint32_t - coord_id) +void PIOS_RFM22B_SetCoordinatorID(uint32_t rfm22b_id, uint32_t coord_id) { struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; @@ -2202,39 +629,12 @@ void PIOS_RFM22B_SetCoordinatorID( } /** + * Returns the device statistics RFM22B device. * - * Returns - * the - * device - * statistics - * RFM22B - * device. - * - * - * @param[in] - * rfm22b_id - * The - * RFM22B - * device - * index. - * - * @param[out] - * stats - * The - * stats - * are - * returned - * in - * this - * structure + * @param[in] rfm22b_id The RFM22B device index. + * @param[out] stats The stats are returned in this structure */ -void PIOS_RFM22B_GetStats( - uint32_t - rfm22b_id, - struct - rfm22b_stats - * - stats) +void PIOS_RFM22B_GetStats(uint32_t rfm22b_id, struct rfm22b_stats *stats) { struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; @@ -2242,98 +642,22 @@ void PIOS_RFM22B_GetStats( return; } - /* - * Calculate - * the - * current - * link - * quality */ + // Calculate the current link quality rfm22_calculateLinkQuality(rfm22b_dev); - /* - * Return - * the - * stats. */ + // Return the stats. *stats = rfm22b_dev->stats; } /** + * Get the stats of the oter radio devices that are in range. * - * Get - * the - * stats - * of - * the - * oter - * radio - * devices - * that - * are - * in - * range. - * - * - * @param[out] - * device_ids - * - * A - * pointer - * to - * the - * array - * to - * store - * the - * device - * IDs. - * - * @param[out] - * RSSIs - * - * A - * pointer - * to - * the - * array - * to - * store - * the - * RSSI - * values - * in. - * - * @param[in] - * mx_pairs - * - * The - * length - * of - * the - * pdevice_ids - * and - * RSSIs - * arrays. - * - * @return - * - * The - * number - * of - * pair - * stats - * returned. + * @param[out] device_ids A pointer to the array to store the device IDs. + * @param[out] RSSIs A pointer to the array to store the RSSI values in. + * @param[in] mx_pairs The length of the pdevice_ids and RSSIs arrays. + * @return The number of pair stats returned. */ -uint8_t PIOS_RFM2B_GetPairStats( - uint32_t - rfm22b_id, - uint32_t - * - device_ids, - int8_t - * - RSSIs, - uint8_t - max_pairs) +uint8_t PIOS_RFM2B_GetPairStats(uint32_t rfm22b_id, uint32_t *device_ids, int8_t *RSSIs, uint8_t max_pairs) { struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; @@ -2341,240 +665,99 @@ uint8_t PIOS_RFM2B_GetPairStats( return 0; } - uint8_t mp = (max_pairs >= OPLINKSTATUS_PAIRIDS_NUMELEM) ? max_pairs : OPLINKSTATUS_PAIRIDS_NUMELEM; - - for (uint8_t i = 0; i < mp; ++i) { device_ids[i] = rfm22b_dev->pair_stats[i].pairID; RSSIs[i] = rfm22b_dev->pair_stats[i].rssi; } + return mp; } /** + * Check the radio device for a valid connection * - * Check - * the - * radio - * device - * for - * a - * valid - * connection - * - * - * @param[in] - * rfm22b_id - * - * The - * rfm22b - * device. - * - * @return - * true - * if - * there - * is - * a - * valid - * connection - * to - * paired - * radio, - * false - * otherwise. + * @param[in] rfm22b_id The rfm22b device. + * @return true if there is a valid connection to paired radio, false otherwise. */ -bool PIOS_RFM22B_LinkStatus(uint32_trfm22b_id) +bool PIOS_RFM22B_LinkStatus(uint32_t rfm22b_id) { struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; if (!PIOS_RFM22B_Validate(rfm22b_dev)) { return false; } - return rfm22b_dev->stats.link_quality > RFM22B_LINK_QUALITY_THRESHOLD; } /** + * Put the RFM22B device into receive mode. * - * Put - * the - * RFM22B - * device - * into - * receive - * mode. - * - * - * @param[in] - * rfm22b_id - * - * The - * rfm22b - * device. - * - * @param[in] - * p - * - * The - * packet - * to - * receive - * into. - * - * @return - * true - * if - * Rx - * mode - * was - * entered - * sucessfully. + * @param[in] rfm22b_id The rfm22b device. + * @param[in] p The packet to receive into. + * @return true if Rx mode was entered sucessfully. */ -bool PIOS_RFM22B_ReceivePacket( - uint32_t - rfm22b_id, - uint8_t - * - p) +bool PIOS_RFM22B_ReceivePacket(uint32_t rfm22b_id, uint8_t *p) { struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; if (!PIOS_RFM22B_Validate(rfm22b_dev)) { return false; } - rfm22b_dev->rx_packet_handle = p; - /* - * Claim - * the - * SPI - * bus. */ + // Claim the SPI bus. rfm22_claimBus(rfm22b_dev); - /* - * disable - * interrupts */ + // disable interrupts rfm22_write(rfm22b_dev, RFM22_interrupt_enable1, 0x00); rfm22_write(rfm22b_dev, RFM22_interrupt_enable2, 0x00); - /* - * Switch - * to - * TUNE - * mode */ + // Switch to TUNE mode rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl1, RFM22_opfc1_pllon); #ifdef PIOS_RFM22B_DEBUG_ON_TELEM D2_LED_OFF; -#endif /* - * PIOS_RFM22B_DEBUG_ON_TELEM */ +#endif // PIOS_RFM22B_DEBUG_ON_TELEM RX_LED_OFF; TX_LED_OFF; - /* - * empty - * the - * rx - * buffer */ + // empty the rx buffer rfm22b_dev->rx_buffer_wr = 0; - /* - * Clear - * the - * TX - * buffer. */ + // Clear the TX buffer. rfm22b_dev->tx_data_rd = rfm22b_dev->tx_data_wr = 0; - /* - * clear - * FIFOs */ + // clear FIFOs rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl2, RFM22_opfc2_ffclrrx | RFM22_opfc2_ffclrtx); rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl2, 0x00); - /* - * enable - * RX - * interrupts */ + // enable RX interrupts rfm22_write(rfm22b_dev, RFM22_interrupt_enable1, RFM22_ie1_encrcerror | RFM22_ie1_enpkvalid | RFM22_ie1_enrxffafull | RFM22_ie1_enfferr); rfm22_write(rfm22b_dev, RFM22_interrupt_enable2, RFM22_ie2_enpreainval | RFM22_ie2_enpreaval | RFM22_ie2_enswdet); - /* - * enable - * the - * receiver */ + // enable the receiver rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl1, RFM22_opfc1_pllon | RFM22_opfc1_rxon); - /* - * Release - * the - * SPI - * bus. */ + // Release the SPI bus. rfm22_releaseBus(rfm22b_dev); - /* - * Indicate - * that - * we're - * in - * RX - * wait - * mode. */ + // Indicate that we're in RX wait mode. rfm22b_dev->rfm22b_state = RFM22B_STATE_RX_WAIT; return true; } /** + * Transmit a packet via the RFM22B device. * - * Transmit - * a - * packet - * via - * the - * RFM22B - * device. - * - * - * @param[in] - * rfm22b_id - * - * The - * rfm22b - * device. - * - * @param[in] - * p - * - * The - * packet - * to - * transmit. - * - * @return - * true - * if - * there - * if - * the - * packet - * was - * queued - * for - * transmission. + * @param[in] rfm22b_id The rfm22b device. + * @param[in] p The packet to transmit. + * @return true if there if the packet was queued for transmission. */ -bool PIOS_RFM22B_TransmitPacket( - uint32_t - rfm22b_id, - uint8_t - * - p, - uint8_t - len) +bool PIOS_RFM22B_TransmitPacket(uint32_t rfm22b_id, uint8_t *p, uint8_t len) { struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; @@ -2589,147 +772,63 @@ bool PIOS_RFM22B_TransmitPacket( rfm22b_dev->packet_start_ticks = 1; } - /* - * Claim - * the - * SPI - * bus. */ + // Claim the SPI bus. rfm22_claimBus(rfm22b_dev); - /* - * Disable - * interrupts */ + // Disable interrupts rfm22_write(rfm22b_dev, RFM22_interrupt_enable1, 0x00); rfm22_write(rfm22b_dev, RFM22_interrupt_enable2, 0x00); - /* - * set - * the - * tx - * power */ + // set the tx power rfm22b_dev->tx_power = 0x7; rfm22_write(rfm22b_dev, RFM22_tx_power, RFM22_tx_pwr_lna_sw | rfm22b_dev->tx_power); - /* - * TUNE - * mode */ + // TUNE mode rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl1, RFM22_opfc1_pllon); - /* - * Queue - * the - * data - * up - * for - * sending */ + // Queue the data up for sending rfm22b_dev->tx_data_wr = len; RX_LED_OFF; - - /* - * Set - * the - * destination - * address - * in - * the - * transmit - * header. */ + // Set the destination address in the transmit header. uint32_t id = rfm22_destinationID(rfm22b_dev); - - rfm22_write(rfm22b_dev, RFM22_transmit_header0, id & 0xff); rfm22_write(rfm22b_dev, RFM22_transmit_header1, (id >> 8) & 0xff); rfm22_write(rfm22b_dev, RFM22_transmit_header2, (id >> 16) & 0xff); rfm22_write(rfm22b_dev, RFM22_transmit_header3, (id >> 24) & 0xff); - - /* - * FIFO - * mode, - * GFSK - * modulation */ + // FIFO mode, GFSK modulation uint8_t fd_bit = rfm22_read(rfm22b_dev, RFM22_modulation_mode_control2) & RFM22_mmc2_fd; - - rfm22_write(rfm22b_dev, RFM22_modulation_mode_control2, fd_bit | RFM22_mmc2_dtmod_fifo | RFM22_mmc2_modtyp_gfsk); - /* - * Clear - * the - * FIFOs. */ + // Clear the FIFOs. rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl2, RFM22_opfc2_ffclrrx | RFM22_opfc2_ffclrtx); rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl2, 0x00); - /* - * Set - * the - * total - * number - * of - * data - * bytes - * we - * are - * going - * to - * transmit. */ + // Set the total number of data bytes we are going to transmit. rfm22_write(rfm22b_dev, RFM22_transmit_packet_length, len); - - /* - * Add - * some - * data - * to - * the - * chips - * TX - * FIFO - * before - * enabling - * the - * transmitter */ + // Add some data to the chips TX FIFO before enabling the transmitter uint8_t *tx_buffer = rfm22b_dev->tx_packet_handle; - - rfm22_assertCs(rfm22b_dev); PIOS_SPI_TransferByte(rfm22b_dev->spi_id, RFM22_fifo_access | 0x80); - - int bytes_to_write = (rfm22b_dev->tx_data_wr - rfm22b_dev->tx_data_rd); - - bytes_to_write = (bytes_to_write > FIFO_SIZE) ? FIFO_SIZE : bytes_to_write; PIOS_SPI_TransferBlock(rfm22b_dev->spi_id, &tx_buffer[rfm22b_dev->tx_data_rd], NULL, bytes_to_write, NULL); rfm22b_dev->tx_data_rd += bytes_to_write; rfm22_deassertCs(rfm22b_dev); - /* - * Enable - * TX - * interrupts. */ + // Enable TX interrupts. rfm22_write(rfm22b_dev, RFM22_interrupt_enable1, RFM22_ie1_enpksent | RFM22_ie1_entxffaem); - /* - * Enable - * the - * transmitter. */ + // Enable the transmitter. rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl1, RFM22_opfc1_pllon | RFM22_opfc1_txon); - /* - * Release - * the - * SPI - * bus. */ + // Release the SPI bus. rfm22_releaseBus(rfm22b_dev); - /* - * We're - * in - * Tx - * mode. */ + // We're in Tx mode. rfm22b_dev->rfm22b_state = RFM22B_STATE_TX_MODE; TX_LED_ON; @@ -2742,78 +841,33 @@ bool PIOS_RFM22B_TransmitPacket( } /** + * Process a Tx interrupt from the RFM22B device. * - * Process - * a - * Tx - * interrupt - * from - * the - * RFM22B - * device. - * - * - * @param[in] - * rfm22b_id - * - * The - * rfm22b - * device. - * - * @return - * PIOS_RFM22B_TX_COMPLETE - * on - * completed - * Tx, - * or - * PIOS_RFM22B_INT_SUCCESS/PIOS_RFM22B_INT_FAILURE. + * @param[in] rfm22b_id The rfm22b device. + * @return PIOS_RFM22B_TX_COMPLETE on completed Tx, or PIOS_RFM22B_INT_SUCCESS/PIOS_RFM22B_INT_FAILURE. */ -pios_rfm22b_int_result PIOS_RFM22B_ProcessTx(uint32_trfm22b_id) +pios_rfm22b_int_result PIOS_RFM22B_ProcessTx(uint32_t rfm22b_id) { struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; if (!PIOS_RFM22B_Validate(rfm22b_dev)) { return PIOS_RFM22B_INT_FAILURE; } - /* - * Read - * the - * device - * status - * registers */ + + // Read the device status registers if (!pios_rfm22_readStatus(rfm22b_dev)) { return PIOS_RFM22B_INT_FAILURE; } - /* - * TX - * FIFO - * almost - * empty, - * it - * needs - * filling - * up */ + + // TX FIFO almost empty, it needs filling up if (rfm22b_dev->status_regs.int_status_1.tx_fifo_almost_empty) { - /* - * Add - * data - * to - * the - * TX - * FIFO - * buffer */ + // Add data to the TX FIFO buffer uint8_t *tx_buffer = rfm22b_dev->tx_packet_handle; uint16_t max_bytes = FIFO_SIZE - TX_FIFO_LO_WATERMARK - 1; - - rfm22_claimBus(rfm22b_dev); rfm22_assertCs(rfm22b_dev); PIOS_SPI_TransferByte(rfm22b_dev->spi_id, RFM22_fifo_access | 0x80); - - int bytes_to_write = (rfm22b_dev->tx_data_wr - rfm22b_dev->tx_data_rd); - - bytes_to_write = (bytes_to_write > max_bytes) ? max_bytes : bytes_to_write; PIOS_SPI_TransferBlock(rfm22b_dev->spi_id, &tx_buffer[rfm22b_dev->tx_data_rd], NULL, bytes_to_write, NULL); rfm22b_dev->tx_data_rd += bytes_to_write; @@ -2822,14 +876,8 @@ pios_rfm22b_int_result PIOS_RFM22B_ProcessTx(uint32_trfm22b_id) return PIOS_RFM22B_INT_SUCCESS; } else if (rfm22b_dev->status_regs.int_status_1.packet_sent_interrupt) { - /* - * Transition - * out - * of - * Tx - * mode. */ + // Transition out of Tx mode. rfm22b_dev->rfm22b_state = RFM22B_STATE_TRANSITION; - return PIOS_RFM22B_TX_COMPLETE; } @@ -2837,141 +885,53 @@ pios_rfm22b_int_result PIOS_RFM22B_ProcessTx(uint32_trfm22b_id) } /** + * Process a Rx interrupt from the RFM22B device. * - * Process - * a - * Rx - * interrupt - * from - * the - * RFM22B - * device. - * - * - * @param[in] - * rfm22b_id - * - * The - * rfm22b - * device. - * - * @return - * PIOS_RFM22B_RX_COMPLETE - * on - * completed - * Rx, - * or - * PIOS_RFM22B_INT_SUCCESS/PIOS_RFM22B_INT_FAILURE. + * @param[in] rfm22b_id The rfm22b device. + * @return PIOS_RFM22B_RX_COMPLETE on completed Rx, or PIOS_RFM22B_INT_SUCCESS/PIOS_RFM22B_INT_FAILURE. */ -pios_rfm22b_int_result PIOS_RFM22B_ProcessRx(uint32_trfm22b_id) +pios_rfm22b_int_result PIOS_RFM22B_ProcessRx(uint32_t rfm22b_id) { struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; if (!PIOS_RFM22B_Validate(rfm22b_dev)) { return PIOS_RFM22B_INT_FAILURE; } - - uint8_t *rx_buffer = rfm22b_dev->rx_packet_handle; pios_rfm22b_int_result ret = PIOS_RFM22B_INT_SUCCESS; - - /* - * Read - * the - * device - * status - * registers */ + // Read the device status registers if (!pios_rfm22_readStatus(rfm22b_dev)) { rfm22_rxFailure(rfm22b_dev); - return PIOS_RFM22B_INT_FAILURE; } - /* - * FIFO - * under/over - * flow - * error. - * - * Restart - * RX - * mode. */ + + // FIFO under/over flow error. Restart RX mode. if (rfm22b_dev->status_regs.int_status_1.fifo_underoverflow_error || rfm22b_dev->status_regs.int_status_1.crc_error) { rfm22_rxFailure(rfm22b_dev); - return PIOS_RFM22B_INT_FAILURE; } - /* - * Valid - * packet - * received */ + + // Valid packet received if (rfm22b_dev->status_regs.int_status_1.valid_packet_received) { - /* - * Claim - * the - * SPI - * bus. */ + // Claim the SPI bus. rfm22_claimBus(rfm22b_dev); - - /* - * read - * the - * total - * length - * of - * the - * packet - * data */ + // read the total length of the packet data uint32_t len = rfm22_read(rfm22b_dev, RFM22_received_packet_length); - - /* - * The - * received - * packet - * is - * going - * to - * be - * larger - * than - * the - * receive - * buffer */ + // The received packet is going to be larger than the receive buffer if (len > rfm22b_dev->max_packet_len) { rfm22_releaseBus(rfm22b_dev); rfm22_rxFailure(rfm22b_dev); - return PIOS_RFM22B_INT_FAILURE; } - /* - * there - * must - * still - * be - * data - * in - * the - * RX - * FIFO - * we - * need - * to - * get */ + + // there must still be data in the RX FIFO we need to get if (rfm22b_dev->rx_buffer_wr < len) { int32_t bytes_to_read = len - rfm22b_dev->rx_buffer_wr; - - - /* - * Fetch - * the - * data - * from - * the - * RX - * FIFO */ + // Fetch the data from the RX FIFO rfm22_assertCs(rfm22b_dev); PIOS_SPI_TransferByte(rfm22b_dev->spi_id, RFM22_fifo_access & 0x7F); rfm22b_dev->rx_buffer_wr += (PIOS_SPI_TransferBlock(rfm22b_dev->spi_id, OUT_FF, (uint8_t *)&rx_buffer[rfm22b_dev->rx_buffer_wr], @@ -2979,296 +939,109 @@ pios_rfm22b_int_result PIOS_RFM22B_ProcessRx(uint32_trfm22b_id) rfm22_deassertCs(rfm22b_dev); } - /* - * Read - * the - * packet - * header - * (destination - * ID) */ + // Read the packet header (destination ID) rfm22b_dev->rx_destination_id = rfm22_read(rfm22b_dev, RFM22_received_header0); rfm22b_dev->rx_destination_id |= (rfm22_read(rfm22b_dev, RFM22_received_header1) << 8); rfm22b_dev->rx_destination_id |= (rfm22_read(rfm22b_dev, RFM22_received_header2) << 16); rfm22b_dev->rx_destination_id |= (rfm22_read(rfm22b_dev, RFM22_received_header3) << 24); - /* - * Release - * the - * SPI - * bus. */ + // Release the SPI bus. rfm22_releaseBus(rfm22b_dev); - /* - * Is - * there - * a - * length - * error? */ + + // Is there a length error? if (rfm22b_dev->rx_buffer_wr != len) { rfm22_rxFailure(rfm22b_dev); - return PIOS_RFM22B_INT_FAILURE; } - /* - * Increment - * the - * total - * byte - * received - * count. */ + // Increment the total byte received count. rfm22b_dev->stats.rx_byte_count += rfm22b_dev->rx_buffer_wr; - /* - * Update - * the - * pair - * status - * with - * this - * packet. */ + // Update the pair status with this packet. rfm22_updatePairStatus(rfm22b_dev); - /* - * We're - * finished - * with - * Rx - * mode */ + // We're finished with Rx mode rfm22b_dev->rfm22b_state = RFM22B_STATE_TRANSITION; ret = PIOS_RFM22B_RX_COMPLETE; } else if (rfm22b_dev->status_regs.int_status_1.rx_fifo_almost_full) { - /* - * RX - * FIFO - * almost - * full, - * it - * needs - * emptying - * read - * data - * from - * the - * rf - * chips - * FIFO - * buffer + // RX FIFO almost full, it needs emptying + // read data from the rf chips FIFO buffer - */ - - /* - * Claim - * the - * SPI - * bus. */ + // Claim the SPI bus. rfm22_claimBus(rfm22b_dev); - - /* - * Read - * the - * total - * length - * of - * the - * packet - * data */ + // Read the total length of the packet data uint16_t len = rfm22_read(rfm22b_dev, RFM22_received_packet_length); - - /* - * The - * received - * packet - * is - * going - * to - * be - * larger - * than - * the - * specified - * length */ + // The received packet is going to be larger than the specified length if ((rfm22b_dev->rx_buffer_wr + RX_FIFO_HI_WATERMARK) > len) { rfm22_releaseBus(rfm22b_dev); rfm22_rxFailure(rfm22b_dev); - return PIOS_RFM22B_INT_FAILURE; } - /* - * The - * received - * packet - * is - * going - * to - * be - * larger - * than - * the - * receive - * buffer */ + + // The received packet is going to be larger than the receive buffer if ((rfm22b_dev->rx_buffer_wr + RX_FIFO_HI_WATERMARK) > rfm22b_dev->max_packet_len) { rfm22_releaseBus(rfm22b_dev); rfm22_rxFailure(rfm22b_dev); - return PIOS_RFM22B_INT_FAILURE; } - /* - * Fetch - * the - * data - * from - * the - * RX - * FIFO */ + // Fetch the data from the RX FIFO rfm22_assertCs(rfm22b_dev); PIOS_SPI_TransferByte(rfm22b_dev->spi_id, RFM22_fifo_access & 0x7F); rfm22b_dev->rx_buffer_wr += (PIOS_SPI_TransferBlock(rfm22b_dev->spi_id, OUT_FF, (uint8_t *)&rx_buffer[rfm22b_dev->rx_buffer_wr], RX_FIFO_HI_WATERMARK, NULL) == 0) ? RX_FIFO_HI_WATERMARK : 0; rfm22_deassertCs(rfm22b_dev); - /* - * Release - * the - * SPI - * bus. */ + // Release the SPI bus. rfm22_releaseBus(rfm22b_dev); - /* - * Make - * sure - * that - * we're - * in - * RX - * mode. */ + // Make sure that we're in RX mode. rfm22b_dev->rfm22b_state = RFM22B_STATE_RX_MODE; } else if (rfm22b_dev->status_regs.int_status_2.valid_preamble_detected) { - /* - * Valid - * preamble - * detected */ + // Valid preamble detected RX_LED_ON; - /* - * Sync - * word - * detected */ + // Sync word detected #ifdef PIOS_RFM22B_DEBUG_ON_TELEM D2_LED_ON; -#endif /* - * PIOS_RFM22B_DEBUG_ON_TELEM */ +#endif // PIOS_RFM22B_DEBUG_ON_TELEM rfm22b_dev->packet_start_ticks = xTaskGetTickCount(); if (rfm22b_dev->packet_start_ticks == 0) { rfm22b_dev->packet_start_ticks = 1; } - /* - * We - * detected - * the - * preamble, - * now - * wait - * for - * sync. */ + // We detected the preamble, now wait for sync. rfm22b_dev->rfm22b_state = RFM22B_STATE_RX_WAIT_SYNC; } else if (rfm22b_dev->status_regs.int_status_2.sync_word_detected) { - /* - * Claim - * the - * SPI - * bus. */ + // Claim the SPI bus. rfm22_claimBus(rfm22b_dev); - - /* - * read - * the - * 10-bit - * signed - * afc - * correction - * value */ - /* - * bits - * 9 - * to - * 2 */ + // read the 10-bit signed afc correction value + // bits 9 to 2 uint16_t afc_correction = (uint16_t)rfm22_read(rfm22b_dev, RFM22_afc_correction_read) << 8; - - - /* - * bits - * 1 - * & - * 0 */ + // bits 1 & 0 afc_correction |= (uint16_t)rfm22_read(rfm22b_dev, RFM22_ook_counter_value1) & 0x00c0; afc_correction >>= 6; - - - /* - * convert - * the - * afc - * value - * to - * Hz */ + // convert the afc value to Hz int32_t afc_corr = (int32_t)(rfm22b_dev->frequency_step_size * afc_correction + 0.5f); - - rfm22b_dev->afc_correction_Hz = (afc_corr < -127) ? -127 : ((afc_corr > 127) ? 127 : afc_corr); - - /* - * read - * rx - * signal - * strength - * .. - * 45 - * = - * -100dBm, - * 205 - * = - * -20dBm */ + // read rx signal strength .. 45 = -100dBm, 205 = -20dBm uint8_t rssi = rfm22_read(rfm22b_dev, RFM22_rssi); - - - /* - * convert - * to - * dBm */ + // convert to dBm rfm22b_dev->rssi_dBm = (int8_t)(rssi >> 1) - 122; - /* - * Release - * the - * SPI - * bus. */ + // Release the SPI bus. rfm22_releaseBus(rfm22b_dev); - /* - * Indicate - * that - * we're - * in - * RX - * mode. */ + // Indicate that we're in RX mode. rfm22b_dev->rfm22b_state = RFM22B_STATE_RX_MODE; } else if ((rfm22b_dev->rfm22b_state == RFM22B_STATE_RX_WAIT_SYNC) && !rfm22b_dev->status_regs.int_status_2.valid_preamble_detected) { - /* - * Waiting - * for - * the - * preamble - * timed - * out. */ + // Waiting for the preamble timed out. rfm22_rxFailure(rfm22b_dev); - return PIOS_RFM22B_INT_FAILURE; } @@ -3276,44 +1049,12 @@ pios_rfm22b_int_result PIOS_RFM22B_ProcessRx(uint32_trfm22b_id) } /** + * Set the PPM packet received callback. * - * Set - * the - * PPM - * packet - * received - * callback. - * - * - * @param[in] - * rfm22b_dev - * - * The - * RFM22B - * device - * ID. - * - * @param[in] - * cb - * - * - * - * - * - * - * - * - * - * The - * callback - * function - * pointer. + * @param[in] rfm22b_dev The RFM22B device ID. + * @param[in] cb The callback function pointer. */ -void PIOS_RFM22B_SetPPMCallback( - uint32_t - rfm22b_id, - PPMReceivedCallback - cb) +void PIOS_RFM22B_SetPPMCallback(uint32_t rfm22b_id, PPMReceivedCallback cb) { struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; @@ -3325,40 +1066,12 @@ void PIOS_RFM22B_SetPPMCallback( } /** + * Set the PPM values to be transmitted. * - * Set - * the - * PPM - * values - * to - * be - * transmitted. - * - * - * @param[in] - * rfm22b_dev - * - * The - * RFM22B - * device - * ID. - * - * @param[in] - * channels - * - * - * - * The - * PPM - * channel - * values. + * @param[in] rfm22b_dev The RFM22B device ID. + * @param[in] channels The PPM channel values. */ -extern void PIOS_RFM22B_PPMSet( - uint32_t - rfm22b_id, - int16_t - * - channels) +extern void PIOS_RFM22B_PPMSet(uint32_t rfm22b_id, int16_t *channels) { struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; @@ -3372,41 +1085,12 @@ extern void PIOS_RFM22B_PPMSet( } /** + * Fetch the PPM values that have been received. * - * Fetch - * the - * PPM - * values - * that - * have - * been - * received. - * - * - * @param[in] - * rfm22b_dev - * - * The - * RFM22B - * device - * structure - * pointer. - * - * @param[out] - * channels - * - * - * The - * PPM - * channel - * values. + * @param[in] rfm22b_dev The RFM22B device structure pointer. + * @param[out] channels The PPM channel values. */ -extern void PIOS_RFM22B_PPMGet( - uint32_t - rfm22b_id, - int16_t - * - channels) +extern void PIOS_RFM22B_PPMGet(uint32_t rfm22b_id, int16_t *channels) { struct pios_rfm22b_dev *rfm22b_dev = (struct pios_rfm22b_dev *)rfm22b_id; @@ -3420,24 +1104,9 @@ extern void PIOS_RFM22B_PPMGet( } /** + * Validate that the device structure is valid. * - * Validate - * that - * the - * device - * structure - * is - * valid. - * - * - * @param[in] - * rfm22b_dev - * - * The - * RFM22B - * device - * structure - * pointer. + * @param[in] rfm22b_dev The RFM22B device structure pointer. */ inline bool PIOS_RFM22B_Validate(struct pios_rfm22b_dev *rfm22b_dev) { @@ -3446,31 +1115,13 @@ inline bool PIOS_RFM22B_Validate(struct pios_rfm22b_dev *rfm22b_dev) /***************************************************************************** -* -* The -* Device -* Control -* Thread +* The Device Control Thread *****************************************************************************/ /** + * The task that controls the radio state machine. * - * The - * task - * that - * controls - * the - * radio - * state - * machine. - * - * - * @param[in] - * paramters - * - * The - * task - * parameters. + * @param[in] paramters The task parameters. */ static void pios_rfm22_task(void *parameters) { @@ -3479,145 +1130,65 @@ static void pios_rfm22_task(void *parameters) if (!PIOS_RFM22B_Validate(rfm22b_dev)) { return; } - - portTickType lastEventTicks = xTaskGetTickCount(); - while (1) { #if defined(PIOS_INCLUDE_WDG) && defined(PIOS_WDG_RFM22B) - /* - * Update - * the - * watchdog - * timer */ - PIOS_WDG_UpdateFlag( - PIOS_WDG_RFM22B); + // Update the watchdog timer + PIOS_WDG_UpdateFlag(PIOS_WDG_RFM22B); #endif /* PIOS_WDG_RFM22B */ - /* - * Wait - * for - * a - * signal - * indicating - * an - * external - * interrupt - * or - * a - * pending - * send/receive - * request. */ + + // Wait for a signal indicating an external interrupt or a pending send/receive request. if (xSemaphoreTake(rfm22b_dev->isrPending, ISR_TIMEOUT / portTICK_RATE_MS) == pdTRUE) { lastEventTicks = xTaskGetTickCount(); - - /* - * Process - * events - * through - * the - * state - * machine. */ + // Process events through the state machine. enum pios_radio_event event; - - while (xQueueReceive(rfm22b_dev->eventQueue, &event, 0) == pdTRUE) { if ((event == RADIO_EVENT_INT_RECEIVED) && ((rfm22b_dev->state == RADIO_STATE_UNINITIALIZED) || (rfm22b_dev->state == RADIO_STATE_INITIALIZING))) { continue; } - rfm22_process_event(rfm22b_dev, event); } } else { - /* - * Has - * it - * been - * too - * long - * since - * the - * last - * event? */ + // Has it been too long since the last event? portTickType curTicks = xTaskGetTickCount(); - - if (pios_rfm22_time_difference_ms(lastEventTicks, curTicks) > PIOS_RFM22B_SUPERVISOR_TIMEOUT) { - /* - * Clear - * the - * event - * queue. */ + // Clear the event queue. enum pios_radio_event event; - - while (xQueueReceive(rfm22b_dev->eventQueue, &event, 0) == pdTRUE) { - /* - * Do - * nothing; */ + // Do nothing; } lastEventTicks = xTaskGetTickCount(); - /* - * Transsition - * through - * an - * error - * event. */ + // Transsition through an error event. rfm22_process_event(rfm22b_dev, RADIO_EVENT_ERROR); } } - /* - * Change - * channels - * if - * necessary. */ + + // Change channels if necessary. if (rfm22_changeChannel(rfm22b_dev)) { rfm22_process_event(rfm22b_dev, RADIO_EVENT_RX_MODE); } - portTickType curTicks = xTaskGetTickCount(); + // Have we been sending / receiving this packet too long? - - /* - * Have - * we - * been - * sending - * / - * receiving - * this - * packet - * too - * long? */ if ((rfm22b_dev->packet_start_ticks > 0) && (pios_rfm22_time_difference_ms(rfm22b_dev->packet_start_ticks, curTicks) > (rfm22b_dev->packet_time * 3))) { rfm22_process_event(rfm22b_dev, RADIO_EVENT_TIMEOUT); } - - /* - * Start - * transmitting - * a - * packet - * if - * it's - * time. */ + // Start transmitting a packet if it's time. bool time_to_send = rfm22_timeToSend(rfm22b_dev); - - - #ifdef PIOS_RFM22B_DEBUG_ON_TELEM - if ( - time_to_send) { + #ifdef PIOS_RFM22B_DEBUG_ON_TELEM + if (time_to_send) { D4_LED_ON; } else { D4_LED_OFF; } - #endif + #endif if (time_to_send && PIOS_RFM22B_InRxWait((uint32_t)rfm22b_dev)) { rfm22_process_event(rfm22b_dev, RADIO_EVENT_TX_START); } @@ -3626,257 +1197,74 @@ static void pios_rfm22_task(void *parameters) /***************************************************************************** -* -* The -* State -* Machine -* Functions +* The State Machine Functions *****************************************************************************/ /** + * Inject an event into the RFM22B state machine. * - * Inject - * an - * event - * into - * the - * RFM22B - * state - * machine. - * - * - * @param[in] - * rfm22b_dev - * The - * device - * structure - * - * @param[in] - * event - * The - * event - * to - * inject - * - * @param[in] - * inISR - * Is - * this - * being - * called - * from - * an - * interrrup - * service - * routine? + * @param[in] rfm22b_dev The device structure + * @param[in] event The event to inject + * @param[in] inISR Is this being called from an interrrup service routine? */ -static void pios_rfm22_inject_event( - struct - pios_rfm22b_dev - * - rfm22b_dev, - enum - pios_radio_event - event, - bool - inISR) +static void pios_rfm22_inject_event(struct pios_rfm22b_dev *rfm22b_dev, enum pios_radio_event event, bool inISR) { if (inISR) { - /* - * Store - * the - * event. */ + // Store the event. portBASE_TYPE pxHigherPriorityTaskWoken1; - - if (xQueueSendFromISR(rfm22b_dev->eventQueue, &event, &pxHigherPriorityTaskWoken1) != pdTRUE) { return; } - - - /* - * Signal - * the - * semaphore - * to - * wake - * up - * the - * handler - * thread. */ + // Signal the semaphore to wake up the handler thread. portBASE_TYPE pxHigherPriorityTaskWoken2; - - if (xSemaphoreGiveFromISR(rfm22b_dev->isrPending, &pxHigherPriorityTaskWoken2) != pdTRUE) { - /* - * Something - * went - * fairly - * seriously - * wrong */ + // Something went fairly seriously wrong rfm22b_dev->errors++; } - portEND_SWITCHING_ISR((pxHigherPriorityTaskWoken2 == pdTRUE) || (pxHigherPriorityTaskWoken2 == pdTRUE)); } else { - /* - * Store - * the - * event. */ + // Store the event. if (xQueueSend(rfm22b_dev->eventQueue, &event, portMAX_DELAY) != pdTRUE) { return; } - /* - * Signal - * the - * semaphore - * to - * wake - * up - * the - * handler - * thread. */ + // Signal the semaphore to wake up the handler thread. if (xSemaphoreGive(rfm22b_dev->isrPending) != pdTRUE) { - /* - * Something - * went - * fairly - * seriously - * wrong */ + // Something went fairly seriously wrong rfm22b_dev->errors++; } } } /** + * Process the next state transition from the given event. * - * Process - * the - * next - * state - * transition - * from - * the - * given - * event. - * - * - * @param[in] - * rfm22b_dev - * The - * device - * structure - * - * @param[in] - * event - * The - * event - * to - * process - * - * @return - * enum - * pios_radio_event - * - * The - * next - * event - * to - * inject + * @param[in] rfm22b_dev The device structure + * @param[in] event The event to process + * @return enum pios_radio_event The next event to inject */ -static enum pios_radio_event rfm22_process_state_transition( - struct - pios_rfm22b_dev - * - rfm22b_dev, - enum - pios_radio_event - event) +static enum pios_radio_event rfm22_process_state_transition(struct pios_rfm22b_dev *rfm22b_dev, enum pios_radio_event event) { - /* - * No - * event */ + // No event if (event >= RADIO_EVENT_NUM_EVENTS) { return RADIO_EVENT_NUM_EVENTS; } - - /* - * Don't - * transition - * if - * there - * is - * no - * transition - * defined */ + // Don't transition if there is no transition defined enum pios_radio_state next_state = rfm22b_transitions[rfm22b_dev->state].next_state[event]; - - if (!next_state) { return RADIO_EVENT_NUM_EVENTS; } /* + * Move to the next state * - * Move - * to - * the - * next - * state - * - * - * This - * is - * done - * prior - * to - * calling - * the - * new - * state's - * entry - * function - * to - * - * guarantee - * that - * the - * entry - * function - * never - * depends - * on - * the - * previous - * - * state. - * - * This - * way, - * it - * cannot - * ever - * know - * what - * the - * previous - * state - * was. + * This is done prior to calling the new state's entry function to + * guarantee that the entry function never depends on the previous + * state. This way, it cannot ever know what the previous state was. */ rfm22b_dev->state = next_state; - /* - * Call - * the - * entry - * function - * (if - * any) - * for - * the - * next - * state. - * */ + + /* Call the entry function (if any) for the next state. */ if (rfm22b_transitions[rfm22b_dev->state].entry_fn) { return rfm22b_transitions[rfm22b_dev->state].entry_fn(rfm22b_dev); } @@ -3885,58 +1273,15 @@ static enum pios_radio_event rfm22_process_state_transition( } /** + * Process the given event through the state transition table. + * This could cause a series of events and transitions to take place. * - * Process - * the - * given - * event - * through - * the - * state - * transition - * table. - * - * This - * could - * cause - * a - * series - * of - * events - * and - * transitions - * to - * take - * place. - * - * - * @param[in] - * rfm22b_dev - * The - * device - * structure - * - * @param[in] - * event - * The - * event - * to - * process + * @param[in] rfm22b_dev The device structure + * @param[in] event The event to process */ -static void rfm22_process_event( - struct - pios_rfm22b_dev - * - rfm22b_dev, - enum - pios_radio_event - event) +static void rfm22_process_event(struct pios_rfm22b_dev *rfm22b_dev, enum pios_radio_event event) { - /* - * Process - * all - * state - * transitions. */ + // Process all state transitions. while (event != RADIO_EVENT_NUM_EVENTS) { event = rfm22_process_state_transition(rfm22b_dev, event); } @@ -3944,66 +1289,27 @@ static void /***************************************************************************** -* -* The -* Device -* Initialization -* / -* Configuration -* Functions +* The Device Initialization / Configuration Functions *****************************************************************************/ /** + * Initialize (or re-initialize) the RFM22B radio device. * - * Initialize - * (or - * re-initialize) - * the - * RFM22B - * radio - * device. - * - * - * @param[in] - * rfm22b_dev - * The - * device - * structure - * - * @return - * enum - * pios_radio_event - * - * The - * next - * event - * to - * inject + * @param[in] rfm22b_dev The device structure + * @return enum pios_radio_event The next event to inject */ static enum pios_radio_event rfm22_init(struct pios_rfm22b_dev *rfm22b_dev) { - /* - * Initialize - * the - * register - * values. */ + // Initialize the register values. rfm22b_dev->status_regs.int_status_1.raw = 0; rfm22b_dev->status_regs.int_status_2.raw = 0; rfm22b_dev->status_regs.device_status.raw = 0; rfm22b_dev->status_regs.ezmac_status.raw = 0; - /* - * Clean - * the - * LEDs */ + // Clean the LEDs rfm22_clearLEDs(); - /* - * Initialize - * the - * detected - * device - * statistics. */ + // Initialize the detected device statistics. for (uint8_t i = 0; i < OPLINKSTATUS_PAIRIDS_NUMELEM; ++i) { rfm22b_dev->pair_stats[i].pairID = 0; rfm22b_dev->pair_stats[i].rssi = -127; @@ -4011,33 +1317,20 @@ static enum pios_radio_event rfm22_init(struct pios_rfm22b_dev *rfm22b_dev) rfm22b_dev->pair_stats[i].lastContact = 0; } - /* - * Initlize - * the - * link - * stats. */ + // Initlize the link stats. for (uint8_t i = 0; i < RFM22B_RX_PACKET_STATS_LEN; ++i) { rfm22b_dev->rx_packet_stats[i] = 0; } - /* - * Initialize - * the - * state */ + + // Initialize the state rfm22b_dev->stats.link_state = OPLINKSTATUS_LINKSTATE_ENABLED; - /* - * Initialize - * the - * packets. */ + // Initialize the packets. rfm22b_dev->rx_packet_len = 0; rfm22b_dev->rx_destination_id = 0; rfm22b_dev->tx_packet_handle = NULL; - /* - * Initialize - * the - * devide - * state */ + // Initialize the devide state rfm22b_dev->rx_buffer_wr = 0; rfm22b_dev->tx_data_rd = rfm22b_dev->tx_data_wr = 0; rfm22b_dev->channel = 0; @@ -4048,349 +1341,125 @@ static enum pios_radio_event rfm22_init(struct pios_rfm22b_dev *rfm22b_dev) rfm22b_dev->rfm22b_state = RFM22B_STATE_INITIALIZING; rfm22b_dev->on_sync_channel = false; - /* - * software - * reset - * the - * RF - * chip - * .. - * following - * procedure - * according - * to - * Si4x3x - * Errata - * (rev. - * B) */ + // software reset the RF chip .. following procedure according to Si4x3x Errata (rev. B) rfm22_write_claim(rfm22b_dev, RFM22_op_and_func_ctrl1, RFM22_opfc1_swres); for (uint8_t i = 0; i < 50; ++i) { - /* - * read - * the - * status - * registers */ + // read the status registers pios_rfm22_readStatus(rfm22b_dev); - /* - * Is - * the - * chip - * ready? */ + + // Is the chip ready? if (rfm22b_dev->status_regs.int_status_2.chip_ready) { break; } - /* - * Wait - * 1ms - * if - * not. */ + // Wait 1ms if not. PIOS_DELAY_WaitmS(1); } - /* - * **************** */ - /* - * read - * status - * - - * clears - * interrupt */ + // **************** + + // read status - clears interrupt pios_rfm22_readStatus(rfm22b_dev); - /* - * Claim - * the - * SPI - * bus. */ + // Claim the SPI bus. rfm22_claimBus(rfm22b_dev); - /* - * disable - * all - * interrupts */ + // disable all interrupts rfm22_write(rfm22b_dev, RFM22_interrupt_enable1, 0x00); rfm22_write(rfm22b_dev, RFM22_interrupt_enable2, 0x00); + // read the RF chip ID bytes - /* - * read - * the - * RF - * chip - * ID - * bytes */ - - /* - * read - * the - * device - * type */ + // read the device type uint8_t device_type = rfm22_read(rfm22b_dev, RFM22_DEVICE_TYPE) & RFM22_DT_MASK; - /* - * read - * the - * device - * version */ + // read the device version uint8_t device_version = rfm22_read(rfm22b_dev, RFM22_DEVICE_VERSION) & RFM22_DV_MASK; - #if defined(RFM22_DEBUG) - DEBUG_PRINTF( - 2, - "rf device type: %d\n\r", - device_type); - DEBUG_PRINTF( - 2, - "rf device version: %d\n\r", - device_version); + DEBUG_PRINTF(2, "rf device type: %d\n\r", device_type); + DEBUG_PRINTF(2, "rf device version: %d\n\r", device_version); #endif + if (device_type != 0x08) { #if defined(RFM22_DEBUG) - DEBUG_PRINTF( - 2, - "rf device type: INCORRECT - should be 0x08\n\r"); + DEBUG_PRINTF(2, "rf device type: INCORRECT - should be 0x08\n\r"); #endif - /* - * incorrect - * RF - * module - * type */ + // incorrect RF module type return RADIO_EVENT_FATAL_ERROR; } if (device_version != RFM22_DEVICE_VERSION_B1) { #if defined(RFM22_DEBUG) - DEBUG_PRINTF( - 2, - "rf device version: INCORRECT\n\r"); + DEBUG_PRINTF(2, "rf device version: INCORRECT\n\r"); #endif - - /* - * incorrect - * RF - * module - * version */ + // incorrect RF module version return RADIO_EVENT_FATAL_ERROR; } - /* - * calibrate - * our - * RF - * module - * to - * be - * exactly - * on - * frequency - * .. - * different - * for - * every - * module */ + // calibrate our RF module to be exactly on frequency .. different for every module rfm22_write(rfm22b_dev, RFM22_xtal_osc_load_cap, OSC_LOAD_CAP); - /* - * disable - * Low - * Duty - * Cycle - * Mode */ + // disable Low Duty Cycle Mode rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl2, 0x00); - /* - * 1MHz - * clock - * output */ + // 1MHz clock output rfm22_write(rfm22b_dev, RFM22_cpu_output_clk, RFM22_coc_1MHz); - /* - * READY - * mode */ + // READY mode rfm22_write(rfm22b_dev, RFM22_op_and_func_ctrl1, RFM22_opfc1_xton); - /* - * choose - * the - * 3 - * GPIO - * pin - * functions - * GPIO - * port - * use - * default - * value - - */ + // choose the 3 GPIO pin functions + // GPIO port use default value rfm22_write(rfm22b_dev, RFM22_io_port_config, RFM22_io_port_default); if (rfm22b_dev->cfg.gpio_direction == GPIO0_TX_GPIO1_RX) { - /* - * GPIO0 - * = - * TX - * State - * (to - * control - * RF - * Switch) */ + // GPIO0 = TX State (to control RF Switch) rfm22_write(rfm22b_dev, RFM22_gpio0_config, RFM22_gpio0_config_drv3 | RFM22_gpio0_config_txstate); - /* - * GPIO1 - * = - * RX - * State - * (to - * control - * RF - * Switch) */ + // GPIO1 = RX State (to control RF Switch) rfm22_write(rfm22b_dev, RFM22_gpio1_config, RFM22_gpio1_config_drv3 | RFM22_gpio1_config_rxstate); } else { - /* - * GPIO0 - * = - * TX - * State - * (to - * control - * RF - * Switch) */ + // GPIO0 = TX State (to control RF Switch) rfm22_write(rfm22b_dev, RFM22_gpio0_config, RFM22_gpio0_config_drv3 | RFM22_gpio0_config_rxstate); - /* - * GPIO1 - * = - * RX - * State - * (to - * control - * RF - * Switch) */ + // GPIO1 = RX State (to control RF Switch) rfm22_write(rfm22b_dev, RFM22_gpio1_config, RFM22_gpio1_config_drv3 | RFM22_gpio1_config_txstate); } - - /* - * GPIO2 - * = - * Clear - * Channel - * Assessment */ + // GPIO2 = Clear Channel Assessment rfm22_write(rfm22b_dev, RFM22_gpio2_config, RFM22_gpio2_config_drv3 | RFM22_gpio2_config_cca); - - /* - * FIFO - * mode, - * GFSK - * modulation */ + // FIFO mode, GFSK modulation uint8_t fd_bit = rfm22_read(rfm22b_dev, RFM22_modulation_mode_control2) & RFM22_mmc2_fd; - - rfm22_write(rfm22b_dev, RFM22_modulation_mode_control2, RFM22_mmc2_trclk_clk_none | RFM22_mmc2_dtmod_fifo | fd_bit | RFM22_mmc2_modtyp_gfsk); + // setup to read the internal temperature sensor - /* - * setup - * to - * read - * the - * internal - * temperature - * sensor */ - - /* - * ADC - * used - * to - * sample - * the - * temperature - * sensor */ + // ADC used to sample the temperature sensor uint8_t adc_config = RFM22_ac_adcsel_temp_sensor | RFM22_ac_adcref_bg; - - rfm22_write(rfm22b_dev, RFM22_adc_config, adc_config); - /* - * adc - * offset */ + // adc offset rfm22_write(rfm22b_dev, RFM22_adc_sensor_amp_offset, 0); - /* - * temp - * sensor - * calibration - * .. - * �40C - * to - * +64C - * 0.5C - * resolution */ + // temp sensor calibration .. �40C to +64C 0.5C resolution rfm22_write(rfm22b_dev, RFM22_temp_sensor_calib, RFM22_tsc_tsrange0 | RFM22_tsc_entsoffs); - /* - * temp - * sensor - * offset */ + // temp sensor offset rfm22_write(rfm22b_dev, RFM22_temp_value_offset, 0); - /* - * start - * an - * ADC - * conversion */ + // start an ADC conversion rfm22_write(rfm22b_dev, RFM22_adc_config, adc_config | RFM22_ac_adcstartbusy); - /* - * set - * the - * RSSI - * threshold - * interrupt - * to - * about - * -90dBm */ + // set the RSSI threshold interrupt to about -90dBm rfm22_write(rfm22b_dev, RFM22_rssi_threshold_clear_chan_indicator, (-90 + 122) * 2); - /* - * enable - * the - * internal - * Tx - * & - * Rx - * packet - * handlers - * (without - * CRC) */ + // enable the internal Tx & Rx packet handlers (without CRC) rfm22_write(rfm22b_dev, RFM22_data_access_control, RFM22_dac_enpacrx | RFM22_dac_enpactx); - /* - * x-nibbles - * tx - * preamble */ + // x-nibbles tx preamble rfm22_write(rfm22b_dev, RFM22_preamble_length, TX_PREAMBLE_NIBBLES); - /* - * x-nibbles - * rx - * preamble - * detection */ + // x-nibbles rx preamble detection rfm22_write(rfm22b_dev, RFM22_preamble_detection_ctrl1, RX_PREAMBLE_NIBBLES << 3); - /* - * header - * control - * - - * using - * a - * 4 - * by - * header - * with - * broadcast - * of - * 0xffffffff */ + // header control - using a 4 by header with broadcast of 0xffffffff rfm22_write(rfm22b_dev, RFM22_header_control1, RFM22_header_cntl1_bcen_0 | RFM22_header_cntl1_bcen_1 | @@ -4400,136 +1469,46 @@ static enum pios_radio_event rfm22_init(struct pios_rfm22b_dev *rfm22b_dev) RFM22_header_cntl1_hdch_1 | RFM22_header_cntl1_hdch_2 | RFM22_header_cntl1_hdch_3); - - - /* - * Check - * all - * bit - * of - * all - * bytes - * of - * the - * header, - * unless - * we're - * an - * unbound - * modem. */ + // Check all bit of all bytes of the header, unless we're an unbound modem. uint8_t header_mask = (rfm22_destinationID(rfm22b_dev) == 0xffffffff) ? 0 : 0xff; - - rfm22_write(rfm22b_dev, RFM22_header_enable0, header_mask); rfm22_write(rfm22b_dev, RFM22_header_enable1, header_mask); rfm22_write(rfm22b_dev, RFM22_header_enable2, header_mask); rfm22_write(rfm22b_dev, RFM22_header_enable3, header_mask); - - - /* - * The - * destination - * ID - * and - * receive - * ID - * should - * be - * the - * same. */ + // The destination ID and receive ID should be the same. uint32_t id = rfm22_destinationID(rfm22b_dev); - - rfm22_write(rfm22b_dev, RFM22_check_header0, id & 0xff); rfm22_write(rfm22b_dev, RFM22_check_header1, (id >> 8) & 0xff); rfm22_write(rfm22b_dev, RFM22_check_header2, (id >> 16) & 0xff); rfm22_write(rfm22b_dev, RFM22_check_header3, (id >> 24) & 0xff); - /* - * 4 - * header - * bytes, - * synchronization - * word - * length - * 3, - * 2, - * 1 - * & - * 0 - * used, - * packet - * length - * included - * in - * header. */ + // 4 header bytes, synchronization word length 3, 2, 1 & 0 used, packet length included in header. rfm22_write(rfm22b_dev, RFM22_header_control2, RFM22_header_cntl2_hdlen_3210 | RFM22_header_cntl2_synclen_3210 | ((TX_PREAMBLE_NIBBLES >> 8) & 0x01)); - /* - * sync - * word */ + // sync word rfm22_write(rfm22b_dev, RFM22_sync_word3, SYNC_BYTE_1); rfm22_write(rfm22b_dev, RFM22_sync_word2, SYNC_BYTE_2); rfm22_write(rfm22b_dev, RFM22_sync_word1, SYNC_BYTE_3); rfm22_write(rfm22b_dev, RFM22_sync_word0, SYNC_BYTE_4); - /* - * TX - * FIFO - * Almost - * Full - * Threshold - * (0 - * - - * 63) */ + // TX FIFO Almost Full Threshold (0 - 63) rfm22_write(rfm22b_dev, RFM22_tx_fifo_control1, TX_FIFO_HI_WATERMARK); - /* - * TX - * FIFO - * Almost - * Empty - * Threshold - * (0 - * - - * 63) */ + // TX FIFO Almost Empty Threshold (0 - 63) rfm22_write(rfm22b_dev, RFM22_tx_fifo_control2, TX_FIFO_LO_WATERMARK); - /* - * RX - * FIFO - * Almost - * Full - * Threshold - * (0 - * - - * 63) */ + // RX FIFO Almost Full Threshold (0 - 63) rfm22_write(rfm22b_dev, RFM22_rx_fifo_control, RX_FIFO_HI_WATERMARK); - /* - * Set - * the - * frequency - * calibration */ + // Set the frequency calibration rfm22_write(rfm22b_dev, RFM22_xtal_osc_load_cap, rfm22b_dev->cfg.RFXtalCap); - /* - * Release - * the - * bus */ + // Release the bus rfm22_releaseBus(rfm22b_dev); - /* - * Initialize - * the - * frequency - * and - * datarate - * to - * te - * default. */ + // Initialize the frequency and datarate to te default. rfm22_setNominalCarrierFrequency(rfm22b_dev, 0); pios_rfm22_setDatarate(rfm22b_dev); @@ -4537,239 +1516,97 @@ static enum pios_radio_event rfm22_init(struct pios_rfm22b_dev *rfm22b_dev) } /** + * Set the air datarate for the RFM22B device. * - * Set - * the - * air - * datarate - * for - * the - * RFM22B - * device. + * Carson's rule: + * The signal bandwidth is about 2(Delta-f + fm) .. * + * Delta-f = frequency deviation + * fm = maximum frequency of the signal * - * Carson's - * rule: - * - * - * The - * signal - * bandwidth - * is - * about - * 2(Delta-f - * + - * fm) - * .. - * - * - * Delta-f - * = - * frequency - * deviation - * - * fm - * = - * maximum - * frequency - * of - * the - * signal - * - * - * @param[in] - * rfm33b_dev - * - * The - * device - * structure - * pointer. - * - * @param[in] - * datarate - * - * The - * air - * datarate. - * - * @param[in] - * data_whitening - * - * Is - * data - * whitening - * desired? + * @param[in] rfm33b_dev The device structure pointer. + * @param[in] datarate The air datarate. + * @param[in] data_whitening Is data whitening desired? */ static void pios_rfm22_setDatarate(struct pios_rfm22b_dev *rfm22b_dev) { enum rfm22b_datarate datarate = rfm22b_dev->datarate; bool data_whitening = true; - /* - * Claim - * the - * SPI - * bus. */ + // Claim the SPI bus. rfm22_claimBus(rfm22b_dev); - /* - * rfm22_if_filter_bandwidth */ + // rfm22_if_filter_bandwidth rfm22_write(rfm22b_dev, 0x1C, reg_1C[datarate]); - /* - * rfm22_afc_loop_gearshift_override */ + // rfm22_afc_loop_gearshift_override rfm22_write(rfm22b_dev, 0x1D, reg_1D[datarate]); - /* - * RFM22_afc_timing_control */ + // RFM22_afc_timing_control rfm22_write(rfm22b_dev, 0x1E, reg_1E[datarate]); - /* - * RFM22_clk_recovery_gearshift_override */ + // RFM22_clk_recovery_gearshift_override rfm22_write(rfm22b_dev, 0x1F, reg_1F[datarate]); - /* - * rfm22_clk_recovery_oversampling_ratio */ + // rfm22_clk_recovery_oversampling_ratio rfm22_write(rfm22b_dev, 0x20, reg_20[datarate]); - /* - * rfm22_clk_recovery_offset2 */ + // rfm22_clk_recovery_offset2 rfm22_write(rfm22b_dev, 0x21, reg_21[datarate]); - /* - * rfm22_clk_recovery_offset1 */ + // rfm22_clk_recovery_offset1 rfm22_write(rfm22b_dev, 0x22, reg_22[datarate]); - /* - * rfm22_clk_recovery_offset0 */ + // rfm22_clk_recovery_offset0 rfm22_write(rfm22b_dev, 0x23, reg_23[datarate]); - /* - * rfm22_clk_recovery_timing_loop_gain1 */ + // rfm22_clk_recovery_timing_loop_gain1 rfm22_write(rfm22b_dev, 0x24, reg_24[datarate]); - /* - * rfm22_clk_recovery_timing_loop_gain0 */ + // rfm22_clk_recovery_timing_loop_gain0 rfm22_write(rfm22b_dev, 0x25, reg_25[datarate]); - /* - * rfm22_agc_override1 */ + // rfm22_agc_override1 rfm22_write(rfm22b_dev, RFM22_agc_override1, reg_69[datarate]); - /* - * rfm22_afc_limiter */ + // rfm22_afc_limiter rfm22_write(rfm22b_dev, 0x2A, reg_2A[datarate]); - /* - * rfm22_tx_data_rate1 */ + // rfm22_tx_data_rate1 rfm22_write(rfm22b_dev, 0x6E, reg_6E[datarate]); - /* - * rfm22_tx_data_rate0 */ + // rfm22_tx_data_rate0 rfm22_write(rfm22b_dev, 0x6F, reg_6F[datarate]); + if (!data_whitening) { - /* - * rfm22_modulation_mode_control1 */ + // rfm22_modulation_mode_control1 rfm22_write(rfm22b_dev, 0x70, reg_70[datarate] & ~RFM22_mmc1_enwhite); } else { - /* - * rfm22_modulation_mode_control1 */ + // rfm22_modulation_mode_control1 rfm22_write(rfm22b_dev, 0x70, reg_70[datarate] | RFM22_mmc1_enwhite); } - /* - * rfm22_modulation_mode_control2 */ + // rfm22_modulation_mode_control2 rfm22_write(rfm22b_dev, 0x71, reg_71[datarate]); - /* - * rfm22_frequency_deviation */ + // rfm22_frequency_deviation rfm22_write(rfm22b_dev, 0x72, reg_72[datarate]); - /* - * rfm22_cpcuu */ + // rfm22_cpcuu rfm22_write(rfm22b_dev, 0x58, reg_58[datarate]); rfm22_write(rfm22b_dev, RFM22_ook_counter_value1, 0x00); rfm22_write(rfm22b_dev, RFM22_ook_counter_value2, 0x00); - /* - * Release - * the - * bus */ + // Release the bus rfm22_releaseBus(rfm22b_dev); } /** + * Set the nominal carrier frequency, channel step size, and initial channel * - * Set - * the - * nominal - * carrier - * frequency, - * channel - * step - * size, - * and - * initial - * channel - * - * - * @param[in] - * rfm33b_dev - * - * The - * device - * structure - * pointer. - * - * @param[in] - * init_chan - * - * The - * initial - * channel - * to - * tune - * to. + * @param[in] rfm33b_dev The device structure pointer. + * @param[in] init_chan The initial channel to tune to. */ -static void rfm22_setNominalCarrierFrequency( - struct - pios_rfm22b_dev - * - rfm22b_dev, - uint8_t - init_chan) +static void rfm22_setNominalCarrierFrequency(struct pios_rfm22b_dev *rfm22b_dev, uint8_t init_chan) { - /* - * Set - * the - * frequency - * channels - * to - * start - * at - * 430MHz */ + // Set the frequency channels to start at 430MHz uint32_t frequency_hz = RFM22B_NOMINAL_CARRIER_FREQUENCY; - /* - * The - * step - * size - * is - * 10MHz - * / - * 250 - * channels - * = - * 40khz, - * and - * the - * step - * size - * is - * specified - * in - * 10khz - * increments. */ + // The step size is 10MHz / 250 channels = 40khz, and the step size is specified in 10khz increments. uint8_t freq_hop_step_size = 4; - /* - * holds - * the - * hbsel - * (1 - * or - * 2) */ + // holds the hbsel (1 or 2) uint8_t hbsel; if (frequency_hz < 480000000) { @@ -4777,8 +1614,6 @@ static void rfm22_setNominalCarrierFrequency( } else { hbsel = 1; } - - float freq_mhz = (float)(frequency_hz) / 1000000.0f; float xtal_freq_khz = 30000.0f; float sfreq = freq_mhz / (10.0f * (xtal_freq_khz / 30000.0f) * (1 + hbsel)); @@ -4787,187 +1622,79 @@ static void rfm22_setNominalCarrierFrequency( uint8_t fch = (fc >> 8) & 0xff; uint8_t fcl = fc & 0xff; - - /* - * Claim - * the - * SPI - * bus. */ + // Claim the SPI bus. rfm22_claimBus(rfm22b_dev); - /* - * Setthe - * frequency - * hopping - * step - * size. */ + // Setthe frequency hopping step size. rfm22_write(rfm22b_dev, RFM22_frequency_hopping_step_size, freq_hop_step_size); - /* - * frequency - * hopping - * channel - * (0-255) */ + // frequency hopping channel (0-255) rfm22b_dev->frequency_step_size = 156.25f * hbsel; - /* - * frequency - * hopping - * channel - * (0-255) */ + // frequency hopping channel (0-255) rfm22b_dev->channel = init_chan; rfm22_write(rfm22b_dev, RFM22_frequency_hopping_channel_select, init_chan); - /* - * no - * frequency - * offset */ + // no frequency offset rfm22_write(rfm22b_dev, RFM22_frequency_offset1, 0); rfm22_write(rfm22b_dev, RFM22_frequency_offset2, 0); - /* - * set - * the - * carrier - * frequency */ + // set the carrier frequency rfm22_write(rfm22b_dev, RFM22_frequency_band_select, fb & 0xff); rfm22_write(rfm22b_dev, RFM22_nominal_carrier_frequency1, fch); rfm22_write(rfm22b_dev, RFM22_nominal_carrier_frequency0, fcl); - /* - * Release - * the - * bus */ + // Release the bus rfm22_releaseBus(rfm22b_dev); } /** + * Set the frequency hopping channel. * - * Set - * the - * frequency - * hopping - * channel. - * - * - * @param[in] - * rfm33b_dev - * - * The - * device - * structure - * pointer. + * @param[in] rfm33b_dev The device structure pointer. */ -static bool rfm22_setFreqHopChannel( - struct - pios_rfm22b_dev - * - rfm22b_dev, - uint8_t - channel) +static bool rfm22_setFreqHopChannel(struct pios_rfm22b_dev *rfm22b_dev, uint8_t channel) { - /* - * set - * the - * frequency - * hopping - * channel */ + // set the frequency hopping channel if (rfm22b_dev->channel == channel) { return false; } - #ifdef PIOS_RFM22B_DEBUG_ON_TELEM D3_LED_TOGGLE; -#endif /* - * PIOS_RFM22B_DEBUG_ON_TELEM */ +#endif // PIOS_RFM22B_DEBUG_ON_TELEM rfm22b_dev->channel = channel; rfm22_write_claim(rfm22b_dev, RFM22_frequency_hopping_channel_select, channel); - return true; } /** + * Read the RFM22B interrupt and device status registers * - * Read - * the - * RFM22B - * interrupt - * and - * device - * status - * registers - * - * - * @param[in] - * rfm22b_dev - * - * The - * device - * structure + * @param[in] rfm22b_dev The device structure */ static bool pios_rfm22_readStatus(struct pios_rfm22b_dev *rfm22b_dev) { - /* - * 1. - * Read - * the - * interrupt - * statuses - * with - * burst - * read */ - rfm22_claimBus(rfm22b_dev); /* - * Set - * RC - * and - * the - * semaphore */ - - + // 1. Read the interrupt statuses with burst read + rfm22_claimBus(rfm22b_dev); // Set RC and the semaphore uint8_t write_buf[3] = { RFM22_interrupt_status1 &0x7f, 0xFF, 0xFF }; uint8_t read_buf[3]; - - rfm22_assertCs(rfm22b_dev); PIOS_SPI_TransferBlock(rfm22b_dev->spi_id, write_buf, read_buf, sizeof(write_buf), NULL); rfm22_deassertCs(rfm22b_dev); rfm22b_dev->status_regs.int_status_1.raw = read_buf[1]; rfm22b_dev->status_regs.int_status_2.raw = read_buf[2]; - /* - * Device - * status */ + // Device status rfm22b_dev->status_regs.device_status.raw = rfm22_read(rfm22b_dev, RFM22_device_status); - /* - * EzMAC - * status */ + // EzMAC status rfm22b_dev->status_regs.ezmac_status.raw = rfm22_read(rfm22b_dev, RFM22_ezmac_status); - /* - * Release - * the - * bus */ + // Release the bus rfm22_releaseBus(rfm22b_dev); - /* - * the - * RF - * module - * has - * gone - * and - * done - * a - * reset - * - - * we - * need - * to - * re-initialize - * the - * rf - * module */ + + // the RF module has gone and done a reset - we need to re-initialize the rf module if (rfm22b_dev->status_regs.int_status_2.poweron_reset) { return false; } @@ -4976,35 +1703,12 @@ static bool pios_rfm22_readStatus(struct pios_rfm22b_dev *rfm22b_dev) } /** + * Recover from a failure in receiving a packet. * - * Recover - * from - * a - * failure - * in - * receiving - * a - * packet. - * - * - * @param[in] - * rfm22b_dev - * - * The - * device - * structure - * - * @return - * enum - * pios_radio_event - * - * The - * next - * event - * to - * inject + * @param[in] rfm22b_dev The device structure + * @return enum pios_radio_event The next event to inject */ -static void rfm22_rxFailure(struct pios_rfm22b_dev *rfm22b_dev) +static void rfm22_rxFailure(struct pios_rfm22b_dev *rfm22b_dev) { rfm22b_dev->stats.rx_failure++; rfm22b_dev->rx_buffer_wr = 0; @@ -5014,38 +1718,14 @@ static void /***************************************************************************** -* -* Radio -* Transmit -* and -* Receive -* functions. +* Radio Transmit and Receive functions. *****************************************************************************/ /** + * Start a transmit if possible * - * Start - * a - * transmit - * if - * possible - * - * - * @param[in] - * radio_dev - * The - * device - * structure - * - * @return - * enum - * pios_radio_event - * - * The - * next - * event - * to - * inject + * @param[in] radio_dev The device structure + * @return enum pios_radio_event The next event to inject */ static enum pios_radio_event radio_txStart(struct pios_rfm22b_dev *radio_dev) { @@ -5053,87 +1733,31 @@ static enum pios_radio_event radio_txStart(struct pios_rfm22b_dev *radio_dev) uint8_t len = 0; uint8_t max_data_len = radio_dev->max_packet_len - (radio_dev->ppm_only_mode ? 0 : RS_ECC_NPARITY); - /* - * Don't - * send - * if - * it's - * not - * our - * turn, - * or - * if - * we're - * receiving - * a - * packet. */ + // Don't send if it's not our turn, or if we're receiving a packet. if (!rfm22_timeToSend(radio_dev) || !PIOS_RFM22B_InRxWait((uint32_t)radio_dev)) { return RADIO_EVENT_RX_MODE; } - /* - * Don't - * send - * anything - * if - * we're - * bound - * to - * a - * coordinator - * and - * not - * yet - * connected. */ + + // Don't send anything if we're bound to a coordinator and not yet connected. if (!rfm22_isCoordinator(radio_dev) && !rfm22_isConnected(radio_dev)) { return RADIO_EVENT_RX_MODE; } - /* - * Should - * we - * append - * PPM - * data - * to - * the - * packet? */ + + // Should we append PPM data to the packet? if (radio_dev->ppm_send_mode) { len = RFM22B_PPM_NUM_CHANNELS + (radio_dev->ppm_only_mode ? 2 : 1); - /* - * Ensure - * we - * can - * fit - * the - * PPM - * data - * in - * the - * packet. */ + + // Ensure we can fit the PPM data in the packet. if (max_data_len < len) { return RADIO_EVENT_RX_MODE; } - /* - * The - * first - * byte - * is - * a - * bitmask - * of - * valid - * channels. */ + // The first byte is a bitmask of valid channels. p[0] = 0; - /* - * Read - * the - * PPM - * input. */ + // Read the PPM input. for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS; ++i) { int32_t val = radio_dev->ppm[i]; - - if ((val == PIOS_RCVR_INVALID) || (val == PIOS_RCVR_TIMEOUT)) { p[i + 1] = 0; } else { @@ -5141,144 +1765,66 @@ static enum pios_radio_event radio_txStart(struct pios_rfm22b_dev *radio_dev) p[i + 1] = (val < 1000) ? 0 : ((val >= 1900) ? 255 : (uint8_t)(256 * (val - 1000) / 900)); } } - /* - * The - * last - * byte - * is - * a - * CRC. */ + + // The last byte is a CRC. if (radio_dev->ppm_only_mode) { uint8_t crc = 0; - - for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS + 1; ++i) { crc = PIOS_CRC_updateByte(crc, p[i]); } p[RFM22B_PPM_NUM_CHANNELS + 1] = crc; } } - /* - * Append - * data - * from - * the - * com - * interface - * if - * applicable. */ + + // Append data from the com interface if applicable. if (!radio_dev->ppm_only_mode && radio_dev->tx_out_cb) { - /* - * Try - * to - * get - * some - * data - * to - * send */ + // Try to get some data to send bool need_yield = false; - - len += (radio_dev->tx_out_cb)(radio_dev->tx_out_context, p + len, max_data_len - len, NULL, &need_yield); } - /* - * Always - * send - * a - * packet - * on - * the - * sync - * channel - * if - * this - * modem - * is - * a - * coordinator. */ + + // Always send a packet on the sync channel if this modem is a coordinator. if ((len == 0) && ((radio_dev->channel_index != 0) || !rfm22_isCoordinator(radio_dev))) { return RADIO_EVENT_RX_MODE; } - /* - * Increment - * the - * packet - * sequence - * number. */ + // Increment the packet sequence number. radio_dev->stats.tx_seq++; - /* - * Add - * the - * error - * correcting - * code. */ + + // Add the error correcting code. if (!radio_dev->ppm_only_mode) { if (len != 0) { - encode_data((unsignedchar *)p, len, (unsigned char *)p); + encode_data((unsigned char *)p, len, (unsigned char *)p); } - len += RS_ECC_NPARITY; } - /* - * Transmit - * the - * packet. */ + // Transmit the packet. PIOS_RFM22B_TransmitPacket((uint32_t)radio_dev, p, len); return RADIO_EVENT_NUM_EVENTS; } /** + * Transmit packet data. * - * Transmit - * packet - * data. - * - * - * @param[in] - * rfm22b_dev - * The - * device - * structure - * - * @return - * enum - * pios_radio_event - * - * The - * next - * event - * to - * inject + * @param[in] rfm22b_dev The device structure + * @return enum pios_radio_event The next event to inject */ static enum pios_radio_event radio_txData(struct pios_rfm22b_dev *radio_dev) { enum pios_radio_event ret_event = RADIO_EVENT_NUM_EVENTS; pios_rfm22b_int_result res = PIOS_RFM22B_ProcessTx((uint32_t)radio_dev); - /* - * Is - * the - * transmition - * complete */ + // Is the transmition complete if (res == PIOS_RFM22B_TX_COMPLETE) { radio_dev->tx_complete_ticks = xTaskGetTickCount(); - /* - * Is - * this - * an - * ACK? */ + // Is this an ACK? ret_event = RADIO_EVENT_RX_MODE; radio_dev->tx_packet_handle = 0; radio_dev->tx_data_wr = radio_dev->tx_data_rd = 0; - /* - * Start - * a - * new - * transaction */ + // Start a new transaction radio_dev->packet_start_ticks = 0; #ifdef PIOS_RFM22B_DEBUG_ON_TELEM @@ -5290,190 +1836,65 @@ static enum pios_radio_event radio_txData(struct pios_rfm22b_dev *radio_dev) } /** + * Switch the radio into receive mode. * - * Switch - * the - * radio - * into - * receive - * mode. - * - * - * @param[in] - * rfm22b_dev - * The - * device - * structure - * - * @return - * enum - * pios_radio_event - * - * The - * next - * event - * to - * inject + * @param[in] rfm22b_dev The device structure + * @return enum pios_radio_event The next event to inject */ static enum pios_radio_event radio_setRxMode(struct pios_rfm22b_dev *rfm22b_dev) { if (!PIOS_RFM22B_ReceivePacket((uint32_t)rfm22b_dev, rfm22b_dev->rx_packet)) { return RADIO_EVENT_NUM_EVENTS; } - rfm22b_dev->packet_start_ticks = 0; - /* - * No - * event - * generated */ + // No event generated return RADIO_EVENT_NUM_EVENTS; } /** + * Complete the receipt of a packet. * - * Complete - * the - * receipt - * of - * a - * packet. - * - * - * @param[in] - * radio_dev - * - * The - * device - * structure - * - * @param[in] - * p - * - * The - * packet - * handle - * of - * the - * received - * packet. - * - * @param[in] - * rc_len - * - * The - * number - * of - * bytes - * received. - * - * @return - * enum - * pios_radio_event - * - * The - * next - * event - * to - * inject + * @param[in] radio_dev The device structure + * @param[in] p The packet handle of the received packet. + * @param[in] rc_len The number of bytes received. + * @return enum pios_radio_event The next event to inject */ -static enum pios_radio_event radio_receivePacket( - struct - pios_rfm22b_dev - * - radio_dev, - uint8_t - * - p, - uint16_t - rx_len) +static enum pios_radio_event radio_receivePacket(struct pios_rfm22b_dev *radio_dev, uint8_t *p, uint16_t rx_len) { bool good_packet = true; bool corrected_packet = false; uint8_t data_len = rx_len; - /* - * We - * don't - * rsencode - * ppm - * only - * packets. */ + // We don't rsencode ppm only packets. if (!radio_dev->ppm_only_mode) { data_len -= RS_ECC_NPARITY; - /* - * Attempt - * to - * correct - * any - * errors - * in - * the - * packet. */ + + // Attempt to correct any errors in the packet. if (data_len > 0) { - decode_data((unsignedchar *)p, rx_len); + decode_data((unsigned char *)p, rx_len); good_packet = check_syndrome() == 0; - /* - * We - * have - * an - * error. - * - * Try - * to - * correct - * it. */ - if (!good_packet && (correct_errors_erasures((unsignedchar *)p, rx_len, 0, 0) != 0)) { - /* - * We - * corrected - * it */ + + // We have an error. Try to correct it. + if (!good_packet && (correct_errors_erasures((unsigned char *)p, rx_len, 0, 0) != 0)) { + // We corrected it corrected_packet = true; } } } - /* - * Should - * we - * pull - * PPM - * data - * off - * of - * the - * head - * of - * the - * packet? */ + + // Should we pull PPM data off of the head of the packet? if ((good_packet || corrected_packet) && radio_dev->ppm_recv_mode) { uint8_t ppm_len = RFM22B_PPM_NUM_CHANNELS + (radio_dev->ppm_only_mode ? 2 : 1); - - /* - * Ensure - * the - * packet - * it - * long - * enough */ + // Ensure the packet it long enough if (data_len < ppm_len) { good_packet = false; } - /* - * Verify - * the - * CRC - * if - * this - * is - * a - * PPM - * only - * packet. */ + + // Verify the CRC if this is a PPM only packet. if ((good_packet || corrected_packet) && radio_dev->ppm_only_mode) { uint8_t crc = 0; - - for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS + 1; ++i) { crc = PIOS_CRC_updateByte(crc, p[i]); } @@ -5482,101 +1903,48 @@ static enum pios_radio_event radio_receivePacket( corrected_packet = false; } } + if (good_packet || corrected_packet) { for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS; ++i) { - /* - * Is - * this - * a - * valid - * channel? */ + // Is this a valid channel? if (p[0] & (1 << i)) { uint32_t val = p[i + 1]; - - radio_dev->ppm[i] = (uint16_t)(1000 + val * 900 / 256); } else { radio_dev->ppm[i] = PIOS_RCVR_INVALID; } } + p += RFM22B_PPM_NUM_CHANNELS + 1; data_len -= RFM22B_PPM_NUM_CHANNELS + 1; - /* - * Call - * the - * PPM - * received - * callback - * if - * it's - * available. */ + + // Call the PPM received callback if it's available. if (radio_dev->ppm_callback) { radio_dev->ppm_callback(radio_dev->ppm); } } } - /* - * Set - * the - * packet - * status */ + + // Set the packet status if (good_packet) { rfm22b_add_rx_status(radio_dev, RADIO_GOOD_RX_PACKET); } else if (corrected_packet) { - /* - * We - * corrected - * the - * error. */ + // We corrected the error. rfm22b_add_rx_status(radio_dev, RADIO_CORRECTED_RX_PACKET); } else { - /* - * We - * couldn't - * correct - * the - * error, - * so - * drop - * the - * packet. */ + // We couldn't correct the error, so drop the packet. rfm22b_add_rx_status(radio_dev, RADIO_ERROR_RX_PACKET); } - enum pios_radio_event ret_event = RADIO_EVENT_RX_COMPLETE; - - if (good_packet || corrected_packet) { - /* - * Send - * the - * data - * to - * the - * com - * port */ + // Send the data to the com port bool rx_need_yield; - - if (radio_dev->rx_in_cb && (data_len > 0) && !radio_dev->ppm_only_mode) { (radio_dev->rx_in_cb)(radio_dev->rx_in_context, p, data_len, NULL, &rx_need_yield); } - /* - * We - * only - * synchronize - * the - * clock - * on - * packets - * from - * our - * coordinator - * on - * the - * sync - * channel. */ + + // We only synchronize the clock on packets from our coordinator on the sync channel. if (!rfm22_isCoordinator(radio_dev) && (radio_dev->rx_destination_id == rfm22_destinationID(radio_dev)) && (radio_dev->channel_index == 0)) { rfm22_synchronizeClock(radio_dev); radio_dev->stats.link_state = OPLINKSTATUS_LINKSTATE_CONNECTED; @@ -5590,28 +1958,10 @@ static enum pios_radio_event radio_receivePacket( } /** + * Receive the packet data. * - * Receive - * the - * packet - * data. - * - * - * @param[in] - * rfm22b_dev - * The - * device - * structure - * - * @return - * enum - * pios_radio_event - * - * The - * next - * event - * to - * inject + * @param[in] rfm22b_dev The device structure + * @return enum pios_radio_event The next event to inject */ static enum pios_radio_event radio_rxData(struct pios_rfm22b_dev *radio_dev) { @@ -5621,21 +1971,14 @@ static enum pios_radio_event radio_rxData(struct pios_rfm22b_dev *radio_dev) switch (res) { case PIOS_RFM22B_RX_COMPLETE: - /* - * Receive - * the - * packet. */ + // Receive the packet. ret_event = radio_receivePacket(radio_dev, radio_dev->rx_packet_handle, radio_dev->rx_buffer_wr); radio_dev->rx_buffer_wr = 0; #ifdef PIOS_RFM22B_DEBUG_ON_TELEM D2_LED_OFF; #endif - /* - * Start - * a - * new - * transaction */ + // Start a new transaction radio_dev->packet_start_ticks = 0; break; @@ -5645,9 +1988,7 @@ static enum pios_radio_event radio_rxData(struct pios_rfm22b_dev *radio_dev) break; default: - /* - * do - * nothing. */ + // do nothing. break; } @@ -5655,43 +1996,23 @@ static enum pios_radio_event radio_rxData(struct pios_rfm22b_dev *radio_dev) } /***************************************************************************** -* -* Link -* Statistics -* Functions +* Link Statistics Functions *****************************************************************************/ /** + * Update the modem pair status. * - * Update - * the - * modem - * pair - * status. - * - * - * @param[in] - * rfm22b_dev - * - * The - * device - * structure + * @param[in] rfm22b_dev The device structure */ -static void rfm22_updatePairStatus(struct pios_rfm22b_dev *radio_dev) +static void rfm22_updatePairStatus(struct pios_rfm22b_dev *radio_dev) { - int8_t rssi = radio_dev->rssi_dBm; - int8_t afc = radio_dev->afc_correction_Hz; - uint32_t id = radio_dev->rx_destination_id; + int8_t rssi = radio_dev->rssi_dBm; + int8_t afc = radio_dev->afc_correction_Hz; + uint32_t id = radio_dev->rx_destination_id; - /* - * Have - * we - * seen - * this - * device - * recently? */ - boolfound = false; - uint8_tid_idx = 0; + // Have we seen this device recently? + bool found = false; + uint8_t id_idx = 0; for (; id_idx < OPLINKSTATUS_PAIRIDS_NUMELEM; ++id_idx) { if (radio_dev->pair_stats[id_idx].pairID == id) { @@ -5699,43 +2020,16 @@ static void break; } } - /* - * If - * we - * have - * seen - * it, - * update - * the - * RSSI - * and - * reset - * the - * last - * contact - * counter */ + + // If we have seen it, update the RSSI and reset the last contact counter if (found) { radio_dev->pair_stats[id_idx].rssi = rssi; radio_dev->pair_stats[id_idx].afc_correction = afc; radio_dev->pair_stats[id_idx].lastContact = 0; } else { - /* - * If - * we - * haven't - * seen - * it, - * find - * a - * slot - * to - * put - * it - * in. */ + // If we haven't seen it, find a slot to put it in. uint8_t min_idx = 0; int8_t min_rssi = radio_dev->pair_stats[0].rssi; - - for (id_idx = 1; id_idx < OPLINKSTATUS_PAIRIDS_NUMELEM; ++id_idx) { if (radio_dev->pair_stats[id_idx].rssi < min_rssi) { min_rssi = radio_dev->pair_stats[id_idx].rssi; @@ -5750,180 +2044,53 @@ static void } /** + * Calculate the link quality from the packet receipt, tranmittion statistics. * - * Calculate - * the - * link - * quality - * from - * the - * packet - * receipt, - * tranmittion - * statistics. - * - * - * @param[in] - * rfm22b_dev - * - * The - * device - * structure + * @param[in] rfm22b_dev The device structure */ -static void rfm22_calculateLinkQuality(struct pios_rfm22b_dev *rfm22b_dev) +static void rfm22_calculateLinkQuality(struct pios_rfm22b_dev *rfm22b_dev) { - /* - * Add - * the - * RX - * packet - * statistics */ + // Add the RX packet statistics rfm22b_dev->stats.rx_good = 0; rfm22b_dev->stats.rx_corrected = 0; rfm22b_dev->stats.rx_error = 0; rfm22b_dev->stats.tx_resent = 0; - for (uint8_t i = 0; i < RFM22B_RX_PACKET_STATS_LEN; ++i) { uint32_t val = rfm22b_dev->rx_packet_stats[i]; - - for (uint8_t j = 0; j < 16; ++j) { switch ((val >> (j * 2)) & 0x3) { case RADIO_GOOD_RX_PACKET: rfm22b_dev->stats.rx_good++; break; - case RADIO_CORRECTED_RX_PACKET: rfm22b_dev->stats.rx_corrected++; break; - case RADIO_ERROR_RX_PACKET: rfm22b_dev->stats.rx_error++; break; - case RADIO_RESENT_TX_PACKET: rfm22b_dev->stats.tx_resent++; break; } } } - /* - * Calculate - * the - * link - * quality - * metric, - * which - * is - * related - * to - * the - * number - * of - * good - * packets - * in - * relation - * to - * the - * number - * of - * bad - * packets. - * Note: - * This - * assumes - * that - * the - * number - * of - * packets - * sampled - * for - * the - * stats - * is - * 64. - * Using - * this - * equation, - * error - * and - * resent - * packets - * are - * counted - * as - * -2, - * and - * corrected - * packets - * are - * counted - * as - * -1. - * The - * range - * is - * 0 - * (all - * error - * or - * resent - * packets) - * to - * 128 - * (all - * good - * packets). - */ + // Calculate the link quality metric, which is related to the number of good packets in relation to the number of bad packets. + // Note: This assumes that the number of packets sampled for the stats is 64. + // Using this equation, error and resent packets are counted as -2, and corrected packets are counted as -1. + // The range is 0 (all error or resent packets) to 128 (all good packets). rfm22b_dev->stats.link_quality = 64 + rfm22b_dev->stats.rx_good - rfm22b_dev->stats.rx_error - rfm22b_dev->stats.tx_resent; } /** + * Add a status value to the RX packet status array. * - * Add - * a - * status - * value - * to - * the - * RX - * packet - * status - * array. - * - * - * @param[in] - * rfm22b_dev - * - * The - * device - * structure - * - * @param[in] - * status - * - * The - * packet - * status - * value + * @param[in] rfm22b_dev The device structure + * @param[in] status The packet status value */ -static void rfm22b_add_rx_status( - struct - pios_rfm22b_dev - * - rfm22b_dev, - enum - pios_rfm22b_rx_packet_status - status) +static void rfm22b_add_rx_status(struct pios_rfm22b_dev *rfm22b_dev, enum pios_rfm22b_rx_packet_status status) { - /* - * Shift - * the - * status - * registers */ + // Shift the status registers for (uint8_t i = RFM22B_RX_PACKET_STATS_LEN - 1; i > 0; --i) { rfm22b_dev->rx_packet_stats[i] = (rfm22b_dev->rx_packet_stats[i] << 2) | (rfm22b_dev->rx_packet_stats[i - 1] >> 30); } @@ -5932,58 +2099,26 @@ static void /***************************************************************************** -* -* Connection -* Handling -* Functions +* Connection Handling Functions *****************************************************************************/ /** + * Are we a coordinator modem? * - * Are - * we - * a - * coordinator - * modem? - * - * - * @param[in] - * rfm22b_dev - * - * The - * device - * structure + * @param[in] rfm22b_dev The device structure */ -static bool rfm22_isCoordinator(struct pios_rfm22b_dev *rfm22b_dev) +static bool rfm22_isCoordinator(struct pios_rfm22b_dev *rfm22b_dev) { return rfm22b_dev->coordinator; } /** + * Returns the destination ID to send packets to. * - * Returns - * the - * destination - * ID - * to - * send - * packets - * to. - * - * - * @param[in] - * rfm22b_id - * The - * RFM22B - * device - * index. - * - * @return - * The - * destination - * ID + * @param[in] rfm22b_id The RFM22B device index. + * @return The destination ID */ -uint32_t rfm22_destinationID(struct pios_rfm22b_dev *rfm22b_dev) +uint32_t rfm22_destinationID(struct pios_rfm22b_dev *rfm22b_dev) { if (rfm22_isCoordinator(rfm22b_dev)) { return rfm22b_dev->deviceID; @@ -5996,193 +2131,56 @@ uint32_t /***************************************************************************** -* -* Frequency -* Hopping -* Functions +* Frequency Hopping Functions *****************************************************************************/ /** + * Synchronize the clock after a packet receive from our coordinator on the syncronization channel. + * This function should be called when a packet is received on the synchronization channel. * - * Synchronize - * the - * clock - * after - * a - * packet - * receive - * from - * our - * coordinator - * on - * the - * syncronization - * channel. - * - * This - * function - * should - * be - * called - * when - * a - * packet - * is - * received - * on - * the - * synchronization - * channel. - * - * - * @param[in] - * rfm22b_dev - * - * The - * device - * structure + * @param[in] rfm22b_dev The device structure */ -static void rfm22_synchronizeClock(struct pios_rfm22b_dev *rfm22b_dev) +static void rfm22_synchronizeClock(struct pios_rfm22b_dev *rfm22b_dev) { portTickType start_time = rfm22b_dev->packet_start_ticks; - /* - * This - * packet - * was - * transmitted - * on - * channel - * 0, - * calculate - * the - * time - * delta - * that - * will - * force - * us - * to - * transmit - * on - * channel - * 0 - * at - * the - * time - * this - * packet - * started. */ - uint8_tnum_chan = num_channels[rfm22b_dev->datarate]; - uint16_tfrequency_hop_cycle_time = rfm22b_dev->packet_time * num_chan; - uint16_ttime_delta = start_time % frequency_hop_cycle_time; + // This packet was transmitted on channel 0, calculate the time delta that will force us to transmit on channel 0 at the time this packet started. + uint8_t num_chan = num_channels[rfm22b_dev->datarate]; + uint16_t frequency_hop_cycle_time = rfm22b_dev->packet_time * num_chan; + uint16_t time_delta = start_time % frequency_hop_cycle_time; - /* - * Calculate - * the - * adjustment - * for - * the - * preamble */ - uint8_toffset = (uint8_t)ceil(35000.0F / data_rate[rfm22b_dev->datarate]); + // Calculate the adjustment for the preamble + uint8_t offset = (uint8_t)ceil(35000.0F / data_rate[rfm22b_dev->datarate]); rfm22b_dev->time_delta = frequency_hop_cycle_time - time_delta + offset; } /** + * Return the extimated current clock ticks count on the coordinator modem. + * This is the master clock used for all synchronization. * - * Return - * the - * extimated - * current - * clock - * ticks - * count - * on - * the - * coordinator - * modem. - * - * This - * is - * the - * master - * clock - * used - * for - * all - * synchronization. - * - * - * @param[in] - * rfm22b_dev - * - * The - * device - * structure + * @param[in] rfm22b_dev The device structure */ -static portTickType rfm22_coordinatorTime( - struct - pios_rfm22b_dev - * - rfm22b_dev, - portTickType - ticks) +static portTickType rfm22_coordinatorTime(struct pios_rfm22b_dev *rfm22b_dev, portTickType ticks) { if (rfm22_isCoordinator(rfm22b_dev)) { return ticks; } - return ticks + rfm22b_dev->time_delta; } /** + * Return true if this modem is in the send interval, which allows the modem to initiate a transmit. * - * Return - * true - * if - * this - * modem - * is - * in - * the - * send - * interval, - * which - * allows - * the - * modem - * to - * initiate - * a - * transmit. - * - * - * @param[in] - * rfm22b_dev - * - * The - * device - * structure + * @param[in] rfm22b_dev The device structure */ -static bool rfm22_timeToSend(struct pios_rfm22b_dev *rfm22b_dev) +static bool rfm22_timeToSend(struct pios_rfm22b_dev *rfm22b_dev) { - portTickType time = rfm22_coordinatorTime(rfm22b_dev, xTaskGetTickCount()); - bool is_coordinator = rfm22_isCoordinator(rfm22b_dev); + portTickType time = rfm22_coordinatorTime(rfm22b_dev, xTaskGetTickCount()); + bool is_coordinator = rfm22_isCoordinator(rfm22b_dev); - /* - * If - * this - * is - * a - * one-way - * link, - * only - * the - * coordinator - * can - * send. */ - uint8_tpacket_period = rfm22b_dev->packet_time; + // If this is a one-way link, only the coordinator can send. + uint8_t packet_period = rfm22b_dev->packet_time; if (rfm22b_dev->one_way_link) { if (is_coordinator) { @@ -6191,151 +2189,46 @@ static bool return false; } } + if (!is_coordinator) { time += packet_period - 1; } else { time -= 1; } - return (time % (packet_period * 2)) == 0; } /** + * Calculate the nth channel index. * - * Calculate - * the - * nth - * channel - * index. - * - * - * @param[in] - * rfm22b_dev - * - * The - * device - * structure - * - * @param[in] - * index - * - * The - * channel - * index - * to - * calculate + * @param[in] rfm22b_dev The device structure + * @param[in] index The channel index to calculate */ -static uint8_t rfm22_calcChannel( - struct - pios_rfm22b_dev - * - rfm22b_dev, - uint8_t - index) +static uint8_t rfm22_calcChannel(struct pios_rfm22b_dev *rfm22b_dev, uint8_t index) { - /* - * Make - * sure - * we - * don't - * index - * outside - * of - * the - * range. */ + // Make sure we don't index outside of the range. uint8_t num_chan = num_channels[rfm22b_dev->datarate]; uint8_t idx = index % num_chan; - /* - * Are - * we - * switching - * to - * a - * new - * channel? */ + // Are we switching to a new channel? if (idx != rfm22b_dev->channel_index) { - /* - * If - * the - * on_sync_channel - * flag - * is - * set, - * it - * means - * that - * we - * were - * on - * the - * sync - * channel, - * but - * no - * packet - * was - * received, - * so - * transition - * to - * a - * non-connected - * state. */ + // If the on_sync_channel flag is set, it means that we were on the sync channel, but no packet was received, so transition to a non-connected state. if (!rfm22_isCoordinator(rfm22b_dev) && (rfm22b_dev->channel_index == 0) && rfm22b_dev->on_sync_channel) { rfm22b_dev->on_sync_channel = false; - /* - * Set - * the - * link - * state - * to - * disconnected. */ + + // Set the link state to disconnected. if (rfm22b_dev->stats.link_state == OPLINKSTATUS_LINKSTATE_CONNECTED) { rfm22b_dev->stats.link_state = OPLINKSTATUS_LINKSTATE_DISCONNECTED; - - /* - * Set - * the - * PPM - * outputs - * to - * INVALID */ + // Set the PPM outputs to INVALID for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS; ++i) { rfm22b_dev->ppm[i] = PIOS_RCVR_INVALID; } } - /* - * Stay - * on - * the - * sync - * channel. */ + // Stay on the sync channel. idx = 0; } else if (idx == 0) { - /* - * If - * we're - * switching - * to - * the - * sync - * channel, - * set - * a - * flag - * that - * can - * be - * used - * to - * detect - * if - * a - * packet - * was - * received. */ + // If we're switching to the sync channel, set a flag that can be used to detect if a packet was received. rfm22b_dev->on_sync_channel = true; } @@ -6346,97 +2239,29 @@ static uint8_t } /** + * Calculate what the current channel shold be. * - * Calculate - * what - * the - * current - * channel - * shold - * be. - * - * - * @param[in] - * rfm22b_dev - * - * The - * device - * structure + * @param[in] rfm22b_dev The device structure */ -static uint8_t rfm22_calcChannelFromClock(struct pios_rfm22b_dev *rfm22b_dev) +static uint8_t rfm22_calcChannelFromClock(struct pios_rfm22b_dev *rfm22b_dev) { portTickType time = rfm22_coordinatorTime(rfm22b_dev, xTaskGetTickCount()); - - /* - * Divide - * time - * into - * 8ms - * blocks. - * - * Coordinator - * sends - * in - * first - * 2 - * ms, - * and - * remote - * send - * in - * 5th - * and - * 6th - * ms. - * Channel - * changes - * occur - * in - * the - * last - * 2 - * ms. - - */ - uint8_tnum_chan = num_channels[rfm22b_dev->datarate]; - uint8_tn = (time / rfm22b_dev->packet_time) % num_chan; + // Divide time into 8ms blocks. Coordinator sends in first 2 ms, and remote send in 5th and 6th ms. + // Channel changes occur in the last 2 ms. + uint8_t num_chan = num_channels[rfm22b_dev->datarate]; + uint8_t n = (time / rfm22b_dev->packet_time) % num_chan; return rfm22_calcChannel(rfm22b_dev, n); } /** + * Change channels to the calculated current channel. * - * Change - * channels - * to - * the - * calculated - * current - * channel. - * - * - * @param[in] - * rfm22b_dev - * - * The - * device - * structure + * @param[in] rfm22b_dev The device structure */ -static bool rfm22_changeChannel(struct pios_rfm22b_dev *rfm22b_dev) +static bool rfm22_changeChannel(struct pios_rfm22b_dev *rfm22b_dev) { - /* - * A - * disconnected - * non-coordinator - * modem - * should - * sit - * on - * the - * sync - * channel - * until - * connected. */ + // A disconnected non-coordinator modem should sit on the sync channel until connected. if (!rfm22_isCoordinator(rfm22b_dev) && !rfm22_isConnected(rfm22b_dev)) { return rfm22_setFreqHopChannel(rfm22b_dev, rfm22_calcChannel(rfm22b_dev, 0)); } else { @@ -6446,88 +2271,37 @@ static bool /***************************************************************************** -* -* Error -* Handling -* Functions +* Error Handling Functions *****************************************************************************/ /** + * Recover from a transmit failure. * - * Recover - * from - * a - * transmit - * failure. - * - * - * @param[in] - * rfm22b_dev - * The - * device - * structure - * - * @return - * enum - * pios_radio_event - * - * The - * next - * event - * to - * inject + * @param[in] rfm22b_dev The device structure + * @return enum pios_radio_event The next event to inject */ static enum pios_radio_event rfm22_txFailure(struct pios_rfm22b_dev *rfm22b_dev) { rfm22b_dev->stats.tx_failure++; rfm22b_dev->packet_start_ticks = 0; rfm22b_dev->tx_data_wr = rfm22b_dev->tx_data_rd = 0; - return RADIO_EVENT_TX_START; } /** + * Recover from a timeout event. * - * Recover - * from - * a - * timeout - * event. - * - * - * @param[in] - * rfm22b_dev - * - * The - * device - * structure - * - * @return - * enum - * pios_radio_event - * - * The - * next - * event - * to - * inject + * @param[in] rfm22b_dev The device structure + * @return enum pios_radio_event The next event to inject */ static enum pios_radio_event rfm22_timeout(struct pios_rfm22b_dev *rfm22b_dev) { rfm22b_dev->stats.timeouts++; rfm22b_dev->packet_start_ticks = 0; - /* - * Release - * the - * Tx - * packet - * if - * it's - * set. */ + // Release the Tx packet if it's set. if (rfm22b_dev->tx_packet_handle != 0) { rfm22b_dev->tx_data_rd = rfm22b_dev->tx_data_wr = 0; } - rfm22b_dev->rfm22b_state = RFM22B_STATE_TRANSITION; rfm22b_dev->rx_buffer_wr = 0; TX_LED_OFF; @@ -6538,92 +2312,33 @@ static enum pios_radio_event rfm22_timeout(struct pios_rfm22b_dev *rfm22b_dev) D3_LED_OFF; D4_LED_OFF; #endif - return RADIO_EVENT_RX_MODE; } /** + * Recover from a severe error. * - * Recover - * from - * a - * severe - * error. - * - * - * @param[in] - * rfm22b_dev - * - * The - * device - * structure - * - * @return - * enum - * pios_radio_event - * - * The - * next - * event - * to - * inject + * @param[in] rfm22b_dev The device structure + * @return enum pios_radio_event The next event to inject */ static enum pios_radio_event rfm22_error(struct pios_rfm22b_dev *rfm22b_dev) { rfm22b_dev->stats.resets++; rfm22_clearLEDs(); - return RADIO_EVENT_INITIALIZE; } /** + * A fatal error has occured in the state machine. + * this should not happen. * - * A - * fatal - * error - * has - * occured - * in - * the - * state - * machine. - * - * this - * should - * not - * happen. - * - * - * @parem - * [in] - * rfm22b_dev - * - * The - * device - * structure - * - * @return - * enum - * pios_radio_event - * - * The - * next - * event - * to - * inject + * @parem [in] rfm22b_dev The device structure + * @return enum pios_radio_event The next event to inject */ static enum pios_radio_event rfm22_fatal_error(__attribute__((unused)) struct pios_rfm22b_dev *rfm22b_dev) { - /* - * RF - * module - * error - * .. - * flash - * the - * LED's */ + // RF module error .. flash the LED's rfm22_clearLEDs(); - for (unsigned int j = 0; j < 16; j++) { USB_LED_ON; LINK_LED_ON; @@ -6639,6 +2354,7 @@ static enum pios_radio_event rfm22_fatal_error(__attribute__((unused)) struct pi PIOS_DELAY_WaitmS(200); } + PIOS_DELAY_WaitmS(1000); PIOS_Assert(0); @@ -6648,79 +2364,30 @@ static enum pios_radio_event rfm22_fatal_error(__attribute__((unused)) struct pi /***************************************************************************** -* -* Utility -* Functions +* Utility Functions *****************************************************************************/ /** + * Calculate the time difference between the start time and end time. + * Times are in ticks. Also handles rollover. * - * Calculate - * the - * time - * difference - * between - * the - * start - * time - * and - * end - * time. - * - * Times - * are - * in - * ticks. - * - * Also - * handles - * rollover. - * - * - * @param[in] - * start_time - * - * The - * start - * time - * in - * ticks. - * - * @param[in] - * end_time - * - * The - * end - * time - * in - * ticks. + * @param[in] start_time The start time in ticks. + * @param[in] end_time The end time in ticks. */ -static uint32_t pios_rfm22_time_difference_ms( - portTickType - start_time, - portTickType - end_time) +static uint32_t pios_rfm22_time_difference_ms(portTickType start_time, portTickType end_time) { if (end_time >= start_time) { return (end_time - start_time) * portTICK_RATE_MS; } - - /* - * Rollover */ + // Rollover return ((portMAX_DELAY - start_time) + end_time) * portTICK_RATE_MS; } /** - * - * Allocate - * the - * device - * structure + * Allocate the device structure */ #if defined(PIOS_INCLUDE_FREERTOS) -static struct -pios_rfm22b_dev -*pios_rfm22_alloc(void) +static struct pios_rfm22b_dev *pios_rfm22_alloc(void) { struct pios_rfm22b_dev *rfm22b_dev; @@ -6731,18 +2398,11 @@ pios_rfm22b_dev } rfm22b_dev->magic = PIOS_RFM22B_DEV_MAGIC; - return rfm22b_dev; } #else -static -struct -pios_rfm22b_dev - pios_rfm22b_devs -[PIOS_RFM22B_MAX_DEVS]; -static -uint8_t - pios_rfm22b_num_devs; +static struct pios_rfm22b_dev pios_rfm22b_devs[PIOS_RFM22B_MAX_DEVS]; +static uint8_t pios_rfm22b_num_devs; static struct pios_rfm22b_dev *pios_rfm22_alloc(void) { struct pios_rfm22b_dev *rfm22b_dev; @@ -6759,15 +2419,9 @@ static struct pios_rfm22b_dev *pios_rfm22_alloc(void) #endif /* if defined(PIOS_INCLUDE_FREERTOS) */ /** - * - * Turn - * off - * all - * of - * the - * LEDs + * Turn off all of the LEDs */ -static void rfm22_clearLEDs(void) +static void rfm22_clearLEDs(void) { LINK_LED_OFF; RX_LED_OFF; @@ -6782,29 +2436,15 @@ static void /***************************************************************************** -* -* SPI -* Read/Write -* Functions +* SPI Read/Write Functions *****************************************************************************/ /** + * Assert the chip select line. * - * Assert - * the - * chip - * select - * line. - * - * - * @param[in] - * rfm22b_dev - * - * The - * RFM22B - * device. + * @param[in] rfm22b_dev The RFM22B device. */ -static void rfm22_assertCs(struct pios_rfm22b_dev *rfm22b_dev) +static void rfm22_assertCs(struct pios_rfm22b_dev *rfm22b_dev) { PIOS_DELAY_WaituS(1); if (rfm22b_dev->spi_id != 0) { @@ -6813,24 +2453,11 @@ static void } /** + * Deassert the chip select line. * - * Deassert - * the - * chip - * select - * line. - * - * - * @param[in] - * rfm22b_dev - * - * The - * RFM22B - * device - * structure - * pointer. + * @param[in] rfm22b_dev The RFM22B device structure pointer. */ -static void rfm22_deassertCs(struct pios_rfm22b_dev *rfm22b_dev) +static void rfm22_deassertCs(struct pios_rfm22b_dev *rfm22b_dev) { if (rfm22b_dev->spi_id != 0) { PIOS_SPI_RC_PinSet(rfm22b_dev->spi_id, rfm22b_dev->slave_num, 1); @@ -6838,23 +2465,11 @@ static void } /** + * Claim the SPI bus. * - * Claim - * the - * SPI - * bus. - * - * - * @param[in] - * rfm22b_dev - * - * The - * RFM22B - * device - * structure - * pointer. + * @param[in] rfm22b_dev The RFM22B device structure pointer. */ -static void rfm22_claimBus(struct pios_rfm22b_dev *rfm22b_dev) +static void rfm22_claimBus(struct pios_rfm22b_dev *rfm22b_dev) { if (rfm22b_dev->spi_id != 0) { PIOS_SPI_ClaimBus(rfm22b_dev->spi_id); @@ -6862,23 +2477,11 @@ static void } /** + * Release the SPI bus. * - * Release - * the - * SPI - * bus. - * - * - * @param[in] - * rfm22b_dev - * - * The - * RFM22B - * device - * structure - * pointer. + * @param[in] rfm22b_dev The RFM22B device structure pointer. */ -static void rfm22_releaseBus(struct pios_rfm22b_dev *rfm22b_dev) +static void rfm22_releaseBus(struct pios_rfm22b_dev *rfm22b_dev) { if (rfm22b_dev->spi_id != 0) { PIOS_SPI_ReleaseBus(rfm22b_dev->spi_id); @@ -6886,173 +2489,45 @@ static void } /** + * Claim the semaphore and write a byte to a register * - * Claim - * the - * semaphore - * and - * write - * a - * byte - * to - * a - * register - * - * - * @param[in] - * rfm22b_dev - * - * The - * RFM22B - * device. - * - * @param[in] - * addr - * The - * address - * to - * write - * to - * - * @param[in] - * data - * The - * datat - * to - * write - * to - * that - * address + * @param[in] rfm22b_dev The RFM22B device. + * @param[in] addr The address to write to + * @param[in] data The datat to write to that address */ -static void rfm22_write_claim( - struct - pios_rfm22b_dev - * - rfm22b_dev, - uint8_t - addr, - uint8_t - data) +static void rfm22_write_claim(struct pios_rfm22b_dev *rfm22b_dev, uint8_t addr, uint8_t data) { rfm22_claimBus(rfm22b_dev); rfm22_assertCs(rfm22b_dev); - - uint8_t buf[2] = { addr | 0x80, data }; - - PIOS_SPI_TransferBlock(rfm22b_dev->spi_id, buf, NULL, sizeof(buf), NULL); rfm22_deassertCs(rfm22b_dev); rfm22_releaseBus(rfm22b_dev); } /** + * Write a byte to a register without claiming the semaphore * - * Write - * a - * byte - * to - * a - * register - * without - * claiming - * the - * semaphore - * - * - * @param[in] - * rfm22b_dev - * - * The - * RFM22B - * device. - * - * @param[in] - * addr - * The - * address - * to - * write - * to - * - * @param[in] - * data - * The - * datat - * to - * write - * to - * that - * address + * @param[in] rfm22b_dev The RFM22B device. + * @param[in] addr The address to write to + * @param[in] data The datat to write to that address */ -static void rfm22_write( - struct - pios_rfm22b_dev - * - rfm22b_dev, - uint8_t - addr, - uint8_t - data) +static void rfm22_write(struct pios_rfm22b_dev *rfm22b_dev, uint8_t addr, uint8_t data) { rfm22_assertCs(rfm22b_dev); - - uint8_t buf[2] = { addr | 0x80, data }; - - PIOS_SPI_TransferBlock(rfm22b_dev->spi_id, buf, NULL, sizeof(buf), NULL); rfm22_deassertCs(rfm22b_dev); } /** + * Read a byte from an RFM22b register without claiming the bus * - * Read - * a - * byte - * from - * an - * RFM22b - * register - * without - * claiming - * the - * bus - * - * - * @param[in] - * rfm22b_dev - * - * The - * RFM22B - * device - * structure - * pointer. - * - * @param[in] - * addr - * The - * address - * to - * read - * from - * - * @return - * Returns - * the - * result - * of - * the - * register - * read + * @param[in] rfm22b_dev The RFM22B device structure pointer. + * @param[in] addr The address to read from + * @return Returns the result of the register read */ -static uint8_t rfm22_read( - struct - pios_rfm22b_dev - * - rfm22b_dev, - uint8_t - addr) +static uint8_t rfm22_read(struct pios_rfm22b_dev *rfm22b_dev, uint8_t addr) { uint8_t out[2] = { addr &0x7F, 0xFF }; uint8_t in[2]; @@ -7060,15 +2535,12 @@ static uint8_t rfm22_read( rfm22_assertCs(rfm22b_dev); PIOS_SPI_TransferBlock(rfm22b_dev->spi_id, out, in, sizeof(out), NULL); rfm22_deassertCs(rfm22b_dev); - return in[1]; } #endif /* PIOS_INCLUDE_RFM22B */ /** - * - * @} - * - * @} + * @} + * @} */