I made my way through the tutorial material, including the 'stats.py' program, which I cut and pasted from the web site. To get it to display correctly on the 240x240 display, I had to adjust the call to create the display object, which was set up for the 135 x 240 display:
- Code: Select all | TOGGLE FULL SIZE
disp = st7789.ST7789(
spi,
cs=cs_pin,
dc=dc_pin,
rst=reset_pin,
baudrate=BAUDRATE,
width=135,
height=240,
x_offset=53,
y_offset=40,
)
OK, so setting width and height to 240 seemed obvious enough. But it took some trial and error to arrive at an x_offset of 0 and a y_offset of 80.
My question is: what do those numbers represent? I assume not pixels, since if so, skipping a third of the display height doesn't seem right. And in any case, I (say) used 90 instead of 80, the display was garbled, not simply moved by an additional 10 whatevers.
I later found another body of example code, which had various offsets for different displays, and the 240x240 y_offset was given as 80, matching the value I found 'the long way round'. But the values just seemed to be magic numbers in the code.