Commits

Anonymous committed a5c90a9

Arduino SDK 0023 Compatibility

Comments (0)

Files changed (16)

 #endif
 
 #include <inttypes.h>
-#include "../Wire/Wire.h"
+#if (__IN_ECLIPSE__)
+//TODO: Find a way for eclipse to play along nicer with Wire library
+#include <Wire/Wire.h>
+#else
+#include <Wire.h>
+#endif
 
 #include "I2CIO.h"
 

LiquidCrystal.cpp

 #else
 #include <Arduino.h>
 #endif
-#include <LiquidCrystal.h>
+#include "LiquidCrystal.h"
 
 // CONSTANT  definitions
 // ---------------------------------------------------------------------------

LiquidCrystal_SR_LCD3.cpp

 #else
 #include <Arduino.h>
 #endif
-#include "FastIO.h"
 #include "LiquidCrystal_SR_LCD3.h"
 
 

LiquidCrystal_SR_LCD3.h

 
 #include <inttypes.h>
 #include "LCD.h"
+#include "FastIO.h"
 
 
 class LiquidCrystal_SR_LCD3 : public LCD

examples/HelloWorld_4bit/HelloWorld_4bit.ino

-#include <Wire.h>
-#include <LiquidCrystal.h>
-
-
-LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
-#define   CONTRAST_PIN   9
-#define   BACKLIGHT_PIN  7
-#define   CONTRAST       110
-
-// Creat a set of new characters
-byte smiley[8] = {
-  0b00000,
-  0b00000,
-  0b01010,
-  0b00000,
-  0b00000,
-  0b10001,
-  0b01110,
-  0b00000
-};
-
-byte armsUp[8] = {
-  0b00100,
-  0b01010,
-  0b00100,
-  0b10101,
-  0b01110,
-  0b00100,
-  0b00100,
-  0b01010
-};
-
-byte frownie[8] = {
-  0b00000,
-  0b00000,
-  0b01010,
-  0b00000,
-  0b00000,
-  0b00000,
-  0b01110,
-  0b10001
-};
-
-void setup()
-{
-  Serial.begin ( 57600 );
-
-  // Switch on the backlight and LCD contrast levels
-  pinMode(CONTRAST_PIN, OUTPUT);
-  analogWrite ( CONTRAST_PIN, CONTRAST );
-
-  lcd.setBacklightPin ( BACKLIGHT_PIN );
-  lcd.setBacklight ( HIGH );
-    
-  lcd.begin(16,2);               // initialize the lcd 
-
-  lcd.createChar (0, smiley);    // load character to the LCD
-  lcd.createChar (1, armsUp);    // load character to the LCD
-  lcd.createChar (2, frownie);   // load character to the LCD
-
-  lcd.home ();                   // go home
-  lcd.print("Hello, ARDUINO ");  
-  lcd.setCursor ( 0, 1 );        // go to the next line
-  lcd.print (" FORUM - fm   ");      
-}
-
-void loop()
-{
-  // Do a little animation by writing to the same location
-  lcd.setCursor ( 14, 1 );
-  lcd.print (char(2));
-  delay (200);
-  lcd.setCursor ( 14, 1 );
-  lcd.print ( char(0));
-  delay (200);
-}

examples/HelloWorld_4bit/HelloWorld_4bit.pde

+#include <Wire.h>
+#include <LiquidCrystal.h>
+
+
+LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
+#define   CONTRAST_PIN   9
+#define   BACKLIGHT_PIN  7
+#define   CONTRAST       110
+
+// Creat a set of new characters
+byte smiley[8] = {
+  0b00000,
+  0b00000,
+  0b01010,
+  0b00000,
+  0b00000,
+  0b10001,
+  0b01110,
+  0b00000
+};
+
+byte armsUp[8] = {
+  0b00100,
+  0b01010,
+  0b00100,
+  0b10101,
+  0b01110,
+  0b00100,
+  0b00100,
+  0b01010
+};
+
+byte frownie[8] = {
+  0b00000,
+  0b00000,
+  0b01010,
+  0b00000,
+  0b00000,
+  0b00000,
+  0b01110,
+  0b10001
+};
+
+void setup()
+{
+  Serial.begin ( 57600 );
+
+  // Switch on the backlight and LCD contrast levels
+  pinMode(CONTRAST_PIN, OUTPUT);
+  analogWrite ( CONTRAST_PIN, CONTRAST );
+
+  lcd.setBacklightPin ( BACKLIGHT_PIN );
+  lcd.setBacklight ( HIGH );
+    
+  lcd.begin(16,2);               // initialize the lcd 
+
+  lcd.createChar (0, smiley);    // load character to the LCD
+  lcd.createChar (1, armsUp);    // load character to the LCD
+  lcd.createChar (2, frownie);   // load character to the LCD
+
+  lcd.home ();                   // go home
+  lcd.print("Hello, ARDUINO ");  
+  lcd.setCursor ( 0, 1 );        // go to the next line
+  lcd.print (" FORUM - fm   ");      
+}
+
+void loop()
+{
+  // Do a little animation by writing to the same location
+  lcd.setCursor ( 14, 1 );
+  lcd.print (char(2));
+  delay (200);
+  lcd.setCursor ( 14, 1 );
+  lcd.print ( char(0));
+  delay (200);
+}

examples/HelloWorld_SR/HelloWorld_SR.ino

-#include <LiquidCrystal_SR.h>
-
-LiquidCrystal_SR lcd(8,7,TWO_WIRE);
-//                   | |
-//                   | \-- Clock Pin
-//                   \---- Data/Enable Pin
-
-// Creat a set of new characters
-byte armsUp[8] = {0b00100,0b01010,0b00100,0b10101,0b01110,0b00100,0b00100,0b01010};
-byte armsDown[8] = {0b00100,0b01010,0b00100,0b00100,0b01110,0b10101,0b00100,0b01010};
-
-void setup(){
-
-  lcd.begin(16,2);               // initialize the lcd
-
-  lcd.createChar (0, armsUp);    // load character to the LCD
-  lcd.createChar (1, armsDown);    // load character to the LCD
-
-  lcd.home ();                   // go home
-  lcd.print(F("LiquidCrystal_SR"));
-}
-
-void loop(){
-  // Do a little animation
-  for(int i = 0; i <= 15; i++) showHappyGuy(i);
-  for(int i = 15; i >= 0; i--) showHappyGuy(i);
-}
-
-void showHappyGuy(int pos){
-  lcd.setCursor ( pos, 1 ); // go to position
-  lcd.print(char(random(0,2))); // show one of the two custom characters
-  delay(150); // wait so it can be seen
-  lcd.setCursor ( pos, 1 ); // go to position again
-  lcd.print(F(" ")); // delete character
-}

