adafruit / Adafruit-ST7735-Library

This is a library for the Adafruit 1.8" SPI display http://www.adafruit.com/products/358 and http://www.adafruit.com/products/618
https://learn.adafruit.com/1-8-tft-display
547 stars 303 forks source link

Fixed (and validated at all orientations) the display window calculation for 135x240 screen #162

Closed kevinfrei closed 2 years ago

kevinfrei commented 2 years ago

Fixed over lunch today, when I probably should have been doing other things...

This makes the ST7789 code work properly for Adafruit's 1.13" 135x240 display at all orientations. Previously, it was off-by-1 in landscape (1) and inverted portrait (2) orientations. If I followed the code properly, this is the only display that should behave differently at different orientations, there's explicit code to deal with it, but it was wrong because _colstart and _colstart2 were always the same value anyway (It looks like a previous change tried to fix it, but wound up only fixing part of the issue)

If you want to test the code out elsewhere, here's my test repo just grab the test.cpp file, rename it test.ino, set the pin numbers properly, and use it in Arduino. The code prints the orientation, while clearing the screen to blue in orientation 0, then setting the orientation and clearing it to black (so you shouldn't see any blue, but you do for 1 & 2) and the other clears the screen to green in orientation 0, then fills a centered rect black 2 pixels narrower and shorter than the screen, so you should see a green rectangle all the way around the screen (which you don't for 1 & 2 again).

You can see it in action before here and after here.

kevinfrei commented 2 years ago

160 made the problem worse: It's now wrong for all rotations! I'll get a fix together and tested. My inclination is to eliminate all the math. It's doing math with numbers that are constant due to program logic, so the math is only there to let people understand intent, I guess?

kevinfrei commented 2 years ago

Okay. The new fix cleans up after #160 for the 1.14" screen, and does it in a manner that doesn't affect any other screens (with comments explaining such). I added one more test that just draws white pixels in the corners in the test repo.

New before (which is worse than the previous before, as it doesn't work for normal rotation) and after videos for your amusement.

makermelissa commented 2 years ago

Thanks for updating this. Could you try out the library with the latest changes from #160? It appears this just swaps the colstart and colstart2 values and then uses them in each others places, so I'm wondering if this is even necessary anymore. I didn't do a release after merging #160 yet, so please try stashing your changes and updating your arduino library with the latest changes. If you're still having problems, I would like to test it out myself before merging. Otherwise, I can just do a release if it's fixed for you. Thanks

makermelissa commented 2 years ago

Oh, never mind, just saw the vids. I'll check on Monday probably.