/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/testing.cc

  • Committer: Tim Marston
  • Date: 2013-11-28 22:57:17 UTC
  • Revision ID: tim@ed.am-20131128225717-2tvlkiy7ne60flbz
renamed ESCs test directory to motors

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// testing.cc
3
 
//
4
 
 
5
 
 
6
 
#include "testing.h"
7
 
#include "config.h"
8
 
#include <Arduino.h>
9
 
 
10
 
 
11
 
// the width of the display of a single channel (in chars)
12
 
#define GRAPH_SIZE 7
13
 
 
14
 
 
15
 
void Testing::setup()
16
 
{
17
 
        Serial.begin( 9600 );
18
 
}
19
 
 
20
 
 
21
 
void Testing::draw_receiver_channels( unsigned long channel_values[] )
22
 
{
23
 
        // init graph
24
 
        static char graph[ GRAPH_SIZE + 2 ];
25
 
        static char inited_graph = false;
26
 
        if( !inited_graph ) {
27
 
                for( int a = 1; a < GRAPH_SIZE + 1; a++ )
28
 
                        graph[ a ] = '_';
29
 
                graph[ 0 ] = '|';
30
 
                graph[ GRAPH_SIZE + 1 ] = 0;
31
 
                inited_graph = true;
32
 
        }
33
 
 
34
 
        // draw channels
35
 
        for( int a = 0; a < NUM_CHANNELS; a++ ) {
36
 
                unsigned long value = min( channel_values[ a ], MAX_CHANNEL_VALUE );
37
 
                int pos = ( GRAPH_SIZE ) * value / MAX_CHANNEL_VALUE;
38
 
                graph[ pos + 1 ] = '^';
39
 
                Serial.print( graph );
40
 
                graph[ pos + 1 ] = '_';
41
 
        }
42
 
        Serial.println( "|" );
43
 
}