Rev 1775 | Rev 1868 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1775 | Rev 1796 | ||
---|---|---|---|
Line 166... | Line 166... | ||
166 | NewPpmData = 0; // Null means NewData for the first 4 channels |
166 | NewPpmData = 0; // Null means NewData for the first 4 channels |
167 | } |
167 | } |
168 | // synchronize channel index |
168 | // synchronize channel index |
169 | index = 1; |
169 | index = 1; |
170 | } else { // within the PPM frame |
170 | } else { // within the PPM frame |
171 | if(index < MAX_CHANNELS-1) // PPM24 supports 12 channels |
171 | if(index < MAX_CHANNELS-1) { // PPM24 supports 12 channels |
172 | { |
- | |
173 | // check for valid signal length (0.8 ms < signal < 2.1984 ms) |
172 | // check for valid signal length (0.8 ms < signal < 2.1984 ms) |
174 | // signal range is from 1.0ms/3.2us = 312 to 2.0ms/3.2us = 625 |
173 | // signal range is from 1.0ms/3.2us = 312 to 2.0ms/3.2us = 625 |
175 | if((signal > 250) && (signal < 687)) { |
174 | if((signal > 250) && (signal < 687)) { |
176 | // shift signal to zero symmetric range -154 to 159 |
175 | // shift signal to zero symmetric range -154 to 159 |
177 | signal -= 470; // offset of 1.4912 ms ??? (469 * 3.2µs = 1.5008 ms) |
176 | signal -= 470; // offset of 1.4912 ms ??? (469 * 3.2µs = 1.5008 ms) |
Line 244... | Line 243... | ||
244 | void RC_update() { |
243 | void RC_update() { |
245 | int16_t tmp1, tmp2; |
244 | int16_t tmp1, tmp2; |
246 | if(RC_Quality) { |
245 | if(RC_Quality) { |
247 | RC_Quality--; |
246 | RC_Quality--; |
248 | if (NewPpmData-- == 0) { |
247 | if (NewPpmData-- == 0) { |
249 | RC_PRTY[CONTROL_PITCH] = RCChannel(CH_PITCH) * staticParams.StickP - /* stickOffsetPitch */ + RCDiff(CH_PITCH) * staticParams.StickD; |
248 | RC_PRTY[CONTROL_PITCH] = RCChannel(CH_PITCH) * staticParams.StickP + RCDiff(CH_PITCH) * staticParams.StickD; |
250 | RC_PRTY[CONTROL_ROLL] = RCChannel(CH_ROLL) * staticParams.StickP - /* stickOffsetRoll */ + RCDiff(CH_ROLL) * staticParams.StickD; |
249 | RC_PRTY[CONTROL_ROLL] = RCChannel(CH_ROLL) * staticParams.StickP + RCDiff(CH_ROLL) * staticParams.StickD; |
251 | RC_PRTY[CONTROL_THROTTLE] = RCChannel(CH_THROTTLE) + PPM_diff[staticParams.ChannelAssignment[CH_THROTTLE]] * dynamicParams.UserParams[3] + 120; |
250 | RC_PRTY[CONTROL_THROTTLE] = RCChannel(CH_THROTTLE) + RCDiff(CH_THROTTLE) * dynamicParams.UserParams[3] + 120; |
252 | if (RC_PRTY[CONTROL_THROTTLE] < 0) RC_PRTY[CONTROL_THROTTLE] = 0; // Throttle is non negative. |
251 | if (RC_PRTY[CONTROL_THROTTLE] < 0) RC_PRTY[CONTROL_THROTTLE] = 0; // Throttle is non negative. |
253 | tmp1 = -RCChannel(CH_YAW) - RCDiff(CH_YAW); |
252 | tmp1 = -RCChannel(CH_YAW) - RCDiff(CH_YAW); |
254 | // exponential stick sensitivity in yawing rate |
253 | // exponential stick sensitivity in yawing rate |
255 | tmp2 = (int32_t) staticParams.StickYawP * ((int32_t)tmp1 * abs(tmp1)) / 512L; // expo y = ax + bx^2 |
254 | tmp2 = (int32_t) staticParams.StickYawP * ((int32_t)tmp1 * abs(tmp1)) / 512L; // expo y = ax + bx^2 |
256 | tmp2 += (staticParams.StickYawP * tmp1) / 4; |
255 | tmp2 += (staticParams.StickYawP * tmp1) / 4; |