1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-16 11:21:18 +03:00

TFT library: warning messages in PImage class and strings inside examples now stored in flash to save RAM

This commit is contained in:
Fede85
2013-12-06 11:17:17 +01:00
parent 9b05911525
commit 9a50f9f1fa
4 changed files with 26 additions and 23 deletions

View File

@ -4,6 +4,9 @@ ARDUINO 1.5.6 BETA
[ide] [ide]
* Improved command-line parsing (Matthijs Kooijman) * Improved command-line parsing (Matthijs Kooijman)
[libraries]
* TFT: warning messages in PImage class and strings inside examples now stored in flash to save RAM.
ARDUINO 1.5.5 BETA 2013.11.28 ARDUINO 1.5.5 BETA 2013.11.28
NOTICE: NOTICE:

View File

@ -50,10 +50,10 @@ void setup() {
TFTscreen.stroke(0, 0, 255); TFTscreen.stroke(0, 0, 255);
TFTscreen.println(); TFTscreen.println();
TFTscreen.println("Arduino TFT Bitmap Example"); TFTscreen.println(F("Arduino TFT Bitmap Example"));
TFTscreen.stroke(0, 0, 0); TFTscreen.stroke(0, 0, 0);
TFTscreen.println("Open serial monitor"); TFTscreen.println(F("Open serial monitor"));
TFTscreen.println("to run the sketch"); TFTscreen.println(F("to run the sketch"));
// initialize the serial port: it will be used to // initialize the serial port: it will be used to
// print some diagnostic info // print some diagnostic info
@ -67,12 +67,12 @@ void setup() {
// try to access the SD card. If that fails (e.g. // try to access the SD card. If that fails (e.g.
// no card present), the setup process will stop. // no card present), the setup process will stop.
Serial.print("Initializing SD card..."); Serial.print(F("Initializing SD card..."));
if (!SD.begin(sd_cs)) { if (!SD.begin(sd_cs)) {
Serial.println("failed!"); Serial.println(F("failed!"));
return; return;
} }
Serial.println("OK!"); Serial.println(F("OK!"));
// initialize and clear the GLCD screen // initialize and clear the GLCD screen
TFTscreen.begin(); TFTscreen.begin();
@ -82,7 +82,7 @@ void setup() {
// image file. // image file.
logo = TFTscreen.loadImage("arduino.bmp"); logo = TFTscreen.loadImage("arduino.bmp");
if (!logo.isValid()) { if (!logo.isValid()) {
Serial.println("error while loading arduino.bmp"); Serial.println(F("error while loading arduino.bmp"));
} }
} }
@ -92,7 +92,7 @@ void loop() {
return; return;
} }
Serial.println("drawing image"); Serial.println(F("drawing image"));
// get a random location where to draw the image. // get a random location where to draw the image.
// To avoid the image to be draw outside the screen, // To avoid the image to be draw outside the screen,

View File

@ -41,10 +41,10 @@ void setup() {
EsploraTFT.stroke(0, 0, 255); EsploraTFT.stroke(0, 0, 255);
EsploraTFT.println(); EsploraTFT.println();
EsploraTFT.println("Arduino LCD Bitmap Example"); EsploraTFT.println(F("Arduino LCD Bitmap Example"));
EsploraTFT.stroke(0, 0, 0); EsploraTFT.stroke(0, 0, 0);
EsploraTFT.println("Open serial monitor"); EsploraTFT.println(F("Open serial monitor"));
EsploraTFT.println("to run the sketch"); EsploraTFT.println(F("to run the sketch"));
// initialize the serial port: it will be used to // initialize the serial port: it will be used to
// print some diagnostic info // print some diagnostic info
@ -55,9 +55,9 @@ void setup() {
// try to access the SD card. If that fails (e.g. // try to access the SD card. If that fails (e.g.
// no card present), the Esplora's LED will turn red. // no card present), the Esplora's LED will turn red.
Serial.print("Initializing SD card..."); Serial.print(F("Initializing SD card..."));
if (!SD.begin(SD_CS)) { if (!SD.begin(SD_CS)) {
Serial.println("failed!"); Serial.println(F("failed!"));
Esplora.writeRed(255); Esplora.writeRed(255);
return; return;
} }
@ -85,7 +85,7 @@ void loop() {
return; return;
} }
Serial.println("drawing image"); Serial.println(F("drawing image"));
// get a random location where to draw the image. // get a random location where to draw the image.
// To avoid the image to be draw outside the screen, // To avoid the image to be draw outside the screen,

View File

@ -316,7 +316,7 @@ PImage PImage::loadImage(const char * fileName) {
// Open requested file on SD card // Open requested file on SD card
if ((bmpFile = SD.open(fileName)) == NULL) { if ((bmpFile = SD.open(fileName)) == NULL) {
Serial.print("loadImage: file not found: "); Serial.print(F("loadImage: file not found: "));
Serial.println(fileName); Serial.println(fileName);
return PImage(); // load error return PImage(); // load error
} }
@ -325,31 +325,31 @@ PImage PImage::loadImage(const char * fileName) {
// Parse BMP header // Parse BMP header
if(read16(bmpFile) != 0x4D42) { // BMP signature if(read16(bmpFile) != 0x4D42) { // BMP signature
Serial.println("loadImage: file doesn't look like a BMP"); Serial.println(F("loadImage: file doesn't look like a BMP"));
return PImage(); return PImage();
} }
Serial.print("File size: "); Serial.println(read32(bmpFile)); Serial.print(F("File size: ")); Serial.println(read32(bmpFile));
(void)read32(bmpFile); // Read & ignore creator bytes (void)read32(bmpFile); // Read & ignore creator bytes
bmpImageoffset = read32(bmpFile); // Start of image data bmpImageoffset = read32(bmpFile); // Start of image data
Serial.print("Image Offset: "); Serial.println(bmpImageoffset, DEC); Serial.print(F("Image Offset: ")); Serial.println(bmpImageoffset, DEC);
// Read DIB header // Read DIB header
Serial.print("Header size: "); Serial.println(read32(bmpFile)); Serial.print(F("Header size: ")); Serial.println(read32(bmpFile));
bmpWidth = read32(bmpFile); bmpWidth = read32(bmpFile);
bmpHeight = read32(bmpFile); bmpHeight = read32(bmpFile);
if(read16(bmpFile) != 1) { // # planes -- must be '1' if(read16(bmpFile) != 1) { // # planes -- must be '1'
Serial.println("loadImage: invalid n. of planes"); Serial.println(F("loadImage: invalid n. of planes"));
return PImage(); return PImage();
} }
bmpDepth = read16(bmpFile); // bits per pixel bmpDepth = read16(bmpFile); // bits per pixel
Serial.print("Bit Depth: "); Serial.println(bmpDepth); Serial.print(F("Bit Depth: ")); Serial.println(bmpDepth);
if((bmpDepth != 24) || (read32(bmpFile) != 0)) { // 0 = uncompressed { if((bmpDepth != 24) || (read32(bmpFile) != 0)) { // 0 = uncompressed {
Serial.println("loadImage: invalid pixel format"); Serial.println(F("loadImage: invalid pixel format"));
return PImage(); return PImage();
} }
Serial.print("Image size: "); Serial.print(F("Image size: "));
Serial.print(bmpWidth); Serial.print(bmpWidth);
Serial.print('x'); Serial.print('x');
Serial.println(bmpHeight); Serial.println(bmpHeight);