pimoroni / st7789-python

Python library to control an ST7789 240x240 1.3" TFT LCD display.
MIT License
193 stars 51 forks source link

240x320 image cannot displaying #15

Closed sangjela closed 2 years ago

sangjela commented 3 years ago

https://github.com/pimoroni/st7789-python/blob/dada81e32d22f9a619dbdc7dbe39432db781e233/library/ST7789/__init__.py#L350

result[..., [0]] = np.add(np.bitwise_and(pb[..., [0]], 0xF8), np.right_shift(pb[..., [1]], 5))

ValueError: shape mismatch: value array of shape (240,320,1) could not be broadcast to indexing result of shape (1,320,240)

in test np shape, np.array return (320, 240, 3) from image 240x320, so shape mismatch occur?

I use self.width, self.height temporately for bug fix, not self._width, self._height....

I use next initial code. .ST7789( ..., width=320, height=240 ...) //it have rotation 90 by default

slabua commented 3 years ago

@sangjela This is the proper fix . Since a transpose operation is being performed, you have to switch width with height when initialising the result array. I opened a pull request for 240x135px LCD here, but it's the same.

Gadgetoid commented 2 years ago

320x240 and 240x135 displays should be supported in v0.0.4 - https://github.com/pimoroni/st7789-python/releases/tag/v0.0.4

Thanks for your help here @slabua

I ended up re-writing the numpy conversion, since it was extremely difficult to understand at a glance and since the data is being serialized anyway there was no real need for it to use a 2D numpy array: https://github.com/pimoroni/st7789-python/commit/568e04cd64189acc532903f30514d08cb81e06dc