Subversion Repositories FlightCtrl

Rev

Rev 1171 | Rev 1213 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1171 Rev 1172
Line 176... Line 176...
176
                ByteHigh = c;
176
                ByteHigh = c;
Line 177... Line 177...
177
               
177
               
178
                if (FrameCnt == 2)
178
                if (FrameCnt == 2)
179
                    {
179
                    {
180
                    // is 1st Byte of Channel-data
-
 
181
                       
180
                    // is 1st Byte of Channel-data
182
                        // Frame 1 with Channel 1-7 comming next
181
                        // Frame 1 with Channel 1-7 comming next
183
                        Frame2 = 0;
182
                        Frame2 = 0;
184
                        if ( ByteHigh & 0x80 )
183
                        if(ByteHigh & 0x80)
185
                            {
184
                            {
Line 205... Line 204...
205
                signal -= 0x200;                // Offset, range 0x000..0x3ff?
204
                signal -= 0x200;                // Offset, range 0x000..0x3ff?
206
                signal = signal/3;              // scaling to fit PPM resolution
205
                signal = signal/3;              // scaling to fit PPM resolution
Line 207... Line 206...
207
               
206
               
208
                if (index >= 0  &&  index <= 10)
207
                if(index >= 0  &&  index <= 10)
209
                    {
-
 
210
                                                               
208
                    {
211
                        if(abs(signal - PPM_in[index]) < 6)
-
 
212
                                {
209
                // Stabiles Signal
213
                                if(SenderOkay < 200)
-
 
214
                                        {
-
 
215
                                        SenderOkay += 10;
-
 
216
                                        }
-
 
217
                                }
210
                if(abs(signal - PPM_in[index]) < 6) { if(SenderOkay < 200) SenderOkay += 10; else SenderOkay = 200;}
218
                        tmp = (3 * (PPM_in[index]) + signal) / 4;  
211
                tmp = (3 * (PPM_in[index]) + signal) / 4;  
219
                        if(tmp > signal+1)
-
 
220
                                {
-
 
221
                                tmp--;
-
 
222
                                }
-
 
223
                        else
-
 
224
                                {
212
                if(tmp > signal+1) tmp--; else
225
                                if(tmp < signal-1)
-
 
226
                                        {
-
 
227
                                        tmp++;
-
 
228
                                        }
-
 
229
                                }
-
 
230
                        if(SenderOkay >= 195)
-
 
231
                                {
213
                if(tmp < signal-1) tmp++;
232
                                PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3;
-
 
233
                                }
-
 
234
                        else
-
 
235
                                {
214
                if(SenderOkay >= 180)  PPM_diff[index] = ((tmp - PPM_in[index]) / 3) * 3;
236
                                PPM_diff[index] = 0;
-
 
237
                                }
-
 
238
                       
215
                else PPM_diff[index] = 0;
239
                        PPM_in[index] = tmp;
216
                PPM_in[index] = tmp;
240
                        }
217
                        }
241
                }
218
                }
242
        else
219
        else
Line 261... Line 238...
261
                // new frame next, nach fruehestens 7ms erwartet
238
                // new frame next, nach fruehestens 7ms erwartet
262
                FrameCnt = 0;
239
                FrameCnt = 0;
263
                Frame2 = 0;
240
                Frame2 = 0;
264
                Sync = 0;
241
                Sync = 0;
265
                }
242
                }
266
 
-
 
267
        // Zeit bis zum nächsten Zeichen messen
243
        // Zeit bis zum nächsten Zeichen messen
268
        FrameTimer = SetDelay (7);
244
        FrameTimer = SetDelay(7);
269
   }
245
   }
270
}  
246
}