@@ -201,14 +201,14 @@ void detectInput(){
201
201
// if ((smallestnumber > 2000 )&&(smallestnumber < 3000)){
202
202
// oneshot42 = 1;
203
203
// }
204
- if (smallestnumber > 1000 ){
204
+ if (smallestnumber > 300 && smallestnumber < 20000 ){
205
205
servoPwm = 1 ;
206
206
ic_timer_prescaler = 47 ;
207
207
armed_count_threshold = 35 ;
208
208
buffersize = 2 ;
209
209
}
210
210
211
- if (smallestnumber == 0 ){
211
+ if (smallestnumber == 0 || smallestnumber == 20000 ){
212
212
inputSet = 0 ;
213
213
}else {
214
214
@@ -218,125 +218,7 @@ void detectInput(){
218
218
}
219
219
220
220
221
- //void computeMSInput(){
222
-
223
- //int lastnumber = dma_buffer[0];
224
- //for ( int j = 1 ; j < 2; j++){
225
-
226
- //if(((dma_buffer[j] - lastnumber) < 1500) && ((dma_buffer[j] - lastnumber) > 0)){ // blank space
227
-
228
- //newinput = map((dma_buffer[j] - lastnumber),243,1200, 0, 2000);
229
- //break;
230
- //}
231
- //lastnumber = dma_buffer[j];
232
- //}
233
- //}
234
-
235
-
236
- //void computeServoInput(){
237
-
238
- //int lastnumber = dma_buffer[0];
239
- //for ( int j = 1 ; j < 2; j++){
240
-
241
- //if(((dma_buffer[j] - lastnumber) >900 ) && ((dma_buffer[j] - lastnumber) < 2150)){ // blank space
242
-
243
- //if(bi_direction){
244
- //if(dma_buffer[j] - lastnumber <= servo_neutral){
245
- //servorawinput = map((dma_buffer[j] - lastnumber), servo_low_threshold, servo_neutral, 0, 1000);
246
- //}else{
247
- //servorawinput = map((dma_buffer[j] - lastnumber), servo_neutral+1, servo_high_threshold, 1001, 2000);
248
- //}
249
- //}else{
250
- //servorawinput = map((dma_buffer[j] - lastnumber), servo_low_threshold, servo_high_threshold, 0, 2000);
251
- //}
252
- //break;
253
- //}
254
- //lastnumber = dma_buffer[j];
255
- //}
256
- //if (servorawinput - newinput > max_servo_deviation){
257
- //newinput += max_servo_deviation;
258
- //}else if(newinput - servorawinput > max_servo_deviation){
259
- //newinput -= max_servo_deviation;
260
- //}else{
261
- //newinput = servorawinput;
262
- //}
263
-
264
- //}
265
-
266
- //void transfercomplete(){
267
- //if(armed && dshot_telemetry){
268
- //if(out_put){
269
-
270
-
271
- //receiveDshotDma();
272
- //return;
273
- //}else{
274
-
275
- //sendDshotDma();
276
- //make_dshot_package();
277
- //computeDshotDMA();
278
- //return;
279
- //}
280
- //}
281
-
282
- //if (inputSet == 0){
283
- //detectInput();
284
- //receiveDshotDma();
285
- //return;
286
- //}
287
-
288
- //if (inputSet == 1){
289
- //if(!armed){
290
- //signaltimeout = 0;
291
- //if (adjusted_input < 0){
292
- //adjusted_input = 0;
293
- //}
294
- //if (adjusted_input == 0){ // note this in input..not newinput so it will be adjusted be main loop
295
- //zero_input_count++;
296
- //}else{
297
- //zero_input_count = 0;
298
- //}
299
- //}
300
-
301
- //if(dshot_telemetry){
302
- //if(out_put){
303
- //// TIM17->CNT = 0;
304
- //make_dshot_package(); // this takes around 10us !!
305
- //computeDshotDMA(); //this is slow too..
306
- //receiveDshotDma(); //holy smokes.. reverse the line and set up dma again
307
- //return;
308
- //}else{
309
- //sendDshotDma();
310
- //return;
311
- //}
312
- //}else{
313
-
314
- //if (dshot == 1){
315
- //computeDshotDMA();
316
- //if(send_telemetry){
317
- //// makeTelemPackage(degrees_celsius,
318
- //// ADC_raw_volts,
319
- //// 1000,
320
- //// 200,
321
- //// k_erpm);
322
- //// send_telem_DMA();
323
- //}
324
- //receiveDshotDma();
325
- //}
326
-
327
-
328
- //if (servoPwm == 1){
329
- //computeServoInput();
330
- //// IC_TIMER_REGISTER->CNT = 0;
331
- //signaltimeout = 0;
332
- //LL_TIM_IC_SetPolarity(IC_TIMER_REGISTER, IC_TIMER_CHANNEL, LL_TIM_IC_POLARITY_RISING); // setup rising pin trigger.
333
- //receiveDshotDma();
334
- //LL_DMA_EnableIT_HT(DMA1, INPUT_DMA_CHANNEL);
335
- //}
336
-
337
- //}
338
- //}
339
- //}
221
+
340
222
341
223
342
224
0 commit comments