Skip to content

Commit 06ac0e3

Browse files
committed
Added conditional LCD_SCREEN_DEBUG symbol to serial prints in load image function
1 parent c0735d6 commit 06ac0e3

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/LcdScreen.h

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,47 +233,65 @@ PImage PImage::loadImage(const char * fileName) {
233233
uint32_t bmpImageoffset; // Start of image data in file
234234
uint32_t rowSize; // Not always = bmpWidth; may have padding
235235
bool flip = true; // BMP is stored bottom-to-top
236+
uint32_t bmpFilesize;
237+
uint32_t bmpHeadersize;
236238

237239

238240
// Open requested file on SD card
239241
if ((bmpFile = SD.open(fileName)) == false) {
242+
#if defined(LCD_SCREEN_DEBUG)
240243
Serial.print(F("loadImage: file not found: "));
241244
Serial.println(fileName);
245+
#endif
242246
return PImage(); // load error
243247
}
244248

245249

246250

247251
// Parse BMP header
248252
if(read16(bmpFile) != 0x4D42) { // BMP signature
253+
#if defined(LCD_SCREEN_DEBUG)
249254
Serial.println(F("loadImage: file doesn't look like a BMP"));
255+
#endif
250256
return PImage();
251257
}
252258

253-
Serial.print(F("File size: ")); Serial.println(read32(bmpFile));
259+
bmpFilesize = read32(bmpFile);
254260
(void)read32(bmpFile); // Read & ignore creator bytes
255261
bmpImageoffset = read32(bmpFile); // Start of image data
256-
Serial.print(F("Image Offset: ")); Serial.println(bmpImageoffset, DEC);
257262
// Read DIB header
258-
Serial.print(F("Header size: ")); Serial.println(read32(bmpFile));
259-
bmpWidth = read32(bmpFile);
263+
bmpHeadersize = read32(bmpFile);
264+
bmpWidth = read32(bmpFile);
260265
bmpHeight = read32(bmpFile);
266+
#if defined(LCD_SCREEN_DEBUG)
267+
Serial.print(F("File size: ")); Serial.println(bmpFilesize);
268+
Serial.print(F("Image Offset: ")); Serial.println(bmpImageoffset, DEC);
269+
Serial.print(F("Header size: ")); Serial.println(bmpHeadersize);
270+
#endif
261271
if(read16(bmpFile) != 1) { // # planes -- must be '1'
272+
#if defined(LCD_SCREEN_DEBUG)
262273
Serial.println(F("loadImage: invalid n. of planes"));
274+
#endif
263275
return PImage();
264276
}
265277

266278
bmpDepth = read16(bmpFile); // bits per pixel
279+
#if defined(LCD_SCREEN_DEBUG)
267280
Serial.print(F("Bit Depth: ")); Serial.println(bmpDepth);
281+
#endif
268282
if((bmpDepth != 24) || (read32(bmpFile) != 0)) { // 0 = uncompressed {
283+
#if defined(LCD_SCREEN_DEBUG)
269284
Serial.println(F("loadImage: invalid pixel format"));
285+
#endif
270286
return PImage();
271287
}
272288

289+
#if defined(LCD_SCREEN_DEBUG)
273290
Serial.print(F("Image size: "));
274291
Serial.print(bmpWidth);
275292
Serial.print('x');
276293
Serial.println(bmpHeight);
294+
#endif
277295

278296
// BMP rows are padded (if needed) to 4-byte boundary
279297
rowSize = (bmpWidth * 3 + 3) & ~3;

0 commit comments

Comments
 (0)