- model.raw[current_input] = adc_in;
- // New format on stick values
- // The calculations happen around the center point, the values
- // need to arrive at 0...100 of the range "center-to-edge",
- // and must end up as negative on the ... negative side of center.
-
- if ( adc_in < input_cal.center[current_input] )
- {
- // The stick is on the negative side, so the range is
- // from the lowest possible value to center, and we must
- // make this a negative percentage value.
- max = input_cal.min[current_input];
- min = input_cal.center[current_input];
- fact = -100;
- }
- else
- {
- // The stick is at center, or on the positive side.
- // Thus, the range is from center to max, and
- // we need positive percentages.
- min = input_cal.center[current_input];
- max = input_cal.max[current_input];
- fact = 100;
- }
- // Calculate the percentage that the current stick position is at
- // in the given range, referenced to or from center, depending :P
- model.stick[current_input] = fact * ((float)adc_in - min ) / (max - min);
-
- // If this input is configured to be reversed, simply do a sign-flip :D
- if ( model.rev[current_input] ) model.stick[current_input] *= -1;
-
- // Dual-rate calculation :D
- // This is very repetitive code. It should be fast, but it may waste code-space.
- float dr_val;
- // Test to see if dualrate-switch #1 applies to channel...
- if ( ( current_input == ( model.dr[0]-1) ) || ( current_input == ( model.dr[1]-1) ) )
- {
- if ( !keys[KEY_DR1] )
- dr_val = ((float)model.dr[4])/100.0;
- else
- dr_val = ((float)model.dr[5])/100.0;
-
- model.stick[current_input] *= dr_val;
- }
- else
- // Test to see if dualrate-switch #1 applies to channel...
- if ( ( current_input == ( model.dr[2]-1) ) || ( current_input == ( model.dr[3]-1) ) )
- {
- if ( !keys[KEY_DR2] )
- dr_val = ((float)model.dr[6])/100.0;
- else
- dr_val = ((float)model.dr[7])/100.0;
-
- model.stick[current_input] *= dr_val;
- }
- }
+ model.raw[current_input] = adc_in;
+ // New format on stick values
+ // The calculations happen around the center point, the values
+ // need to arrive at 0...100 of the range "center-to-edge",
+ // and must end up as negative on the ... negative side of center.
+
+ if ( adc_in < input_cal.center[current_input] )
+ {
+ // The stick is on the negative side, so the range is
+ // from the lowest possible value to center, and we must
+ // make this a negative percentage value.
+ max = input_cal.min[current_input];
+ min = input_cal.center[current_input];
+ fact = -100;
+ }
+ else
+ {
+ // The stick is at center, or on the positive side.
+ // Thus, the range is from center to max, and
+ // we need positive percentages.
+ min = input_cal.center[current_input];
+ max = input_cal.max[current_input];
+ fact = 100;
+ }
+ // Calculate the percentage that the current stick position is at
+ // in the given range, referenced to or from center, depending :P
+ model.stick[current_input] = fact * ((float)adc_in - min ) / (max - min);
+
+ // If this input is configured to be reversed, simply do a sign-flip :D
+ if ( model.rev[current_input] ) model.stick[current_input] *= -1;
+
+ // Dual-rate calculation :D
+ // This is very repetitive code. It should be fast, but it may waste code-space.
+ float dr_val;
+ // Test to see if dualrate-switch #1 applies to channel...
+ if ( ( current_input == ( model.dr[0]-1) ) || ( current_input == ( model.dr[1]-1) ) )
+ {
+ if ( !keys[KEY_DR1] )
+ dr_val = ((float)model.dr[4])/100.0;
+ else
+ dr_val = ((float)model.dr[5])/100.0;
+
+ model.stick[current_input] *= dr_val;
+ }
+ else
+ // Test to see if dualrate-switch #1 applies to channel...
+ if ( ( current_input == ( model.dr[2]-1) ) || ( current_input == ( model.dr[3]-1) ) )
+ {
+ if ( !keys[KEY_DR2] )
+ dr_val = ((float)model.dr[6])/100.0;
+ else
+ dr_val = ((float)model.dr[7])/100.0;
+
+ model.stick[current_input] *= dr_val;
+ }
+ }