-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for TTGO T-Display #8
Conversation
The height and width are height=280, width=240 but not as expected height=240, width=135. There is an invisible area outside the screen. |
It's hard for me to support hardware I don't possess. From the URL's you posted it should be capable of working, and your code shows you are setting about investigating this in the same way that I would. Further, given your progress so far I'm confident we can fix this. It seems that the principal problem is an offset such that Determining these values is likely to be an iterative process unless you have someone else's code or docs to study. My simple test script helps with getting pixel-perfect values. I have had to do this with other displays. To add a few general comments. Firstly, thank you for your excellent initial post which provided everything needed to offer support (see below). Secondly it's a great product to support and I'm keen to progress this and offer any help I can. Please keep me posted on progress. Cheers, Pete Beats "I installed this on a Chinese clone of the Scam Products Inc TotallyNackered V0.01 alpha and it doesn't work. Can u help?". I exaggerate only slightly... |
Please see above edit. |
Hello, Peter.
I can't find it. Could you please give a link or datasheet.pdf Thanks for your work. |
I'm damned if I can find where I got it. I'm pretty sure it was from the Adafruit site but I can't find it there. I've posted it here. |
Thanks for the pdf.
|
The ST7789 driver can support displays up to 320x240. The driver was designed around the Adafruit 240x240 display. With RGB565 the buffer size would be 240x240x2 = 115200 bytes. This would be unusable on most platforms. By using a 4-bit greyscale buffer this reduces to 240x240/2 = 28800 bytes which is big but usable on Pyboards, Pico and ESP32 without SPIRAM. The driver uses a lookup table (LUT) to map the 4-bit value onto a 12-bit color which is a mode that the hardware supports. The LUT is user configurable so the GUI can use a wide range of colors, but only from a palette of 16 user selectable colors. I chose 12-bit mode to minimise transfer time between the framebuf and the hardware. This is a compromise: transfer time and color selection are offset against a big reduction in RAM usage (transfer time because of the real time mapping from the LUT), When you use the offset values, what is the outcome? Does the image alter its position on screen? I'm trying to figure out if I made a mistake implementing it or whether the problem is something more subtle. [EDIT] Answered my own question here. I looked at the header file you posted. I suggest for a trial we set the window as the manufacturers do. This means commenting out lines 164 and 168 and entering self._wcd(b'\x2a', b'\x00\x00\x00\xe5') # h says 239 (\xef) but it's actually 229
self._wcd(b'\x2b', b'\x00\x00\x01\x3f') # 319 [EDIT] This is a hack but it may point to where we're going wrong. If this doesn't work, try changing the I'm puzzled, though. These values in the header seem to imply a zero offset which is where we started. Tomorrow I'll study the header file in more detail to see if I can find any relevant issues. |
I have now studied the TTGO header files in detail. In general they make sense. Many of the settings replicate the software reset defaults - I'm not sure why they explicitly set them to default values. They send one 0xb6 command which is not in the datasheet so I have no idea what that does. There are a couple of cases where their commands slightly alter voltages applied to the display. I've seen this kind of thing in other code - I'm not sure of the consequences but it is not going to cause your specific problem. They do gamma setting. Adafruit don't, and nor do I. This is not necessary unless you are going to display images - which you're not with a 4-bit driver. Your colors look fine. What continues to baffle me is their setting of the display window which assumes a 240x320 display. It seems inevitable that, with these settings, some content will be off-screen, which is what you're experiencing. Their Arduino code is complex and I really can't follow it. However I suspect that they later override the default window settings to match the physical display size. I still therefore think that the problem should be fixable with the right display window settings. If the physical display is smaller than the chip's onboard RAM it must be mapped onto a subset of the RAM. The display window enables the driver to write just to that subset. Getting these settings right is tricky but should fix the problem. I've ordered one of these from a local supplier so I will experiment. Until it arrives and I spend time with it I'm afraid I've run out of ideas. |
as described at |
I'm sorry, I was thinking of another driver. It is 16-bit. I received my board this morning and have produced color_setup_ttgo.py which is in the directory with the driver. This appears to be pixel-perfect and runs demos such as aclock and color15. It produces a landscape mode display. You'll need to update the driver as my handling of offset was wrong. Hopefully you want a landscape mode display. Currently only PORTRAIT mode works and produces a landscape display. I'll have to think that one through so there may be some changes. |
Thank you, Also, I found TTGO, which has offsets modes |
It is now. I don't know what happened to that That link will be very helpful. First thing I noticed is that in their "inverted landscape" mode they use the same offsets as me. I'll look at this further over the next day or two and hopefully produce an update that supports all possible rotations. The next release of the docs will include a credit to you for your help with supporting this device - it is much appreciated! |
I have pushed a new release which now supports all display modes. There was a nasty bug in the driver which prevented portrait mode from working. I had not catered for the case where the physical width of a display was not divisible by 2. I have tested all modes on TTGO and Adafruit. Hopefully this has fixed all outstanding problems. The setup file has commented out code showing how to invoke each mode. You'll observe that the setup file transposes The relevant part of the driver doc has an acknowledgement of your work on this. Please let me know if you find any issues or have any comments. |
Hello, Peter. Don't merge this pull request, but live it open, please. |
I'm currently considering where the various color_setup files should go. It seems rather confusing to have them all in one directory, but I haven't thought of a satisfactory alternative. There are two variables, host microcontroller and display adaptor. In the case of TTGO there is currently a third variable - display type - but I hope to remove that. I'm modifying the driver to handle the mapping of the various orientation options so that they work properly on any device. So if you choose PORTRAIT | USD you will get that on TTGO or Adafruit. |
Little note.
|
I appreciate that I've moved the setup file as you requested but I'm still wondering how best to organise them. The code now handles Hopefully that is the end of the API changes. |
The offset[2] will confuse users. They will think
|
Sorry for my tediousness, and thank you for your patience. The problem is that the PORTRAIT constant may be the portrait or landscape for different manufacturers in real world
More correct name is PORTRAIT is a name in an absolute coordinate system, X-Y Exchange is a name in a relative coordinate system |
I agree with you about offset and have replaced the If a new device has a different connection (as you suggest above) I'll just need to create a new object for the Regarding naming I think Landscape: text runs parallel to the long axis. I've pushed an update - barring any bugs I think I'm happy with the API. I do like the TTGO unit. It's nicely made and is surely the cheapest way to get a decent display on a MicroPython host. |
"entities should not be multiplied without necessity" https://en.wikipedia.org/wiki/Occam%27s_razor |
Hello, Peter. I think that the up-group level should be a display controller, and the next group level may be a display(or board) or manufacturer. I have tested TTGO and I am glad. |
The added abstraction is the reason for doing it :) It allows me to change the data type without changing the API. Further, there is no reason for the user to think about numeric offset values: these are an aspect of the driver and should be encapsulated in that file. In my opinion, of course. Thank you again for your work on this. It has been an enjoyable and fruitful collaboration. I'd be interested to know what application you plan for the TTGO. |
Hello, Peter.
Could you help me?
I try to add support of TTGO T-Display 1.14" 135*240(Pixel) based on ST7789V
http://www.lilygo.cn/claprod_view.aspx?TypeId=62&Id=1274
https://github.com/Xinyuan-LilyGO/TTGO-T-Display
https://github.com/Xinyuan-LilyGO/TTGO-T-Display/blob/master/image/pinmap.jpg
https://github.com/Xinyuan-LilyGO/TTGO-T-Display/blob/master/schematic/ESP32-TFT(6-26).pdf
It should work as Adafruit 1.3" and 1.54" 240x240 Wide Angle TFT LCD Display with MicroSD - ST7789
but not works.
WIP.
FactoryTest
https://github.com/Xinyuan-LilyGO/TTGO-T-Display/blob/master/TFT_eSPI/examples/FactoryTest/FactoryTest.ino
ST7789 Initialization
https://github.com/Xinyuan-LilyGO/TTGO-T-Display/blob/master/TFT_eSPI/TFT_Drivers/ST7789_Init.h
Thanks.