aboutsummaryrefslogtreecommitdiff
path: root/libraries/TFT/examples/Esplora/EsploraTFTTemp
diff options
context:
space:
mode:
authorCristian Maglie <c.maglie@bug.st>2013-06-01 23:16:02 +0200
committerCristian Maglie <c.maglie@bug.st>2013-06-01 23:16:02 +0200
commit177ad96f866714a4962be57f69cd3d5a6334cde1 (patch)
tree1072239986340d6a239adac924eddf2e1d1ca566 /libraries/TFT/examples/Esplora/EsploraTFTTemp
parent6cff36ac5e85c74bcb45cc53491ad69d64520b36 (diff)
parentd90fcca5839d13d57ed527d4009b78d22dafbde7 (diff)
Merge branch 'merge-1.0.5' into ide-1.5.x-discovery
Diffstat (limited to 'libraries/TFT/examples/Esplora/EsploraTFTTemp')
-rw-r--r--libraries/TFT/examples/Esplora/EsploraTFTTemp/EsploraTFTTemp.ino64
1 files changed, 64 insertions, 0 deletions
diff --git a/libraries/TFT/examples/Esplora/EsploraTFTTemp/EsploraTFTTemp.ino b/libraries/TFT/examples/Esplora/EsploraTFTTemp/EsploraTFTTemp.ino
new file mode 100644
index 0000000..b475d2d
--- /dev/null
+++ b/libraries/TFT/examples/Esplora/EsploraTFTTemp/EsploraTFTTemp.ino
@@ -0,0 +1,64 @@
+/*
+
+ Esplora TFT Temperature Display
+
+ This example for the Arduino TFT screen is for use
+ with an Arduino Esplora.
+
+ This example reads the temperature of the Esplora's
+ on board thermisistor and displays it on an attached
+ LCD screen, updating every second.
+
+ This example code is in the public domain.
+
+ Created 15 April 2013 by Scott Fitzgerald
+
+ http://arduino.cc/en/Tutorial/EsploraTFTTemp
+
+ */
+
+// include the necessary libraries
+#include <Esplora.h>
+#include <TFT.h> // Arduino LCD library
+#include <SPI.h>
+
+char tempPrintout[3]; // array to hold the temperature data
+
+void setup() {
+
+ // Put this line at the beginning of every sketch that uses the GLCD
+ EsploraTFT.begin();
+
+ // clear the screen with a black background
+ EsploraTFT.background(0,0,0);
+
+ // set the text color to magenta
+ EsploraTFT.stroke(200,20,180);
+ // set the text to size 2
+ EsploraTFT.setTextSize(2);
+ // start the text at the top left of the screen
+ // this text is going to remain static
+ EsploraTFT.text("Degrees in C :\n ",0,0);
+
+ // set the text in the loop to size 5
+ EsploraTFT.setTextSize(5);
+}
+
+void loop() {
+
+ // read the temperature in Celcius and store it in a String
+ String temperature = String(Esplora.readTemperature(DEGREES_C));
+
+ // convert the string to a char array
+ temperature.toCharArray(tempPrintout, 3);
+
+ // set the text color to white
+ EsploraTFT.stroke(255,255,255);
+ // print the temperature one line below the static text
+ EsploraTFT.text(tempPrintout, 0, 30);
+
+ delay(1000);
+ // erase the text for the next loop
+ EsploraTFT.stroke(0,0,0);
+ EsploraTFT.text(tempPrintout, 0, 30);
+}