#include <TinyTuner.h>
#include <avr/pgmspace.h>
const char Hello[] PROGMEM =
"\r\n\r\n\r\n\r\n"
"--------------------------------------------------------------------------------\r\n"
"Poor Man's Tiny Tuner\r\n"
"Slowly send lowercase 'x' to tune the oscillator...\r\n\r\n";
const char StartingValue1[] PROGMEM =
" // Starting OSCCAL value is 0x";
const char StartingValue2[] PROGMEM =
"\r\n\r\n";
const char Header[] PROGMEM =
"Step OSCCAL\r\n";
const char Bye1[] PROGMEM =
"\r\n"
"Copy-and-paste the following line of code at the top of setup...\r\n\r\n"
" OSCCAL = 0x";
const char Bye2[] PROGMEM =
";\r\n\r\n"
"--------------------------------------------------------------------------------\r\n";
const char Pad5[] PROGMEM = " ";
void setup( void )
{
Serial.begin( 9600 );
Serial_printP( Hello );
Serial_printP( StartingValue1 );
Serial.print( OSCCAL, HEX );
Serial_printP( StartingValue2 );
}
void loop( void )
{
TinyTuner tt;
bool KeepGoing;
unsigned Step;
Serial_printP( Header );
KeepGoing = true;
Step = 0;
while ( KeepGoing )
{
++Step;
Serial.write( ' ' );
if ( Step < 10 )
{
Serial.write( ' ' );
}
Serial.print( Step );
Serial_printP( Pad5 );
KeepGoing = tt.update();
Serial.print( OSCCAL, HEX );
Serial.println();
}
Serial_printP( Bye1 );
Serial.print( OSCCAL, HEX );
Serial_printP( Bye2 );
}
void Serial_printP( const char* p )
{
char ch;
ch = pgm_read_byte( p );
while ( ch != 0 )
{
Serial.write( ch );
++p;
ch = pgm_read_byte( p );
}
}