/elec/quadcopter

To get this branch, use:
bzr branch http://bzr.ed.am/elec/quadcopter

« back to all changes in this revision

Viewing changes to test/receiver/pulse-width/main.ino

  • Committer: Tim Marston
  • Date: 2014-01-29 22:34:56 UTC
  • Revision ID: tim@ed.am-20140129223456-aees83f0x1ndvdg9
fixed some bugs in rc-interface introduced in the conversion from the motors
test program

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
#define AVERAGE_DAMP 1
17
17
 
18
18
// graphic display
19
 
#define GRAPH 1
 
19
#define GRAPH 0
20
20
#define GRAPH_MIN 1000
21
21
#define GRAPH_MAX 2000
22
22
#define GRAPH_SIZE 30
58
58
        for( int a = 0; a < AVERAGE_SAMPLES; a++ )
59
59
                intervals[ a ] = 0;
60
60
 
61
 
#ifdef GRAPH
 
61
#if GRAPH
62
62
        // init graph
63
63
        char graph[ GRAPH_SIZE + 3 ];
64
64
        for( int a = 1; a < GRAPH_SIZE + 1; a++ )
71
71
        while( true )
72
72
        {
73
73
                // detect pulse falling-edge
 
74
                noInterrupts();
74
75
                unsigned long pulse_on = _new_pulse_on;
75
76
                unsigned long pulse_off = _new_pulse_off;
 
77
                interrupts();
 
78
                
76
79
                bool got_pulse = false;
77
 
                if( pulse_off > last_pulse_off )
 
80
                if( pulse_off != last_pulse_off )
78
81
                {
79
82
                        // sanity check
80
83
                        unsigned long interval = pulse_off - pulse_on;
81
 
                        if( interval > 800 && interval < 3000 )
 
84
//                      if( interval > 800 && interval < 3000 )
82
85
                        {
83
86
                                // update interval buffer
84
87
                                intervals[ interval_idx ] = pulse_off - pulse_on;
101
104
                                ave += intervals[ a ];
102
105
                        ave /= AVERAGE_SAMPLES;
103
106
 
104
 
#ifdef GRAPH
 
107
#if GRAPH
105
108
 
106
109
                        // draw graph
107
110
                        int pos = ( GRAPH_SIZE ) *