Using ILI9341_t3 for 2 different size displays.

Status
Not open for further replies.

KrisKasprzak

Well-known member
All,

I have 2 different sketches each drive a different LCD's of different sizes, one sketch drives an ILI9341 240 x 320 and the other sketch drives an HX8357 (320x480). I realize it's odd driving an 8357 with the ILI9341, but it works great. One program is a transmitter the other is a receiver for a wireless data logger


The problem i have is that every time i compile one sketch or the other I need to edit the #defines in the ILI9341_t3.h file, see how i just comment out the others size. I'm always editing one, then editing the other--it's a pain to have to change the #defines

Code:
#define ILI9341_TFTWIDTH  240
#define ILI9341_TFTHEIGHT 320

//#define ILI9341_TFTWIDTH  320
//#define ILI9341_TFTHEIGHT 480


Iv'e tried moving the #defines to the sketches but the defines are also used in the .CPP file. Is there any way to do this? My only other idea is the pass the sizes to the class initializer statement (and modifying the library functions).

Thought I'd ask before I start hacking...


Code:
#define ILI9341_TFTWIDTH  240
#define ILI9341_TFTHEIGHT 320

#include "ILI9341_t3.h"

ILI9341_t3 Display = ILI9341_t3(10, 9);

void setup() {

  Display.begin();

}

void loop() {

  Display.setTextSize(2);
  Display.setCursor(10, 10);
  Display.print(F("The Cat in th hat")) ;

}
 
My only other idea is the pass the sizes to the class initializer statement (and modifying the library functions).

This sounds like the most reasonable approach.

You could also make 2 completely different copies of the library, with all global namespace stuff changed so they don't conflict.
 
Status
Not open for further replies.
Back
Top