examples/HelloWorld_SR/HelloWorld_SR.pde

+#include <Wire.h>
+#include <LiquidCrystal_SR.h>
+
+LiquidCrystal_SR lcd(8,7,TWO_WIRE);
+//                   | |
+//                   | \-- Clock Pin
+//                   \---- Data/Enable Pin
+
+// Creat a set of new characters
+byte armsUp[8] = {0b00100,0b01010,0b00100,0b10101,0b01110,0b00100,0b00100,0b01010};
+byte armsDown[8] = {0b00100,0b01010,0b00100,0b00100,0b01110,0b10101,0b00100,0b01010};
+
+void setup(){
+
+  lcd.begin(16,2);               // initialize the lcd
+
+  lcd.createChar (0, armsUp);    // load character to the LCD
+  lcd.createChar (1, armsDown);    // load character to the LCD
+
+  lcd.home ();                   // go home
+  lcd.print("LiquidCrystal_SR");
+}
+
+void loop(){
+  // Do a little animation
+  for(int i = 0; i <= 15; i++) showHappyGuy(i);
+  for(int i = 15; i >= 0; i--) showHappyGuy(i);
+}
+
+void showHappyGuy(int pos){
+  lcd.setCursor ( pos, 1 ); // go to position
+  lcd.print(char(random(0,2))); // show one of the two custom characters
+  delay(150); // wait so it can be seen
+  lcd.setCursor ( pos, 1 ); // go to position again
+  lcd.print(" "); // delete character
+}

examples/HelloWorld_i2c/HelloWorld_i2c.ino

-#include <Wire.h> 
-#include <LiquidCrystal_I2C.h>
-
-LiquidCrystal_I2C lcd(0x38);  // Set the LCD I2C address
-
-#define BACKLIGHT_PIN     13
-
-// Creat a set of new characters
-const uint8_t charBitmap[][8] = {
-   { 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 },
-   { 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 },
-   { 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 },
-   { 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 },
-   { 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 },
-   { 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 },
-   { 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 },
-   { 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 }
-   
-};
-
-void setup()
-{
-   int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));
-
-  // Switch on the backlight
-  pinMode ( BACKLIGHT_PIN, OUTPUT );
-  digitalWrite ( BACKLIGHT_PIN, HIGH );
-  
-  lcd.begin(16,2);               // initialize the lcd 
-
-   for ( int i = 0; i < charBitmapSize; i++ )
-   {
-      lcd.createChar ( i, (uint8_t *)charBitmap[i] );
-   }
-
-  lcd.home ();                   // go home
-  lcd.print("Hello, ARDUINO ");  
-  lcd.setCursor ( 0, 1 );        // go to the next line
-  lcd.print (" FORUM - fm   ");
-  delay ( 1000 );
-}
-
-void loop()
-{
-   lcd.home ();
-   // Do a little animation by writing to the same location
-   for ( int i = 0; i < 2; i++ )
-   {
-      for ( int j = 0; j < 16; j++ )
-      {
-         lcd.print (char(random(7)));
-      }
-      lcd.setCursor ( 0, 1 );
-   }
-   delay (200);
-}

examples/HelloWorld_i2c/HelloWorld_i2c.pde

+#include <Wire.h> 
+#include <LiquidCrystal_I2C.h>
+
+LiquidCrystal_I2C lcd(0x38);  // Set the LCD I2C address
+
+#define BACKLIGHT_PIN     13
+
+// Creat a set of new characters
+const uint8_t charBitmap[][8] = {
+   { 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 },
+   { 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 },
+   { 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 },
+   { 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 },
+   { 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 },
+   { 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 },
+   { 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 },
+   { 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 }
+   
+};
+
+void setup()
+{
+   int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));
+
+  // Switch on the backlight
+  pinMode ( BACKLIGHT_PIN, OUTPUT );
+  digitalWrite ( BACKLIGHT_PIN, HIGH );
+  
+  lcd.begin(16,2);               // initialize the lcd 
+
+   for ( int i = 0; i < charBitmapSize; i++ )
+   {
+      lcd.createChar ( i, (uint8_t *)charBitmap[i] );
+   }
+
+  lcd.home ();                   // go home
+  lcd.print("Hello, ARDUINO ");  
+  lcd.setCursor ( 0, 1 );        // go to the next line
+  lcd.print (" FORUM - fm   ");
+  delay ( 1000 );
+}
+
+void loop()
+{
+   lcd.home ();
+   // Do a little animation by writing to the same location
+   for ( int i = 0; i < 2; i++ )
+   {
+      for ( int j = 0; j < 16; j++ )
+      {
+         lcd.print (char(random(7)));
+      }
+      lcd.setCursor ( 0, 1 );
+   }
+   delay (200);
+}

examples/SerialDisplay/SerialDisplay.ino

-/*
- * Displays text sent over the serial port (e.g. from the Serial Monitor) on
- * an attached LCD.
- */
-#include <Wire.h> 
-#include <LiquidCrystal_I2C.h>
-
-#define BACKLIGHT_PIN     13
-
-LiquidCrystal_I2C lcd(0x38);  // set the LCD address to 0x38
-
-void setup()
-{
-  pinMode ( BACKLIGHT_PIN, OUTPUT );
-  lcd.begin (16,2); 
-  digitalWrite ( BACKLIGHT_PIN, HIGH );
-  
-  Serial.begin(57600);
-}
-
-void loop()
-{
-  // when characters arrive over the serial port...
-  if (Serial.available()) 
-  {
-    // wait a bit for the entire message to arrive
-    delay(100);
-    // clear the screen
-    lcd.clear();
-    // read all the available characters
-    while (Serial.available() > 0) 
-    {
-      // display each character to the LCD
-      lcd.write(Serial.read());
-    }
-  }
-}

examples/SerialDisplay/SerialDisplay.pde

