Skip to content

Commit 9a50f9f

Browse files
committed
TFT library: warning messages in PImage class and strings inside examples now stored in flash to save RAM
1 parent 9b05911 commit 9a50f9f

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

Diff for: build/shared/revisions.txt

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ ARDUINO 1.5.6 BETA
44
[ide]
55
* Improved command-line parsing (Matthijs Kooijman)
66

7+
[libraries]
8+
* TFT: warning messages in PImage class and strings inside examples now stored in flash to save RAM.
9+
710
ARDUINO 1.5.5 BETA 2013.11.28
811

912
NOTICE:

Diff for: libraries/TFT/examples/Arduino/TFTBitmapLogo/TFTBitmapLogo.ino

+8-8
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ void setup() {
5050

5151
TFTscreen.stroke(0, 0, 255);
5252
TFTscreen.println();
53-
TFTscreen.println("Arduino TFT Bitmap Example");
53+
TFTscreen.println(F("Arduino TFT Bitmap Example"));
5454
TFTscreen.stroke(0, 0, 0);
55-
TFTscreen.println("Open serial monitor");
56-
TFTscreen.println("to run the sketch");
55+
TFTscreen.println(F("Open serial monitor"));
56+
TFTscreen.println(F("to run the sketch"));
5757

5858
// initialize the serial port: it will be used to
5959
// print some diagnostic info
@@ -67,12 +67,12 @@ void setup() {
6767

6868
// try to access the SD card. If that fails (e.g.
6969
// no card present), the setup process will stop.
70-
Serial.print("Initializing SD card...");
70+
Serial.print(F("Initializing SD card..."));
7171
if (!SD.begin(sd_cs)) {
72-
Serial.println("failed!");
72+
Serial.println(F("failed!"));
7373
return;
7474
}
75-
Serial.println("OK!");
75+
Serial.println(F("OK!"));
7676

7777
// initialize and clear the GLCD screen
7878
TFTscreen.begin();
@@ -82,7 +82,7 @@ void setup() {
8282
// image file.
8383
logo = TFTscreen.loadImage("arduino.bmp");
8484
if (!logo.isValid()) {
85-
Serial.println("error while loading arduino.bmp");
85+
Serial.println(F("error while loading arduino.bmp"));
8686
}
8787
}
8888

@@ -92,7 +92,7 @@ void loop() {
9292
return;
9393
}
9494

95-
Serial.println("drawing image");
95+
Serial.println(F("drawing image"));
9696

9797
// get a random location where to draw the image.
9898
// To avoid the image to be draw outside the screen,

Diff for: libraries/TFT/examples/Esplora/EsploraTFTBitmapLogo/EsploraTFTBitmapLogo.ino

+6-6
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ void setup() {
4141

4242
EsploraTFT.stroke(0, 0, 255);
4343
EsploraTFT.println();
44-
EsploraTFT.println("Arduino LCD Bitmap Example");
44+
EsploraTFT.println(F("Arduino LCD Bitmap Example"));
4545
EsploraTFT.stroke(0, 0, 0);
46-
EsploraTFT.println("Open serial monitor");
47-
EsploraTFT.println("to run the sketch");
46+
EsploraTFT.println(F("Open serial monitor"));
47+
EsploraTFT.println(F("to run the sketch"));
4848

4949
// initialize the serial port: it will be used to
5050
// print some diagnostic info
@@ -55,9 +55,9 @@ void setup() {
5555

5656
// try to access the SD card. If that fails (e.g.
5757
// no card present), the Esplora's LED will turn red.
58-
Serial.print("Initializing SD card...");
58+
Serial.print(F("Initializing SD card..."));
5959
if (!SD.begin(SD_CS)) {
60-
Serial.println("failed!");
60+
Serial.println(F("failed!"));
6161
Esplora.writeRed(255);
6262
return;
6363
}
@@ -85,7 +85,7 @@ void loop() {
8585
return;
8686
}
8787

88-
Serial.println("drawing image");
88+
Serial.println(F("drawing image"));
8989

9090
// get a random location where to draw the image.
9191
// To avoid the image to be draw outside the screen,

Diff for: libraries/TFT/src/utility/Adafruit_GFX.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ PImage PImage::loadImage(const char * fileName) {
316316

317317
// Open requested file on SD card
318318
if ((bmpFile = SD.open(fileName)) == NULL) {
319-
Serial.print("loadImage: file not found: ");
319+
Serial.print(F("loadImage: file not found: "));
320320
Serial.println(fileName);
321321
return PImage(); // load error
322322
}
@@ -325,31 +325,31 @@ PImage PImage::loadImage(const char * fileName) {
325325

326326
// Parse BMP header
327327
if(read16(bmpFile) != 0x4D42) { // BMP signature
328-
Serial.println("loadImage: file doesn't look like a BMP");
328+
Serial.println(F("loadImage: file doesn't look like a BMP"));
329329
return PImage();
330330
}
331331

332-
Serial.print("File size: "); Serial.println(read32(bmpFile));
332+
Serial.print(F("File size: ")); Serial.println(read32(bmpFile));
333333
(void)read32(bmpFile); // Read & ignore creator bytes
334334
bmpImageoffset = read32(bmpFile); // Start of image data
335-
Serial.print("Image Offset: "); Serial.println(bmpImageoffset, DEC);
335+
Serial.print(F("Image Offset: ")); Serial.println(bmpImageoffset, DEC);
336336
// Read DIB header
337-
Serial.print("Header size: "); Serial.println(read32(bmpFile));
337+
Serial.print(F("Header size: ")); Serial.println(read32(bmpFile));
338338
bmpWidth = read32(bmpFile);
339339
bmpHeight = read32(bmpFile);
340340
if(read16(bmpFile) != 1) { // # planes -- must be '1'
341-
Serial.println("loadImage: invalid n. of planes");
341+
Serial.println(F("loadImage: invalid n. of planes"));
342342
return PImage();
343343
}
344344

345345
bmpDepth = read16(bmpFile); // bits per pixel
346-
Serial.print("Bit Depth: "); Serial.println(bmpDepth);
346+
Serial.print(F("Bit Depth: ")); Serial.println(bmpDepth);
347347
if((bmpDepth != 24) || (read32(bmpFile) != 0)) { // 0 = uncompressed {
348-
Serial.println("loadImage: invalid pixel format");
348+
Serial.println(F("loadImage: invalid pixel format"));
349349
return PImage();
350350
}
351351

352-
Serial.print("Image size: ");
352+
Serial.print(F("Image size: "));
353353
Serial.print(bmpWidth);
354354
Serial.print('x');
355355
Serial.println(bmpHeight);

0 commit comments

Comments
 (0)