Replies: 10 comments 1 reply
-
|
Hi @tdhoward, I've not tried to come up with a process for this yet, but I'll give it a shot. It seems to me there are 3 primary areas of concern: getting the display to show anything, dialing in colors, and dialing in the position. The first is by far the most difficult because it depends on starting with a working init string (from st7789.py in your case), getting the correct pin numbers in the right places in the board_config, and getting the polarity correct on the backlight and reset pins. Luckily, it sounds like you've gotten past that point, so we can move on. Currently, BusDisplay only works at 16-bit color depth, so that will help since we don't have to worry with several different color depths. The three things that affect colors are inversion, color order and byte swapping. Luckily they are all True-False settings, so at most there are 8 combinations to try.
Knowing all that, after you have your This is getting long. I'll pick up with positioning in the next post. |
Beta Was this translation helpful? Give feedback.
-
|
The settings that affect the image position on our display are width, height, colstart, rowstart, rotation and mirrored. (This assumes the init string in the driver is correct.) The rotation and mirrored settings depend on your application and easier to set to 0 and False, respectively, until you have the other 4 settings correct. That is to say, ignore the way you plan to use it in your project first, and instead be willing to position your project in the display's "natural" position until you get those 4 settings right. (I'm not sure if natural is the correct word here. I'll probably interchange it with native and normal in the rest of this writeup.) Comparing it to a computer monitor, we'd want to start with the monitor with it's normal "up side up", even if in our final project we're going to rotate it or mirror it. The width and height are easy as well. Just get them from you board's spec sheet. The only issue is that they may be reversed, but we'll test for that in a bit.
This line may be offset in any direction, but it will definitely go either horizontal or vertical. If it is vertical, rotate your project 90 degrees. Now we know we have the portrait / landscape orientation correct, but we don't know if it is 180 degrees off or not.
If the blue line is above the white line, rotate your project 180 degrees. Now we have it in it's "normal" posisition.
At this point, everything should be working with your display in its "normal" position. Now you can change the rotation and mirror if you need to, and it should still work. If it doesn't, that is my problem to fix in BusDisplay, not yours in the board_config. As always, please let me know how it turns out. Now that I've written this out, I plan to put some revision of it in the documentation. Feel free to add or change anything you'd like to see in the docs. |
Beta Was this translation helpful? Give feedback.
-
|
@bdbarnett This is great info, very helpful. Here are my thoughts and actions as I stepped through this with the T-Display-S3:
Through these tests, it seems like certain parameters change more things than are expected. The settings I was adjusting didn't seem to result in a display driver that worked consistently across different examples. Any suggestions for what I might be doing wrong? (Also, I've been trying out the board config for the T-Display-S3 Pro, and I have some feedback and questions on that, but I'll save it for a different discussion post.) Thanks! |
Beta Was this translation helpful? Give feedback.
-
|
@tdhoward I'm glad to hear you are using You said
I don't think you are doing anything wrong. BusDisplay just hasn't been tested (and corrected) to work with displays where colstart and rowstart aren't both 0. I need your help to figure out what must be changed in BusDisplay for these displays. Refer to lines 54 to 78 and 239 to 243 of In the MIPI Display Command Set (DCS), register 0x36 is "set_address_mode", more commonly referred to as MADCTL, which stands for "memory address control". It defines the read and write direction of the frame memory. The 8 bits in this register are:
The display controller has "frame memory", also called Graphics RAM or GRAM. Bits 7 to 5 of the MADCTL register specify the order the data bytes are written to the frame memory from the MCU. Bits 4 to 0 specify the order the data bytes are written from the frame memory to the display device. From my research, it is customary to leave Bits 1 and 0 set to 0 and use bits 7 and 6 to flip the display image. Likewise, bits 4 and 2 are usually left alone at 0. Bit 3 effects the colors displayed, but does not effect the orientation of the image on the display. That means we only need to be concerned with Bits 7, 6 and 5 for orientation. That gives us 2^3 orientations, which is 8. 4 of them show the image as you can read it in rotations of 0, 90, 180 and 270 degrees. The other 4 show the image in those same 4 rotations except mirrored, meaning you'd need to see the image in a mirror to be able to read it. These latter 4 are useful in head-up displays. In BusDisplay, I created 2 rotation tables to represent the 8 possible orientations: one with the images legible, the other with the images mirrored. If mirrored==False, _DEFAULT_ROTATION_TABLE is used. If mirrored=True, _MIRRORED_ROTATION_TABLE is used. That is to say, the mirrored setting is due to my choice of how to implement rotations, not part of the DCS spec. The rotation tables are tuples (or lists) of four 8-bit integers. The MADCTL register is written in the
The .init() method is called by This is not a permanent fix, but while you are troubleshooting, you can set I'm hoping this background gives you an idea of how to troubleshoot it. One way that comes to my mind is to do the following: This would show all 256 possible values of MADCTL without making the assumptions about bits 4, 2, 1 and 0. It will draw the display then wait 1 second. If you only want to test some of the 8 bits, you could do it this way: That would keep the setting of BGR from your board_config, then test all 32 combinations of MY, MX, MV, ML and MH while leaving the last 2 bits set to 0. Let's don't test with any of the BMP565 files yet. BMP565 does some advanced things that we need to ignore until we get rotations working correctly, particularly scrolling! Boxlines is a good test. It was originally written by russhughes and uses tft_config. The first thing it does is set the screen to landscape (WIDE) orientation, so we have to take that into account while we're testing. For instance, if you run framebuf_simpletest, it uses the display in whatever rotation it happens to currently be in. When you run boxlines, if leaves the rotation alone if it's already in a landscape orientation, but rotates it 90 degrees if it's in a portrait orientation. If you run framebuf_simpletest again without resetting the board, it will have the rotation set by boxlines, which will always be landscape. For this reason, it can look like you're running the same test but getting different results, when in actuality, it is a new test with the rotation set differently! In fact, it may be necessary to disable setting the rotation in boxlines.py or tft_config.py and only set it in the board_config.py while troubleshooting. I added this line to BusDiplay so you we can see when a device changes it's rotation: While writing this up and thinking about the results you saw, I realized that I was using ._colstart and ._rowstart in .blit_rect() without taking into consideration the rotation of the display. I have now added properties for .colstart and .rowstart that return the values of ._colstart and ._rowstart IF the rotation is 0. I need to flesh out what those two properties should return at other rotations. Up to this point, I haven't needed to know the width and height of the display controller, but instead only relied on the width and height of the display itself. If the display controller width is 240 and the display width is 170, we have the 70 pixel window I mentioned before to align the image, so we know colstart is between 0 and 70. When rotation==180, we need to recalculate the colstart from the other side of the display, so the formula is display_controller_width - display_width - _colstart. I really don't want to have to specify the display_controller_width, so I'm trying to figure out how to get that value without it. Can you think of anything? |
Beta Was this translation helpful? Give feedback.
-
|
@tdhoward I fixed a couple errors in colstart() and .rowstart() that I added today. Also, I referenced these Arduino drivers for ST7789 and see that for an ST7789 connected to a 170-pixel wide display, colstart is 35 for portrait orientations while rowstart is 0, and they are swapped for landscape orientations. I updated BusDisplay to do the same thing. Hopefully we won't need to specify the display controller dimensions after all. I haven't implemented reading from the display and don't plan to, so that would leave out querying the display even if the display allowed it. I like your idea of putting it in the |
Beta Was this translation helpful? Give feedback.
-
|
@bdbarnett When using the latest code on the T-Display-S3, I'm getting consistent behavior between framebuf_simpletest and boxlines, so that is great. I get this message from boxlines, but not from framebuf_simpletest: "ST7789.rotation(): Setting rotation to 90". At this point, all my focus is going to be on getting the S3-Pro screen working, since I need that for the class I'm teaching. |
Beta Was this translation helpful? Give feedback.
-
|
@tdhoward If you still have no display on the ST7796 on T-Display-S3 Pro, set the SPI If none of those work, I just ported the TFT_eSPI ST7796 driver to this driver for you. It shouldn't make a difference, but it's worth a shot if everything else is failing. |
Beta Was this translation helpful? Give feedback.
-
|
@bdbarnett Thanks for all your work on this! I was also poking through the TFT_eSPI driver for the ST7796. I only had to make a few adjustments to the board_config, and the display seems to be working! It's giving me the correct colors and orientation, and lines up with the edges perfectly. I'll do a PR for the T-Display-S3 Pro board_config.py, but I'm still working on the touch driver. |
Beta Was this translation helpful? Give feedback.
-
|
@tdhoward Fantastic! You are welcome, and thank you for submitting the PR. Looks like my blunders were swapping colstart with rowstart, and, more importantly, having the polarity of reset wrong. Let me know if I can help in any way. I'm taking a bit of a break from adding features or changing how things work, but I'd be glad to address any bugs or explain anything you need me to. |
Beta Was this translation helpful? Give feedback.
-
|
@bdbarnett Thanks! I so appreciate your help. Maybe I'll ask my ST7796 (S3 Pro) questions on the other thread. I'm really happy with this progress. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using a LilyGo T-Display-S3, which uses the ST7789 driver chip. When using this driver, the screen looks rotated 90 degrees, the colors are off, and there are big areas of the screen that don't get erased. I'm not sure what to adjust in the settings.
I was hoping for some helpful tips from @bdbarnett (or anyone else in the community) for how to approach this. I'm fine with reading datasheets and all that, but I was wondering if there is a particular sequence that anyone likes to go through when tuning these things. I'm picturing something like:
Any thoughts or pointers?
Beta Was this translation helpful? Give feedback.
All reactions