+/*
+ * Displays text sent over the serial port (e.g. from the Serial Monitor) on
+ * an attached LCD.
+ */
+#include <Wire.h> 
+#include <LiquidCrystal_I2C.h>
+
+#define BACKLIGHT_PIN     13
+
+LiquidCrystal_I2C lcd(0x38);  // set the LCD address to 0x38
+
+void setup()
+{
+  pinMode ( BACKLIGHT_PIN, OUTPUT );
+  lcd.begin (16,2); 
+  digitalWrite ( BACKLIGHT_PIN, HIGH );
+  
+  Serial.begin(57600);
+}
+
+void loop()
+{
+  // when characters arrive over the serial port...
+  if (Serial.available()) 
+  {
+    // wait a bit for the entire message to arrive
+    delay(100);
+    // clear the screen
+    lcd.clear();
+    // read all the available characters
+    while (Serial.available() > 0) 
+    {
+      // display each character to the LCD
+      lcd.write(Serial.read());
+    }
+  }
+}

examples/i2cLCDextraIO/i2cLCDextraIO.ino

-// ---------------------------------------------------------------------------
-// Created by Francisco Malpartida on 1/1/12.
-// Copyright 2011 - Under creative commons license:
-//        Attribution-NonCommercial-ShareAlike CC BY-NC-SA
-//
-// This software is furnished "as is", without technical support, and with no 
-// warranty, express or implied, as to its usefulness for any purpose.
-//
-// Thread Safe: No
-// Extendable: Yes
-//
-// @file i2CLCDextraIO.pde
-// Temperature logging to demonstrate the I2CLCDextraIO library.
-// 
-// @brief This application is a demostration file for the I2CLCDextraIO library
-// that reads a temperature from the internal ATMEGA328p temperature sensor
-// and displays it on the LCD. The application also demonstrates some of the
-// methods of the library, such as loading custom characters to the LCD,
-// moving around the LCD, and writing to it.
-//
-// @author F. Malpartida
-// ---------------------------------------------------------------------------
-#include <Arduino.h>
-#include <Wire.h>
-#include <LCD.h>
-
-#define _LCD_I2C_
-
-#ifdef _LCD_I2C_
-#include <LiquidCrystal_I2C.h>
-#endif
-
-#ifdef _LCD_4BIT_
-#include <LiquidCrystal.h>
-#endif
-
-
-/*!
-    @defined    CHAR_WIDTH
-    @abstract   Character witdth of the display, expressed in pixeles per character.
-*/
-#define CHAR_WIDTH  5
-
-/*!
-    @defined    BACKLIGHT_PIN
-    @abstract   LCD backlight pin definition.
-    @discussion AVR pin used for the backlight illumintation of the LCD.
-*/
-#define BACKLIGHT_PIN          12
-
-/*!
-    @defined    TEMP_CAL_OFFSET
-    @abstract   Temperature calibration offset.
-    @discussion This is the offset value that has to be modified to get a
-                correct temperature reading from the internal temperature sensor
-                of your AVR.
-*/
-#define TEMP_CAL_OFFSET 334
-
-/*!
-    @defined    FILTER_ALP
-    @abstract   Low pass filter alpha value
-    @discussion This value defines how much does the current reading, influences
-                the over all value. The smaller, the less influence the current
-                reading has over the overall result.
-*/
-#define FILTER_ALP 0.1
-
-extern unsigned int __bss_end;
-extern unsigned int __heap_start;
-extern void *__brkval;
-
-#ifdef _LCD_I2C_
-LiquidCrystal_I2C lcd(0x38);  // set the LCD address to 0x20 for a 16 chars and 2 line display
-#endif
-
-#ifdef _LCD_4BIT_
-LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
-const int    CONTRAST_PIN  = 9;
-const int    CONTRAST      = 65;
-#endif
-
-
-LCD *myLCD = &lcd;
-
-static double tempFilter;
-
-
-/*!
-    @const      charBitmap 
-    @abstract   Define Character bitmap for the bargraph.
-    @discussion Defines a character bitmap to represent a bargraph on a text
-    display. The bitmap goes from a blank character to full black.
-*/
-const uint8_t charBitmap[][8] = {
-   { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
-   { 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0 },
-   { 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x0 },
-   { 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0 },
-   { 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x0 },
-   { 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0 },
-   { 0xe, 0x11, 0x11, 0x11, 0xe, 0, 0, 0 },
-   { 0x6, 0x9, 0x9, 0x6, 0x0, 0, 0, 0}
-};
-
-/*!
-    @function
-    @abstract   Return available RAM memory
-    @discussion This routine returns the ammount of RAM memory available after
-                initialising the C runtime.
-    @param      
-    @result     Free RAM available.
-*/
-
-static int freeMemory() 
-{
-  int free_memory;
-
-  if((int)__brkval == 0)
-     free_memory = ((int)&free_memory) - ((int)&__bss_end);
-  else
-    free_memory = ((int)&free_memory) - ((int)__brkval);
-
-  return free_memory;
-}
-
-/*!
-    @function
-    @abstract   Returns AVR328p internal temperature
-    @discussion Configures the ADC MUX for the temperature ADC channel and
-                waits for conversion and returns the value of the ADC module
-    @result     The internal temperature reading - in degrees C 
-*/
-
-static int readTemperature()
-{
-   ADMUX = 0xC8;                          // activate interal temperature sensor, 
-                                          // using 1.1V ref. voltage
-   ADCSRA |= _BV(ADSC);                   // start the conversion
-   while (bit_is_set(ADCSRA, ADSC));      // ADSC is cleared when the conversion 
-                                          // finishes
-                                          
-   // combine bytes & correct for temperature offset (approximate)
-   return ( (ADCL | (ADCH << 8)) - TEMP_CAL_OFFSET);  
-}
-
-/*!
-    @function
-    @abstract   Braws a bargraph onto the display representing the value passed.
-    @discussion Draws a bargraph on the specified row using barLength characters. 
-    @param      value[in] Value to represent in the bargraph
-    @param      row[in] Row of the LCD where to display the bargraph. Range (0, 1)
-                for this display.
-    @param      barlength[in] Length of the bar, expressed in display characters.
-    @param      start[in]     Start bar character
-    @param      end [in]      End bar character
-
-    @result     None
-*/
-static void drawBars ( int value, uint8_t row, uint8_t barLength, char start, 
-                       char end )
-{
-   int numBars;
-
-   // Set initial titles on the display
-   myLCD->setCursor (0, row);
-   myLCD->print (start);
-
-   // Calculate the size of the bar
-   value = map ( value, -30, 50, 0, ( barLength ) * CHAR_WIDTH );
-   numBars = value / CHAR_WIDTH;
-   
-   // Limit the size of the bargraph to barLength
-   if ( numBars > barLength )
-   {
-     numBars = barLength;
-   }
-   myLCD->setCursor ( 1, row );
-   
-   // Draw the bars
-   while ( numBars-- )
-   {
-      myLCD->print ( char( 5 ) );
-   }
-   
-   // Draw the fractions
-   numBars = value % CHAR_WIDTH;
-   myLCD->print ( char(numBars) );
-   myLCD->setCursor (barLength + 1, row);
-   myLCD->print (end);
-
-}
-
-void setup ()
-{
-   int i; 
-   int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));
-   
-   Serial.begin ( 57600 );
-   analogReference ( INTERNAL );
-   
-#ifdef _LCD_4BIT_
-  pinMode(CONTRAST_PIN, OUTPUT);
-  pinMode(BACKLIGHT_PIN, OUTPUT);
-#endif
-  digitalWrite(BACKLIGHT_PIN, HIGH);
-  analogWrite (CONTRAST_PIN, CONTRAST);
-
-   myLCD->begin ( 16, 2 );
-  
-   // Load custom character set into CGRAM
-   for ( i = 0; i < charBitmapSize; i++ )
-   {
-      myLCD->createChar ( i, (uint8_t *)charBitmap[i] );
-   }
-   Serial.println ( freeMemory () );
-
-   myLCD->clear ();
-   myLCD->print ("Temp:");
-
-   tempFilter = readTemperature (); // Initialise the temperature Filter
-
-}
-
-
-void loop ()
-{
-  int temp;
-  
-  temp = readTemperature();
-  tempFilter = ( FILTER_ALP * temp) + (( 1.0 - FILTER_ALP ) * tempFilter);
-
-  myLCD->setCursor ( 8, 0 );
-  myLCD->print ("     ");
-  myLCD->setCursor ( 8, 0 );
-  myLCD->print ( tempFilter, 1 );
-  myLCD->setCursor ( 12, 0 );
-  myLCD->print ( "\x07" );
-  myLCD->print ("C");  
-  drawBars ( tempFilter, 1, 14, '-', '+' );
-  
-  delay (200);
-}

