peter-l5/SH1107

sh1107

Closed this issue · 3 comments

image
rotate=0
if self.rotate90: could run in anyway
so what is the else propose?

I mean, this statement will always be executed. How to rotate 90 degrees

Hi seeloongleft,

I'm not sure if I understand the issue you have raised correctly. Are you having a problem rotating the display?

To rotate the display you must call the SH1107_I2C or SH1107_SPI class with the rotate parameter set to 90 or 270.

The example code in the project shows this. See line 31 in both the SPI and the I2C examples. The I2C example uses rotate = 0 and the SPI example has rotate = 270.

Does this help?

In the code you highlight, the line:

self.rotate90 = rotate == 90 or rotate == 270

sets self.rotate90 to False if rotate is not equal to 90 or 270. Therefore the else statement is run if rotate equals 0.

Just to add to the earlier comment, unfortunately the driver only supports rotation by 180 degrees after initialisation of the display. Rotation by 90 and 270 degrees is only possible during construction of the display object. This is because 180 degree rotation is provided by the SH1107 chip, but to achieve 90/ 270 degree rotation different FrameBuffer and display addressing modes are used, and these cannot be readily changed after initialisation. It might be possible to amend the driver to do this but it would add complexity and I'm not sure that the effort is justified. Happy if you'd like to have a go though.

I'm going to close this issue.