adafruit / Adafruit-SSD1331-OLED-Driver-Library-for-Arduino

For 0.96" OLEDs in the Adafruit shop
http://www.adafruit.com/products/684
Other
101 stars 67 forks source link

SSD1331 1.1.0 makes writeCommand() inaccessible (also can't be reverted) #18

Closed Paraphraser closed 5 years ago

Paraphraser commented 6 years ago

I have a physical button in my project which, when pressed, results in a call to one of the following to toggle the on/off state of the OLED:

display.writeCommand(SSD1331_CMD_DISPLAYOFF); or display.writeCommand(SSD1331_CMD_DISPLAYON);

This gives me the ability to only have the OLED turned on when I need to interact with the project, hopefully also extending the life of the OLED and minimising any burn-in.

The upgrade to GFX 1.2.5 and SSD1331 1.1.0 breaks this code. Although the CMD constants are still visible in the SSD1331 header file, there is no longer a way to call writeCommand() from a sketch.

Also, when I reverted to the library versions I had installed previously (GFX 1.2.3, SSD1331 1.0.2) my sketch no longer compiles, reporting:

Adafruit_SSD1331_OLED_Driver_Library_for_Arduino/Adafruit_SSD1331.cpp:289:21: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'PortReg* {aka volatile unsigned char*}' in assignment sclkportreg = portOutputRegister(digitalPinToPort(_sclk)); ^ Adafruit_SSD1331_OLED_Driver_Library_for_Arduino/Adafruit_SSD1331.cpp:293:20: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'PortReg* {aka volatile unsigned char*}' in assignment sidportreg = portOutputRegister(digitalPinToPort(_sid)); ^ Adafruit_SSD1331_OLED_Driver_Library_for_Arduino/Adafruit_SSD1331.cpp:305:15: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'PortReg* {aka volatile unsigned char*}' in assignment csportreg = portOutputRegister(digitalPinToPort(_cs)); ^ Adafruit_SSD1331_OLED_Driver_Library_for_Arduino/Adafruit_SSD1331.cpp:308:15: error: cannot convert 'volatile uint32_t* {aka volatile unsigned int*}' to 'PortReg* {aka volatile unsigned char*}' in assignment rsportreg = portOutputRegister(digitalPinToPort(_rs)); ^ [snip] Using library Adafruit_GFX_Library at version 1.2.3 in folder: ~/Documents/Arduino/libraries/Adafruit_GFX_Library Using library Adafruit_SSD1331_OLED_Driver_Library_for_Arduino at version 1.0.2 in folder: ~/Documents/Arduino/libraries/Adafruit_SSD1331_OLED_Driver_Library_for_Arduino [snip] Error compiling for board WeMos D1 R2 & mini.

I have two computers which I (mostly) keep in parallel. The computer not yet upgraded to GFX 1.2.5 and SSD1331 1.1.0 still compiles the sketch properly so I am reasonably certain that upgrading the other computer broke something that downgrading is unable to repair.

I tried deleting both the GFX and SSD1331 libraries completely, then reinstalling GFX 1.2.3 and SSD1331 1.0.2 from scratch but that did not cure the problem.

ladyada commented 6 years ago

yeah we now subclass SPITFT which means our lives are not doomed. we could make writecommand public but because writeCommand() didnt start an SPI transaction, its a dangerous command to run :)

would you be interested in adding a new command to SPITFT called like enableDisplay(bool flag) just like invertDisplay? https://github.com/adafruit/Adafruit-GFX-Library/blob/master/Adafruit_SPITFT.cpp#L481 we'd take the PR and bump both libraries

Paraphraser commented 6 years ago

a function like enableDisplay() would certainly solve my problem so this approach has my vote.

ladyada commented 6 years ago

@Paraphraser OK! we have no plans or eta on adding this function so if you're willing to try forking and implementing it, we'd be willing to add it!

ladyada commented 5 years ago

we now have sendCommand() which does all your SPI transaction stuff for you, please use that if you plan to still add this!

Paraphraser commented 5 years ago

Your last advice about sendCommand() made me think that it really was about time I got around to doing this. You’ll find the PR in your queue. Thanks for the kick-in-the-pants.