/elec/quadcopter

To get this branch, use:
bzr branch http://bzr.ed.am/elec/quadcopter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
// testing.cc
//


#include "testing.h"
#include "config.h"
#include <Arduino.h>


// the width of the display of a single channel (in chars)
#define GRAPH_SIZE 7


void Testing::setup()
{
	Serial.begin( 9600 );
}


void Testing::draw_receiver_channels( unsigned long channel_values[] )
{
	// init graph
	static char graph[ GRAPH_SIZE + 2 ];
	static char inited_graph = false;
	if( !inited_graph ) {
		for( int a = 1; a < GRAPH_SIZE + 1; a++ )
			graph[ a ] = '_';
		graph[ 0 ] = '|';
		graph[ GRAPH_SIZE + 1 ] = 0;
		inited_graph = true;
	}

	// draw channels
	for( int a = 0; a < NUM_CHANNELS; a++ ) {
		unsigned long value = min( channel_values[ a ], MAX_CHANNEL_VALUE );
		int pos = ( GRAPH_SIZE ) * value / MAX_CHANNEL_VALUE;
		graph[ pos + 1 ] = '^';
		Serial.print( graph );
		graph[ pos + 1 ] = '_';
	}
	Serial.println( "|" );
}