//
// 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( "|" );
}