examples/i2cLCDextraIO/i2cLCDextraIO.pde

 //
 // @author F. Malpartida
 // ---------------------------------------------------------------------------
-#include <Arduino.h>
 #include <Wire.h>
 #include <LCD.h>
 

examples/performanceLCD/performanceLCD.ino

-// Created by Francisco Malpartida on 20/08/11.
-// Copyright 2011 - Under creative commons license 3.0:
-//        Attribution-ShareAlike CC BY-SA
-//
-// This software is furnished "as is", without technical support, and with no 
-// warranty, express or implied, as to its usefulness for any purpose.
-//
-// Thread Safe: No
-// Extendable: Yes
-//
-// @file performanceLCD.h
-// This sketch implements a simple benchmark for the New LiquidCrystal library.
-// 
-// @brief 
-// This sketch provides a simple benchmark for the New LiquidCrystal library. It
-// enables to test the varios classes provided by the library giving a performance
-// reference.
-//
-// This library is only compatible with Arduino's SDK version 1.0
-//
-// @version API 1.0.0
-//
-// @author F. Malpartida - fmalpartida@gmail.com
-//         Contribution by flo - Florian@Fida.biz - for benchmarking SR 
-// ---------------------------------------------------------------------------
-#include <Arduino.h>
-#include <Wire.h>
-
-#define _LCD_I2C_
-
-#ifdef _LCD_I2C_
-#include <LiquidCrystal_I2C.h>
-#endif
-
-#ifdef _LCD_4BIT_
-#include <LiquidCrystal.h>
-#endif
-
-#ifdef _LCD_SR_
-#include <LiquidCrystal_SR.h>
-#endif
-
-#ifdef _LCD_SRLCD3_
-#include <LiquidCrystal_SR_LCD3.h>
-#endif
-
-// C runtime variables
-// -------------------
-extern unsigned int __bss_end;
-extern unsigned int __heap_start;
-extern void *__brkval;
-
-// Constants and definitions
-// -------------------------
-// Definitions for compatibility with Arduino SDK prior to version 1.0
-#ifndef F
-#define F
-#endif
-
-/*!
- @defined    NUM_BENCHMARKS
- @abstract   Number of benchmarks in the project.
- */
-#define NUM_BENCHMARKS 4
-
-/*!
- @defined    ITERATIONS
- @abstract   Number of benchmarks iterations to perform.
- */
-#define ITERATIONS    10
-
-/*!
- @defined    LCD_ROWS
- @abstract   LCD rows
- @discussion Defines the number of rows that the LCD has, normal LCD ranges are (1, 2, 4).
- */
-#define LCD_ROWS        2
-
-/*!
- @defined    LCD_COLUMNS
- @abstract   LCD available columns
- @discussion Defines the number of colums that the LCD has, normal LCD ranges are (8, 16, 20).
- */
-#define LCD_COLUMNS    16
-
-/*!
- @const      Pin constant definitions
- @abstract   Define several constants required to manage the LCD backlight and contrast
- */
-#ifdef _LCD_I2C_
-const int   BACKLIGHT_PIN  = 12;
-const int   CONTRAST_PIN  = 0; // none
-const int   CONTRAST      = 0; // none
-#endif
-
-#ifdef _LCD_4BIT_
-const int    CONTRAST_PIN  = 9;
-const int    BACKLIGHT_PIN = 7;
-const int    CONTRAST      = 120;
-#endif
-
-#ifdef _LCD_SR_
-const int    CONTRAST_PIN  = 0; // not connected
-const int    BACKLIGHT_PIN = 0; // none
-const int    CONTRAST      = 0;
-#endif
-
-#ifdef _LCD_SRLCD3_
-const int    CONTRAST_PIN  = 0; // none
-const int    BACKLIGHT_PIN = 5;
-const int    CONTRAST      = 0;
-#endif
-
-/*!
- @const      charBitmap 
- @abstract   Define Character bitmap for the bargraph.
- @discussion Defines a character bitmap to represent a bargraph on a text
- display. The bitmap goes from a blank character to full black.
- */
-const uint8_t charBitmap[][8] = {
-   { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
-   { 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0 },
-   { 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x0 },
-   { 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0 },
-   { 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x0 },
-   { 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0 }
-};
-
-/*!
- @typedef    t_benchmarkOp
- @abstract   Function pointer associated to each benchmark.
- */
-typedef long (*t_benchmarkOp)( uint8_t );
-
-/*!
- @typedef    t_timeBenchMarks
- @abstract   Structure to store results of the execution time of the benchmark.
- @field      benchmark: function pointer of the benchmark to be executed.
- */
-typedef struct 
-{
-   t_benchmarkOp   benchmark; /**< Function pointer associated to the benchmark */
-   long            benchTime; /**< execution time for benchmark 1 in useconds */
-   uint8_t         numWrites; /**< Number of write cycles of the benchmark    */
-} t_benchMarks;
-
-
-// Main LCD objects
-// ----------------
-#ifdef _LCD_I2C_
-LiquidCrystal_I2C lcd(0x38);  // set the LCD address to 0x20 for a 16 chars and 2 line display
-#endif
-
-#ifdef _LCD_4BIT_
-LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
-#endif
-
-#ifdef _LCD_SR_
-LiquidCrystal_SR lcd(8,7,TWO_WIRE);
-#endif
-
-#ifdef _LCD_SRLCD3_
-LiquidCrystal_SR_LCD3 lcd(3, 4, 2);
-#endif
-
-// benchMarks definitions
-// ----------------------
-extern long benchmark1 ( uint8_t );
-extern long benchmark2 ( uint8_t );
-extern long benchmark3 ( uint8_t );
-extern long benchmark4 ( uint8_t );
-
-//! @brief benchmark structure that will be initialised and 
-static t_benchMarks myBenchMarks[NUM_BENCHMARKS] =
-{
-   { benchmark1, 0, (LCD_ROWS * LCD_COLUMNS) + 2 },
-   { benchmark2, 0, LCD_ROWS * LCD_COLUMNS * 6 },
-   { benchmark3, 0, 40 + 2 },
-   { benchmark4, 0, 40 + 2 }
-};
-
-// Static methods
-// --------------
-/*!
- @function   freeMemory
- @abstract   Return available RAM memory
- @discussion This routine returns the ammount of RAM memory available after
- initialising the C runtime.
- @param      
- @return     Free RAM available.
- */
-static int freeMemory ( void ) 
-{
-   int free_memory;
-   
-   if((int)__brkval == 0)
-   free_memory = ((int)&free_memory) - ((int)&__bss_end);
-   else
-   free_memory = ((int)&free_memory) - ((int)__brkval);
-   
-   return free_memory;
-}
-
-/*!
- @function   LCDSetup
- @abstract   Initialise LCD associated pins and initialise the LCD object 
- with its geometry.
- @discussion Initialise the LCD object and make it ready for operation by
- setting up the LCD geometry, i.e. LCD character size. Initialise
- and configure all associated control pins such as backlight and
- contras pin if necessary.
- 
- @param[in]  charBitmapSize: contrasts pin associated to the contrast (should be an
- analog pin). 0 if contrast pin is not required.
- @param[in]  backlight: backlight pin associated to the LCD backlight.
- @param[in]  cols: number of LCD columns normal values (1, 2, 4)
- @param[in]  rows: number of LCD rows normal values (8, 16, 20)
- */
-static void LCDSetup ( uint8_t contrasPin, uint8_t backlight, uint8_t cols, uint8_t rows )
-{
-   // If our setup uses a PWM to control the backlight, configure it
-   // --------------------------------------------------------------
-   if ( contrasPin != 0 )
-   {
-      pinMode ( contrasPin, OUTPUT );
-      analogWrite ( contrasPin, CONTRAST );
-   }
-   // Setup backlight pin
-   if ( backlight != 0 ){
-     pinMode(backlight, OUTPUT);
-     digitalWrite(backlight, HIGH);
-   }
-   
-   lcd.begin ( cols, rows );
-   lcd.clear ( );
-}
-
-
-/*!
- @function   LCDLoadCharacters
- @abstract   Loads onto the LCD the character set for the benchmark.
- @discussion Loads onto the LCD the character set that will be used throughout
- the benchmark.
- 
- @param[in]  charBitmapSize: number of characters to load to the LCD.
- */
-static void LCDLoadCharacters ( int numChars )
-{
-   // Load custom character set into CGRAM
-   for ( int i = 0; i < numChars; i++ )
-   {
-      lcd.createChar ( i, (uint8_t *)charBitmap[i] );
-   }
-}
-
-
-// Benchmarks
-// ----------
-/*!
- @function   benchmark1
- @abstract   writes to the LCD a full set of characters loaded on the LCD
-             memory.
- @discussion Writes to all the positions of the LCD a fixed pattern from
-             memory. For every line it writes, it positions the cursor.
-             The number of writen LCD accesses is: LCD_ROW * LCD_COLUMS + 2.
-             It returns the cumulative time used by all the iterations.
- 
- @param[in]  iterations: number of iterations the benchmark is executed before
-             returning the time taken by all iterations.
- @return     The time take to execute iterations number of benchmarks.
- */
-long benchmark1 ( uint8_t iterations )
-{
-   unsigned long time, totalTime = 0;
-   int i, j;
-   
-   while ( iterations > 0 )
-   {
-      // Clear the LCD
-      lcd.clear ( );
-   
-      time = micros ();
-      for ( i = 0; i < LCD_ROWS; i++ )
-      {
-         lcd.setCursor ( 0, i );
-         for ( j = 0; j < LCD_COLUMNS; j++ )
-         {
-            lcd.print (char(5));
-         }
-      }
-      totalTime += ( micros() - time );
-      delay ( 200 ); // it doesn't keep up with the LCD refresh rate.
-      iterations--;
-   }
-   return ( totalTime );
-}
-
-/*!
- @function   benchmark2
- @abstract   writes to the LCD a full set of characters loaded on the LCD
-             memory one line pixel at the time
- @discussion Writes to all the positions of the LCD a fixed pattern from
-             memory each patern take 6 write operations to the LCD. For every  
-             character it writes it sets the cursor possition.
-             The number of writen LCD accesses is: LCD_ROW * LCD_COLUMS * 6.
-             It returns the cumulative time used by all the iterations.
- 
- @param[in]  iterations: number of iterations the benchmark is executed before
-             returning the time taken by all iterations.
- @return     The time take to execute iterations number of benchmarks.
- */
-long benchmark2 ( uint8_t iterations )
-{
-   unsigned long time, totalTime = 0;
-   int i, j, k;
-   
-   while ( iterations > 0 )
-   {
-      // Clear the LCD
-      lcd.clear ( );
-   
-      time = micros ();
-      
-      for ( i = 0; i < LCD_ROWS; i++ )
-      {
-         for ( j = 0; j < LCD_COLUMNS; j++ )
-         {
-            for ( k = 0; k <= 5; k++ )
-            {
-               lcd.setCursor ( j, i );
-               lcd.print (char(k));
-            }
-         }
-      }
-      totalTime += ( micros() - time );
-      iterations--;
-   }
-   return ( totalTime );
-}
-
-/*!
- @function   benchmark3
- @abstract   writes to the LCD a full set of characters from memory.
- @discussion Writes to all the positions of the LCD a fixed pattern from
-             RAM. For every line it writes, it positions the cursor.
-             The number of writen LCD accesses is: LCD_ROW * LCD_COLUMS + 2.
-             It returns the cumulative time used by all the iterations.
- 
- @param[in]  iterations: number of iterations the benchmark is executed before
-             returning the time taken by all iterations.
- @return     The time take to execute iterations number of benchmarks.
- */
-long benchmark3 ( uint8_t iterations )
-{
-   unsigned long time, totalTime = 0;
-   int i, j;
-   
-   while ( iterations > 0 )
-   {
-      // Clear the LCD
-      lcd.clear ( );
-   
-      time = micros ();
-      for ( i = 0; i < LCD_ROWS; i++ )
-      {
-         lcd.setCursor ( 0, i );
-         lcd.print ( "####################" );
-      }
-      totalTime += ( micros() - time );
-      delay ( 200 ); // it doesn't keep up with the LCD refresh rate.
-      iterations--;
-   }
-   return ( totalTime );
-}
-
-/*!
- @function   benchmark4
- @abstract   writes to the LCD a full set of characters from memory.
- @discussion Writes to all the positions of the LCD a fixed pattern from
-             flash. For every line it writes, it positions the cursor.
-             The number of writen LCD accesses is: LCD_ROW * LCD_COLUMS + 2.
-             It returns the cumulative time used by all the iterations.
- 
- @param[in]  iterations: number of iterations the benchmark is executed before
-             returning the time taken by all iterations.
- @return     The time take to execute iterations number of benchmarks.
- */
-long benchmark4 ( uint8_t iterations )
-{
-   unsigned long time, totalTime = 0;
-   int i, j;
-   
-   while ( iterations > 0 )
-   {
-      // Clear the LCD
-      lcd.clear ( );
-   
-      time = micros ();
-      for ( i = 0; i < LCD_ROWS; i++ )
-      {
-         lcd.setCursor ( 0, i );
-         lcd.print ( F("####################") );
-      }
-      totalTime += ( micros() - time );
-      delay ( 200 ); // it doesn't keep up with the LCD refresh rate.
-      iterations--;
-   }
-   return ( totalTime );
-}
-
-// Main system setup
-// -----------------
-void setup ()
-{
-   Serial.begin ( 57600 );
-   Serial.print ("Free mem: ");
-   Serial.println ( freeMemory () );
-   
-   // Initialise the LCD
-   LCDSetup ( CONTRAST_PIN, BACKLIGHT_PIN, LCD_COLUMNS, LCD_ROWS );
-   LCDLoadCharacters ( (sizeof(charBitmap ) / sizeof (charBitmap[0])) );
-}
-
-
-// Main system loop
-// ----------------
-void loop ()
-{
-   int i;
-
-   lcd.setCursor ( 0, 0 );
-   lcd.clear ( );
-   
-   // Run benchmark
-   for ( i = 0; i < NUM_BENCHMARKS; i++ )
-   {
-      myBenchMarks[i].benchTime = 
-         myBenchMarks[i].benchmark (ITERATIONS)/ITERATIONS;
-         Serial.println (i);
-   }
-   
-   for ( i = 0; i < NUM_BENCHMARKS; i++ )
-   {   
-      Serial.print ( F("benchmark") );
-      Serial.print ( i );
-      Serial.print ( ": " );
-      Serial.print ( myBenchMarks[i].benchTime );
-      Serial.print ( F(" us - ") );
-      Serial.print ( F(" write: ") );
-      Serial.print ( myBenchMarks[i].benchTime / myBenchMarks[i].numWrites );
-      Serial.println ( F(" us") ); 
-      
-   }
-}
-

examples/performanceLCD/performanceLCD.pde

+// Created by Francisco Malpartida on 20/08/11.
+// Copyright 2011 - Under creative commons license 3.0:
+//        Attribution-ShareAlike CC BY-SA
+//
+// This software is furnished "as is", without technical support, and with no 
+// warranty, express or implied, as to its usefulness for any purpose.
+//
+// Thread Safe: No
+// Extendable: Yes
+//
+// @file performanceLCD.h
+// This sketch implements a simple benchmark for the New LiquidCrystal library.
+// 
+// @brief 
+// This sketch provides a simple benchmark for the New LiquidCrystal library. It
+// enables to test the varios classes provided by the library giving a performance
+// reference.
+//
+// This library is only compatible with Arduino's SDK version 1.0
+//
+// @version API 1.0.0
+//
+// @author F. Malpartida - fmalpartida@gmail.com
+//         Contribution by flo - Florian@Fida.biz - for benchmarking SR 
+// ---------------------------------------------------------------------------
+#include <Wire.h>
+
+#define _LCD_I2C_
+
+#ifdef _LCD_I2C_
+#include <LiquidCrystal_I2C.h>
+#endif
+
+#ifdef _LCD_4BIT_
+#include <LiquidCrystal.h>
+#endif
+
+#ifdef _LCD_SR_
+#include <LiquidCrystal_SR.h>
+#endif
+
+#ifdef _LCD_SRLCD3_
+#include <LiquidCrystal_SR_LCD3.h>
+#endif
+
+// C runtime variables
+// -------------------
+extern unsigned int __bss_end;
+extern unsigned int __heap_start;
+extern void *__brkval;
+
+// Constants and definitions
+// -------------------------
+// Definitions for compatibility with Arduino SDK prior to version 1.0
+#ifndef F
+#define F
+#endif
+
+/*!
+ @defined    NUM_BENCHMARKS
+ @abstract   Number of benchmarks in the project.
+ */
+#define NUM_BENCHMARKS 4
+
+/*!
+ @defined    ITERATIONS
+ @abstract   Number of benchmarks iterations to perform.
+ */
+#define ITERATIONS    10
+
+/*!
+ @defined    LCD_ROWS
+ @abstract   LCD rows
+ @discussion Defines the number of rows that the LCD has, normal LCD ranges are (1, 2, 4).
+ */
+#define LCD_ROWS        2
+
+/*!
+ @defined    LCD_COLUMNS
+ @abstract   LCD available columns
+ @discussion Defines the number of colums that the LCD has, normal LCD ranges are (8, 16, 20).
+ */
+#define LCD_COLUMNS    16
+
+/*!
+ @const      Pin constant definitions
+ @abstract   Define several constants required to manage the LCD backlight and contrast
+ */
+#ifdef _LCD_I2C_
+const int   BACKLIGHT_PIN  = 12;
+const int   CONTRAST_PIN  = 0; // none
+const int   CONTRAST      = 0; // none
+#endif
+
+#ifdef _LCD_4BIT_
+const int    CONTRAST_PIN  = 9;
+const int    BACKLIGHT_PIN = 7;
+const int    CONTRAST      = 120;
+#endif
+
+#ifdef _LCD_SR_
+const int    CONTRAST_PIN  = 0; // not connected
+const int    BACKLIGHT_PIN = 0; // none
+const int    CONTRAST      = 0;
+#endif
+
+#ifdef _LCD_SRLCD3_
+const int    CONTRAST_PIN  = 0; // none
+const int    BACKLIGHT_PIN = 5;
+const int    CONTRAST      = 0;
+#endif
+
+/*!
+ @const      charBitmap 
+ @abstract   Define Character bitmap for the bargraph.
+ @discussion Defines a character bitmap to represent a bargraph on a text
+ display. The bitmap goes from a blank character to full black.
+ */
+const uint8_t charBitmap[][8] = {
+   { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
+   { 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0 },
+   { 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x0 },
+   { 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0 },
+   { 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x0 },
+   { 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0 }
+};
+
+/*!
+ @typedef    t_benchmarkOp
+ @abstract   Function pointer associated to each benchmark.
+ */
+typedef long (*t_benchmarkOp)( uint8_t );
+
+/*!
+ @typedef    t_timeBenchMarks
+ @abstract   Structure to store results of the execution time of the benchmark.
+ @field      benchmark: function pointer of the benchmark to be executed.
+ */
+typedef struct 
+{
+   t_benchmarkOp   benchmark; /**< Function pointer associated to the benchmark */
+   long            benchTime; /**< execution time for benchmark 1 in useconds */
+   uint8_t         numWrites; /**< Number of write cycles of the benchmark    */
+} t_benchMarks;
+
+
+// Main LCD objects
+// ----------------
+#ifdef _LCD_I2C_
+LiquidCrystal_I2C lcd(0x38);  // set the LCD address to 0x20 for a 16 chars and 2 line display
+#endif
+
+#ifdef _LCD_4BIT_
+LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
+#endif
+
+#ifdef _LCD_SR_
+LiquidCrystal_SR lcd(8,7,TWO_WIRE);
+#endif
+
+#ifdef _LCD_SRLCD3_
+LiquidCrystal_SR_LCD3 lcd(3, 4, 2);
+#endif
+
+// benchMarks definitions
+// ----------------------
+extern long benchmark1 ( uint8_t );
+extern long benchmark2 ( uint8_t );
+extern long benchmark3 ( uint8_t );
+extern long benchmark4 ( uint8_t );
+
+//! @brief benchmark structure that will be initialised and 
+static t_benchMarks myBenchMarks[NUM_BENCHMARKS] =
+{
+   { benchmark1, 0, (LCD_ROWS * LCD_COLUMNS) + 2 },
+   { benchmark2, 0, LCD_ROWS * LCD_COLUMNS * 6 },
+   { benchmark3, 0, 40 + 2 },
+   { benchmark4, 0, 40 + 2 }
+};
+
+// Static methods
+// --------------
+/*!
+ @function   freeMemory
+ @abstract   Return available RAM memory
+ @discussion This routine returns the ammount of RAM memory available after
+ initialising the C runtime.
+ @param      
+ @return     Free RAM available.
+ */
+static int freeMemory ( void ) 
+{
+   int free_memory;
+   
+   if((int)__brkval == 0)
+   free_memory = ((int)&free_memory) - ((int)&__bss_end);
+   else
+   free_memory = ((int)&free_memory) - ((int)__brkval);
+   
+   return free_memory;
+}
+
+/*!
+ @function   LCDSetup
+ @abstract   Initialise LCD associated pins and initialise the LCD object 
+ with its geometry.
+ @discussion Initialise the LCD object and make it ready for operation by
+ setting up the LCD geometry, i.e. LCD character size. Initialise
+ and configure all associated control pins such as backlight and
+ contras pin if necessary.
+ 
+ @param[in]  charBitmapSize: contrasts pin associated to the contrast (should be an
+ analog pin). 0 if contrast pin is not required.
+ @param[in]  backlight: backlight pin associated to the LCD backlight.
+ @param[in]  cols: number of LCD columns normal values (1, 2, 4)
+ @param[in]  rows: number of LCD rows normal values (8, 16, 20)
+ */
+static void LCDSetup ( uint8_t contrasPin, uint8_t backlight, uint8_t cols, uint8_t rows )
+{
+   // If our setup uses a PWM to control the backlight, configure it
+   // --------------------------------------------------------------
+   if ( contrasPin != 0 )
+   {
+      pinMode ( contrasPin, OUTPUT );
+      analogWrite ( contrasPin, CONTRAST );
+   }
+   // Setup backlight pin
+   if ( backlight != 0 ){
+     pinMode(backlight, OUTPUT);
+     digitalWrite(backlight, HIGH);
+   }
+   
+   lcd.begin ( cols, rows );
+   lcd.clear ( );
+}
+
+
+/*!
+ @function   LCDLoadCharacters
+ @abstract   Loads onto the LCD the character set for the benchmark.
+ @discussion Loads onto the LCD the character set that will be used throughout
+ the benchmark.
+ 
+ @param[in]  charBitmapSize: number of characters to load to the LCD.
+ */
+static void LCDLoadCharacters ( int numChars )
+{
+   // Load custom character set into CGRAM
+   for ( int i = 0; i < numChars; i++ )
+   {
+      lcd.createChar ( i, (uint8_t *)charBitmap[i] );
+   }
+}
+
+
+// Benchmarks
+// ----------
+/*!
+ @function   benchmark1
+ @abstract   writes to the LCD a full set of characters loaded on the LCD
+             memory.
+ @discussion Writes to all the positions of the LCD a fixed pattern from
+             memory. For every line it writes, it positions the cursor.
+             The number of writen LCD accesses is: LCD_ROW * LCD_COLUMS + 2.
+             It returns the cumulative time used by all the iterations.
+ 
+ @param[in]  iterations: number of iterations the benchmark is executed before
+             returning the time taken by all iterations.
+ @return     The time take to execute iterations number of benchmarks.
+ */
+long benchmark1 ( uint8_t iterations )
+{
+   unsigned long time, totalTime = 0;
+   int i, j;
+   
+   while ( iterations > 0 )
+   {
+      // Clear the LCD
+      lcd.clear ( );
+   
+      time = micros ();
+      for ( i = 0; i < LCD_ROWS; i++ )
+      {
+         lcd.setCursor ( 0, i );
+         for ( j = 0; j < LCD_COLUMNS; j++ )
+         {
+            lcd.print (char(5));
+         }
+      }
+      totalTime += ( micros() - time );
+      delay ( 200 ); // it doesn't keep up with the LCD refresh rate.
+      iterations--;
+   }
+   return ( totalTime );
+}
+
+/*!
+ @function   benchmark2
+ @abstract   writes to the LCD a full set of characters loaded on the LCD
+             memory one line pixel at the time
+ @discussion Writes to all the positions of the LCD a fixed pattern from
+             memory each patern take 6 write operations to the LCD. For every  
+             character it writes it sets the cursor possition.
+             The number of writen LCD accesses is: LCD_ROW * LCD_COLUMS * 6.
+             It returns the cumulative time used by all the iterations.
+ 
+ @param[in]  iterations: number of iterations the benchmark is executed before
+             returning the time taken by all iterations.
+ @return     The time take to execute iterations number of benchmarks.
+ */
+long benchmark2 ( uint8_t iterations )
+{
+   unsigned long time, totalTime = 0;
+   int i, j, k;
+   
+   while ( iterations > 0 )
+   {
+      // Clear the LCD
+      lcd.clear ( );
+   
+      time = micros ();
+      
+      for ( i = 0; i < LCD_ROWS; i++ )
+      {
+         for ( j = 0; j < LCD_COLUMNS; j++ )
+         {
+            for ( k = 0; k <= 5; k++ )
+            {
+               lcd.setCursor ( j, i );
+               lcd.print (char(k));
+            }
+         }
+      }
+      totalTime += ( micros() - time );
+      iterations--;
+   }
+   return ( totalTime );
+}
+
+/*!
+ @function   benchmark3
+ @abstract   writes to the LCD a full set of characters from memory.
+ @discussion Writes to all the positions of the LCD a fixed pattern from
+             RAM. For every line it writes, it positions the cursor.
+             The number of writen LCD accesses is: LCD_ROW * LCD_COLUMS + 2.
+             It returns the cumulative time used by all the iterations.
+ 
+ @param[in]  iterations: number of iterations the benchmark is executed before
+             returning the time taken by all iterations.
+ @return     The time take to execute iterations number of benchmarks.
+ */
+long benchmark3 ( uint8_t iterations )
+{
+   unsigned long time, totalTime = 0;
+   int i, j;
+   
+   while ( iterations > 0 )
+   {
+      // Clear the LCD
+      lcd.clear ( );
+   
+      time = micros ();
+      for ( i = 0; i < LCD_ROWS; i++ )
+      {
+         lcd.setCursor ( 0, i );
+         lcd.print ( "####################" );
+      }
+      totalTime += ( micros() - time );
+      delay ( 200 ); // it doesn't keep up with the LCD refresh rate.
+      iterations--;
+   }
+   return ( totalTime );
+}
+
+/*!
+ @function   benchmark4
+ @abstract   writes to the LCD a full set of characters from memory.
+ @discussion Writes to all the positions of the LCD a fixed pattern from
+             flash. For every line it writes, it positions the cursor.
+             The number of writen LCD accesses is: LCD_ROW * LCD_COLUMS + 2.
+             It returns the cumulative time used by all the iterations.
+ 
+ @param[in]  iterations: number of iterations the benchmark is executed before
+             returning the time taken by all iterations.
+ @return     The time take to execute iterations number of benchmarks.
+ */
+long benchmark4 ( uint8_t iterations )
+{
+   unsigned long time, totalTime = 0;
+   int i, j;
+   
+   while ( iterations > 0 )
+   {
+      // Clear the LCD
+      lcd.clear ( );
+   
+      time = micros ();
+      for ( i = 0; i < LCD_ROWS; i++ )
+      {
+         lcd.setCursor ( 0, i );
+         lcd.print ( F("####################") );
+      }
+      totalTime += ( micros() - time );
+      delay ( 200 ); // it doesn't keep up with the LCD refresh rate.
+      iterations--;
+   }
+   return ( totalTime );
+}
+
+// Main system setup
+// -----------------
+void setup ()
+{
+   Serial.begin ( 57600 );
+   Serial.print ("Free mem: ");
+   Serial.println ( freeMemory () );
+   
+   // Initialise the LCD
+   LCDSetup ( CONTRAST_PIN, BACKLIGHT_PIN, LCD_COLUMNS, LCD_ROWS );
+   LCDLoadCharacters ( (sizeof(charBitmap ) / sizeof (charBitmap[0])) );
+}
+
+
+// Main system loop
+// ----------------
+void loop ()
+{
+   int i;
+
+   lcd.setCursor ( 0, 0 );
+   lcd.clear ( );
+   
+   // Run benchmark
+   for ( i = 0; i < NUM_BENCHMARKS; i++ )
+   {
+      myBenchMarks[i].benchTime = 
+         myBenchMarks[i].benchmark (ITERATIONS)/ITERATIONS;
+         Serial.println (i);
+   }
+   
+   for ( i = 0; i < NUM_BENCHMARKS; i++ )
+   {   
+      Serial.print ( F("benchmark") );
+      Serial.print ( i );
+      Serial.print ( ": " );
+      Serial.print ( myBenchMarks[i].benchTime );
+      Serial.print ( F(" us - ") );
+      Serial.print ( F(" write: ") );
+      Serial.print ( myBenchMarks[i].benchTime / myBenchMarks[i].numWrites );
+      Serial.println ( F(" us") ); 
+      
+   }
+}
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.