Created
April 30, 2014 19:50
-
-
Save JChristensen/1a2bb3f03626aac92de0 to your computer and use it in GitHub Desktop.
Testing Falcon Four's LiquidTWI library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <LiquidCrystal.h> //http://github.com/adafruit/LiquidCrystal | |
#include <LiquidTWI.h> //http://forums.adafruit.com/viewtopic.php?f=19&t=21586&p=113177 | |
#include <Wire.h> //http://arduino.cc/en/Reference/Wire | |
#include <Streaming.h> //http://arduiniana.org/libraries/streaming/ | |
//Comment one of the following two lines: | |
//LiquidCrystal lcd(0); //i2c address 0 (0x20) | |
LiquidTWI lcd(0); //i2c address 0 (0x20) | |
void setup(void) | |
{ | |
unsigned long t1, t2, lcdLapse, serialLapse; | |
Serial.begin(115200); | |
lcd.begin(16, 2); //16 col x 2 rows | |
TWBR = 12; //400kHz I2C SCL | |
lcd.clear(); | |
delay(1000); | |
t1 = millis(); | |
lcd << "1234567890123456"; | |
lcd.setCursor(0, 1); //col 0, row 1 | |
lcd << "abcdefghijklmnop"; | |
t2 = millis(); | |
lcdLapse = t2 - t1; | |
Serial.println(lcdLapse); | |
t1 = millis(); | |
Serial.println("1234567890123456"); | |
Serial.println("abcdefghijklmnop"); | |
t2 = millis(); | |
serialLapse = t2 - t1; | |
Serial.println(serialLapse); | |
delay(1000); | |
lcd.clear(); | |
lcd.setCursor(0, 1); //col 0, row 1 | |
lcd.print(lcdLapse); | |
lcd.print(" ms "); | |
delay(1000); | |
} | |
void loop(void) | |
{ | |
unsigned long t1, t2; | |
static unsigned long msLast; | |
unsigned long ms = millis(); | |
if (ms - msLast >= 1000) { | |
msLast += 1000; | |
t1 = millis(); | |
lcd.setCursor(0, 0); | |
lcd.print(ms); | |
t2 = millis(); | |
lcd.setCursor(0, 1); | |
lcd.print(t2 - t1); | |
lcd.print(" ms "); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment