3.97 big 240×400 display ST7793

madias
Wed May 30, 2018 8:33 pm
Ok, this is not really a “project”, more a template for projects needing a cheap and large touch display (without super hi-res resolution):
The ST7793 is a big, cheap 8-bit parallel Touchscreen TFT-module with “arduino shield” pinouts. Price is below 6 Euros (without shipping) https://www.aliexpress.com/item/1lot-2- … 19187.html
It is supported nearly out of the box with mcufriend kbv library -> https://github.com/prenticedavid/MCUFRIEND_kbv
Beware if you use another board, because there are some #ifdef exactly for the bluepill and or nucleo, so you need to change the library files or just set a #define in the sketch for bluepill, so check if this matches with your board (maple mini won’t do that!):
#elif defined(ARDUINO_GENERIC_STM32F103C) || defined(ARDUINO_NUCLEO_F103C8) || defined(ARDUINO_BLUEPILL_F103C8)

madias
Wed May 30, 2018 8:34 pm
ok, here is the missing ZIP and the complete wiring:

TFT——-Bluepill
D0———–A0
to
D7———–A7
LCD_RST—-PB9
LCD_CS—–PB8
LCD_RS—–PB7 (=LCD_CD)
LCD_WR—-PB6
LCD_RD—–PB0

Be careful: You need to connect 3.3 and 5V!


madias
Wed May 30, 2018 8:56 pm
One note:
Forget using hardware scrolling with this display.
Reason: The controller is 240×432 and the TFT-display is 240×400 so you’ll get 32 lines of garbage while hardware scrolling. (Ok, HW-scrolling is cool a first time looking and further you’ll never need/miss it again)

david.prentice
Wed May 30, 2018 10:17 pm
I think that I kludge the hardware scrolling for ILI9327.
I probably don’t bother for ST7793 / R61509. I do not own these.

I was not aware that 3.97 was 240×400. 3.95 inch is 320×480.
Similarly 3.6 inch is 240×400. 3.5 inch is 320×480
I am sure that other panels will emerge out of the woodwork one day.

If you want to scroll, sleep, … or anything else, just ask.

David.


madias
Thu May 31, 2018 7:06 am
Dear David!
Thank you for your library! I’ll never will use the HW scrolling function, because it isn’t “partially” for the ST7793
There is another problem: The pin mapping for the bluepill while using a touchscreen:

LCD———————AVR—–Bluepill
LCD WR TOUCH_YP—A0——PB6
LCD RS TOUCH_XM—-A2——PB7

XM and YP must be on an analog input pin, either PB6 and PB7 are digital only pins.
We have 10 Analog Inputs on STM32F103C8 -> PA0 to PA7 and PB0, PB1
So I need to rewrite it and put LCD WR and LCD RS to PB0 and PB1. Drawback: All analog inputs are used only by display. I’ve to thing about a better solution (maybe not using the whole PA (to 07) port for the 8-bit port….)


stevestrong
Thu May 31, 2018 7:29 am
I was using PB0..15 for data for my 8/16 bit displays.
PB2 is on middle BOOT1 jumper pin (bluepill) available.
In addition you have bridge R4 (I think) on the back side to have direct connection between jumper pin and IC pin.

david.prentice
Thu May 31, 2018 9:13 am
I am a little surprised to hear that your TouchScreen uses A0, A2, D7, D6 pins.
Plug the Shield into a Uno and run the Diagnose_TouchPins or Calibration sketch.

Most shields use A1, A2, 7, 6 or sometimes A1, A2, 9, 8.
I do have one 3.3V shield
Diagnosing as:-
XM,XP: (A2, D8) = 25
YP,YM: (A3, D9) = 36
ID = 0x9320


madias
Thu May 31, 2018 12:00 pm
It was my mistake, pinout is standard – UNO testing:
Testing: (A1,D6)=34
Testing: (A2,D7)=36
Strange that both values are quiet similar. On another MCUFRIEND Uno Shield Display the values are more “right” (25,30) – but the touchdisplay works on UNO, have to look for some better STM32 implementation (Currently I have some strange Y values on Nucleo/bluepill).

madias
Thu May 31, 2018 12:01 pm
Overall I would say this display is more interesting for the bigger STM32 like RET or VET for comfortable pin manipulation without afio-remapping or compromises, maybe I’ll use it for my serial TFT – 3D printer project, because the size is fine for touching it with my fingers (better than those 2.4 or 2.8 ones). The low resolution is also fine, because I don’t need fancy hi-res graphics and the lower the resolution the smaller the code and faster the display.

david.prentice
Thu May 31, 2018 1:58 pm
Testing: (A1,D6)=34
Testing: (A2,D7)=36

david.prentice
Thu May 31, 2018 3:48 pm
I ran the Calibration sketch editing for my Touch pins on the BluePill.
#elif defined(ARDUINO_BLUEPILL_F103C8) || defined(ARDUINO_GENERIC_STM32F103C)
int XP = PB6, YP = PA6, XM = PA7, YM = PB7; //most common configuration

madias
Thu May 31, 2018 8:37 pm
I got it working with my nucleo (didn’t tested it on bluepill, but this would be only some pin defs):
The values on UNO didn’t really match on STM32 (maybe caused by 3.3 vs 5V?) so I use the nucleo with the official CORE (thanks for that hind, David!) for calibration:
uint8_t YP = A2; // must be an analog pin, use "An" notation!
uint8_t XM = A1; // must be an analog pin, use "An" notation!
uint8_t YM = 7; // can be a digital pin
uint8_t XP = 6; // can be a digital pin
uint8_t SwapXY = 0;

uint16_t TS_LEFT = 76;
uint16_t TS_RT = 911;
uint16_t TS_TOP = 66;
uint16_t TS_BOT = 944;


david.prentice
Thu May 31, 2018 10:03 pm
I strongly advise you to look at the latest Release v2.9.8

Instead of swapping pins etc, I diagnose the actual X, Y pins in Portrait mode.
This gives you a clear value for LEFT, RT, TOP, BOT.

And means you can map your pixel coordinates appropriately when using a different orientation.

David.


madias
Thu May 31, 2018 10:38 pm
Ok, I’ll give the new version a try! (I have some other MCUfriend tft shields at home).

BTW: Did I say, that this TFT-shield is really a secret tip? ;)


Leave a Reply

Your email address will not be published. Required fields are marked *