Library for interfacing to Nokia 5110 LCD display (as found on the SparkFun website).
Fork of N5110 by
Diff: N5110.h
- Revision:
- 10:6f3abb40202b
- Parent:
- 8:40abe5736eca
- Child:
- 11:fc7d89b33e4c
diff -r 7701f0126ba7 -r 6f3abb40202b N5110.h --- a/N5110.h Tue May 20 19:43:52 2014 +0000 +++ b/N5110.h Wed Jul 16 08:42:27 2014 +0000 @@ -66,7 +66,27 @@ lcd.setXYAddress(0,3); // print character lcd.printChar('X'); - + + // data to be printed on display + int temperature = 27; + // print formatted data to buffer + char buffer[14]; // each character is 6 pixels, screen is 84 pixels (84/6 = 14) + int length = sprintf(buffer,"Temperatu = %2d",temperature); + // it is important the format specifier ensures the string will fit in the buffer + // if string will fit on display + if (length <= 14) + lcd.printString(buffer,0,4); // display on screen + else + lcd.printString("Too long",0,4); // else print error message + + // same idea with floats + float humidity = 9.45; + length = sprintf(buffer,"Humidit = %4.2f",humidity); + if (length <= 14) + lcd.printString(buffer,0,2); + else + lcd.printString("Too long",0,2); + while(1); }