/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: 2013-11-13 22:39:08 UTC
  • Revision ID: tim@ed.am-20131113223908-0ohj8mmvdmqhzdku
updated comments in receiver tests

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 0
 
19
#define GRAPH 1
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
 
#if GRAPH
 
61
#ifdef 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();
75
74
                unsigned long pulse_on = _new_pulse_on;
76
75
                unsigned long pulse_off = _new_pulse_off;
77
 
                interrupts();
78
 
                
79
76
                bool got_pulse = false;
80
 
                if( pulse_off != last_pulse_off )
 
77
                if( pulse_off > last_pulse_off )
81
78
                {
82
79
                        // sanity check
83
80
                        unsigned long interval = pulse_off - pulse_on;
84
 
//                      if( interval > 800 && interval < 3000 )
 
81
                        if( interval > 800 && interval < 3000 )
85
82
                        {
86
83
                                // update interval buffer
87
84
                                intervals[ interval_idx ] = pulse_off - pulse_on;
104
101
                                ave += intervals[ a ];
105
102
                        ave /= AVERAGE_SAMPLES;
106
103
 
107
 
#if GRAPH
 
104
#ifdef GRAPH
108
105
 
109
106
                        // draw graph
110
107
                        int pos = ( GRAPH_SIZE ) *