     }
   }
 }
-
-#define NUM_STR   "1234567890123456"
-#define ALPHA_STR "ABCDEFGHIJKLMNOP"
 
 void benchmark3(uint16_t nr)
 {


void measure(const char* name, benchmark_t fn, uint16_t nr, uint16_t bytes)
{
  lcd.display_clear();
  lcd.puts_P(name);
  uint32_t start = RTC::micros();
  {
    fn(nr);
  }
  uint32_t us = (RTC::micros() - start) / nr;
  trace << clear << name << endl;
  trace << us << PSTR(" us (") << us / bytes << PSTR(")");
}



#include "Cosa/RTC.hh"
#include "Cosa/Watchdog.hh"
#include "Cosa/IOStream.hh"
#include "Cosa/LCD/Driver/HD44780.hh"

// Select the port for the benchmark
HD44780::Port port;
// HD44780::SR3W port;
// HD44780::SR3WSPI port;
// HD44780::MJKDZ port;
// HD44780::DFRobot port;
HD44780 lcd(&port);
IOStream cout(&lcd);

// Display configuration
const uint16_t WIDTH = 16;
const uint16_t HEIGHT = 2;

// Measurement support
typedef void (*benchmark_t)(uint16_t);
void measure(const char* name, benchmark_t fn, uint16_t nr, uint16_t bytes);
#define MEASURE(fn,bytes) measure(PSTR(#fn),fn,10,bytes)

// The benchmarks
void benchmark1(uint16_t nr);
void benchmark2(uint16_t nr);
void benchmark3(uint16_t nr);
void benchmark4(uint16_t nr);

// Benchmark configuration
#define CHAR_MAX 6
#define NUM_STR   "1234567890123456"
#define ALPHA_STR "ABCDEFGHIJKLMNOP"

void setup()
{
  RTC::begin();
  Watchdog::begin();
  lcd.begin();
  cout << PSTR("CosaLCDbench:");
  SLEEP(2);
}

void loop()
{
  MEASURE(benchmark1, WIDTH * HEIGHT + 2);
  MEASURE(benchmark2, WIDTH * HEIGHT * CHAR_MAX * 2);
  MEASURE(benchmark3, WIDTH * HEIGHT + 2);
  MEASURE(benchmark4, WIDTH * HEIGHT + 2);
}
