aboutsummaryrefslogtreecommitdiff
path: root/libraries/TFT/examples/Esplora/EsploraTFTBitmapLogo
diff options
context:
space:
mode:
authorCristian Maglie <c.maglie@bug.st>2013-05-29 18:30:36 +0200
committerCristian Maglie <c.maglie@bug.st>2013-05-29 18:30:36 +0200
commitd90fcca5839d13d57ed527d4009b78d22dafbde7 (patch)
tree768b98af21e5075846184dd3de41ae0c22e75e20 /libraries/TFT/examples/Esplora/EsploraTFTBitmapLogo
parent7207108255a772474b322151cb0fd113e8030afe (diff)
parentef4e8c65373f531ce6d37ff226a21fc9b358ff29 (diff)
Merged 1.0.5
Diffstat (limited to 'libraries/TFT/examples/Esplora/EsploraTFTBitmapLogo')
-rw-r--r--libraries/TFT/examples/Esplora/EsploraTFTBitmapLogo/EsploraTFTBitmapLogo.ino101
-rw-r--r--libraries/TFT/examples/Esplora/EsploraTFTBitmapLogo/arduino.bmpbin0 -> 6966 bytes
2 files changed, 101 insertions, 0 deletions
diff --git a/libraries/TFT/examples/Esplora/EsploraTFTBitmapLogo/EsploraTFTBitmapLogo.ino b/libraries/TFT/examples/Esplora/EsploraTFTBitmapLogo/EsploraTFTBitmapLogo.ino
new file mode 100644
index 0000000..3d3f230
--- /dev/null
+++ b/libraries/TFT/examples/Esplora/EsploraTFTBitmapLogo/EsploraTFTBitmapLogo.ino
@@ -0,0 +1,101 @@
+/*
+
+ Esplora TFT Bitmap Logos
+
+ This example for the Arduino TFT screen is for use
+ with an Arduino Esplora.
+
+ This example reads an image file from a micro-SD card
+ and draws it on the screen, at random locations.
+
+ There is a .bmp file included with this sketch.
+ - open the sketch folder (Ctrl-K or Cmd-K)
+ - copy the "arduino.bmp" file to a micro-SD
+ - put the SD into the SD slot of the Arduino LCD module.
+
+ This example code is in the public domain.
+
+ Created 19 April 2013 by Enrico Gueli
+
+ http://arduino.cc/en/Tutorial/EsploraTFTBitmapLogo
+
+ */
+
+// include the necessary libraries
+#include <Esplora.h>
+#include <SPI.h>
+#include <SD.h>
+#include <TFT.h> // Arduino LCD library
+
+// the Esplora pin connected to the chip select line for SD card
+#define SD_CS 8
+
+// this variable represents the image to be drawn on screen
+PImage logo;
+
+void setup() {
+ // initialize the GLCD and show a message
+ // asking the user to open the serial line
+ EsploraTFT.begin();
+ EsploraTFT.background(255, 255, 255);
+
+ EsploraTFT.stroke(0, 0, 255);
+ EsploraTFT.println();
+ EsploraTFT.println("Arduino LCD Bitmap Example");
+ EsploraTFT.stroke(0, 0, 0);
+ EsploraTFT.println("Open serial monitor");
+ EsploraTFT.println("to run the sketch");
+
+ // initialize the serial port: it will be used to
+ // print some diagnostic info
+ Serial.begin(9600);
+ while (!Serial) {
+ // wait for serial monitor to be open
+ }
+
+ // try to access the SD card. If that fails (e.g.
+ // no card present), the Esplora's LED will turn red.
+ Serial.print("Initializing SD card...");
+ if (!SD.begin(SD_CS)) {
+ Serial.println("failed!");
+ Esplora.writeRed(255);
+ return;
+ }
+ Serial.println("OK!");
+
+ // clear the GLCD screen before starting
+ EsploraTFT.background(255, 255, 255);
+
+ // now that the SD card can be access, try to load the
+ // image file. The Esplora LED will turn green or red if
+ // the loading went OK or not.
+ Esplora.writeRGB(0, 0, 0);
+ logo = EsploraTFT.loadImage("arduino.bmp");
+ if (logo.isValid()) {
+ Esplora.writeGreen(255);
+ }
+ else
+ Esplora.writeRed(255);
+
+}
+
+void loop() {
+ // don't do anything if the image wasn't loaded correctly.
+ if (logo.isValid() == false) {
+ return;
+ }
+
+ Serial.println("drawing image");
+
+ // get a random location where to draw the image.
+ // To avoid the image to be draw outside the screen,
+ // take into account the image size.
+ int x = random(EsploraTFT.width() - logo.width());
+ int y = random(EsploraTFT.height() - logo.height());
+
+ // draw the image to the screen
+ EsploraTFT.image(logo, x, y);
+
+ // wait a little bit before drawing again
+ delay(1500);
+}
diff --git a/libraries/TFT/examples/Esplora/EsploraTFTBitmapLogo/arduino.bmp b/libraries/TFT/examples/Esplora/EsploraTFTBitmapLogo/arduino.bmp
new file mode 100644
index 0000000..09c670a
--- /dev/null
+++ b/libraries/TFT/examples/Esplora/EsploraTFTBitmapLogo/arduino.bmp
Binary files differ