Hi all,
I have the Adafruit 3.5" 320x480 Color TFT Touchscreen Breakout.
With the supplied Adafruit_HX8357 library, it wotks well connected on a Mega board (displaying bitmap picture with the spitfbitmap example)
I would like to dispay jpeg picture. Fot that, I try to use the JPEGdecoder library where I chose the TFT_Jpeg example. It works, but the picture is very small as this library was created for the ST7735 Adafruit dispay which is 1.8" - 128x160.
In the code, there is commented lines for using a HX8357 based display (as the Adafruit TFT does) : using TFT_HX8357 library. But it doesnt work with Adafruit TFT, I think due to pinout. I replace the call to library by using Adafruit_HX8357. I also change in the renderJPEG routine the call to setWindow by a call to setAddrWindow as suggested. (setWindows do not exist in Adafruit library)
Finally, the code is well compiled, loaded to the board and it runs (information in the serial monitor) but ... no picture !
Hereunder, the code for including the library and creating the class TFTscreen:
// include the necessary libraries
#include <SPI.h>
#include <SD.h>
//#include <TFT.h> // Arduino LCD library
#include <JPEGDecoder.h> // JPEG decoder library
// pin definition for the Mega
#define sd_cs 4
#define lcd_cs 10
#define dc 9
#define rst 11
#include <Adafruit_HX8357.h> // Hardware-specific library
Adafruit_HX8357 TFTscreen = Adafruit_HX8357(lcd_cs, dc); // Invoke custom library
#define TFT_WHITE 0xFFFF
#define TFT_BLACK 0x0000
#define TFT_RED 0xF800
// TFT driver and graphics library
//TFT TFTscreen = TFT(lcd_cs, dc, rst);
And the changed code in the renderJPRG routine:
// draw image block if it will fit on the screen
if ( ( mcu_x + win_w) <= TFTscreen.width() && ( mcu_y + win_h) <= TFTscreen.height()) {
// open a window onto the screen to paint the pixels into
TFTscreen.setAddrWindow(mcu_x, mcu_y, mcu_x + win_w - 1, mcu_y + win_h - 1);
//TFTscreen.setWindow(mcu_x, mcu_y, mcu_x + win_w - 1, mcu_y + win_h - 1);
// push all the image block pixels to the screen
while (mcu_pixels--) TFTscreen.pushColor(*pImg++); // Send to TFT 16 bits at a time
Can somebody help?
Thanks by advance