/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 src/rc-interface/main.ino

  • Committer: dan
  • Date: 2014-02-05 19:30:09 UTC
  • Revision ID: dan-20140205193009-r1fy3n31e4tfilo8
Added Ultra Sonic Prox sensor test prog

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
#include "config.h"
47
47
#include "receiver.h"
48
48
#include "motors.h"
49
 
#include "testing.h"
 
49
#include "comms.h"
50
50
 
51
51
 
52
52
void setup()
53
53
{
54
54
        Receiver::setup();
55
55
        Motors::setup();
56
 
 
57
 
        Testing::setup();
 
56
        Comms::setup();
 
57
 
 
58
        // led
 
59
        pinMode( LED_PIN, OUTPUT );
 
60
        digitalWrite( LED_PIN, LOW );
 
61
}
 
62
 
 
63
 
 
64
void flash_led()
 
65
{
 
66
        static bool on = false;
 
67
        on = !on;
 
68
        digitalWrite( LED_PIN, on? HIGH : LOW );
58
69
}
59
70
 
60
71
 
61
72
void loop()
62
73
{
63
 
        unsigned long channel_values[ NUM_CHANNELS ];
 
74
        int channel_values[ NUM_CHANNELS ];
64
75
 
65
76
        while( true )
66
77
        {
 
78
                // have we read a whole set of channel values?
67
79
                if( Receiver::read_channels( channel_values ) )
68
80
                {
69
 
                        Testing::draw_receiver_channels( channel_values );
 
81
                        // yes, flash led!
 
82
                        flash_led();
 
83
 
 
84
                        // send channel values to main board
 
85
                        Comms::write_channels( channel_values );
 
86
 
 
87
                        // set motor speeds
 
88
                        Motors::set_values( channel_values );
70
89
                }
71
 
//              Motors::update_channels( channel_values );
 
90
 
 
91
                // update motors
 
92
                Motors::update();
72
93
        }
73
94
}