Skip to content

Commit

Permalink
Add ability to reset display without clearing CGRAM or turning displa…
Browse files Browse the repository at this point in the history
…y off.
  • Loading branch information
nseidle committed Mar 30, 2022
1 parent 045c9dc commit cf4cce5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SparkFun Qwiic OLED Graphics Library
version=1.0.3
version=1.0.4
author=SparkFun Electronics <techsupport@sparkfun.com>
maintainer=SparkFun Electronics <sparkfun.com>
sentence=Library for SparkFun SSD1306 based OLED display products.
Expand Down
7 changes: 4 additions & 3 deletions src/SparkFun_Qwiic_OLED.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,11 @@ class QwiicOLEDBaseClass : public Print { // NOTE: implementing Arduino Print
//
// Parameter Description
// --------- -----------------------------
// retval true on success, false on failure
// clearDisplay true - clear the internal buffers during reset
// retval true on success, false on failure

bool reset(void){
return _device.reset();
bool reset(bool clearDisplay){
return _device.reset(clearDisplay);
}

///////////////////////////////////////////////////////////////////////
Expand Down
17 changes: 9 additions & 8 deletions src/qwiic_grssd1306.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ bool QwGrSSD1306::init(void)
//
// Returns true on success, false on failure

bool QwGrSSD1306::reset(void){
bool QwGrSSD1306::reset(bool clearDisplay){

// If we are not in an init state, just call init
if(!_isInit)
Expand All @@ -275,11 +275,11 @@ bool QwGrSSD1306::reset(void){
return false;

// setup oled
setup_oled_device();
setup_oled_device(clearDisplay);

// Init internal/drawing buffers and device screen buffer

init_buffers();
if(clearDisplay)
init_buffers();

return true;
}
Expand Down Expand Up @@ -320,11 +320,12 @@ void QwGrSSD1306::set_contrast(uint8_t contrast){
// Method sends the init/setup commands to the OLED device, placing
// it in a state for use by this driver/library.

void QwGrSSD1306::setup_oled_device(void){
void QwGrSSD1306::setup_oled_device(bool clearDisplay){

// Start the device setup - sending commands to device. See command defs in header, and
// device datasheet
send_dev_command(kCmdDisplayOff);
if(clearDisplay)
send_dev_command(kCmdDisplayOff);

send_dev_command(kCmdSetDisplayClockDiv, 0x80);
send_dev_command(kCmdSetMultiplex, _viewport.height - 1);
Expand All @@ -346,8 +347,8 @@ void QwGrSSD1306::setup_oled_device(void){
send_dev_command(kCmdSetVComDeselect, _initVCOMDeselect);
send_dev_command(kCmdDeactivateScroll);

send_dev_command(kCmdDisplayOn);

if(clearDisplay)
send_dev_command(kCmdDisplayOn);
}
////////////////////////////////////////////////////////////////////////////////////
// set_comm_bus()
Expand Down
4 changes: 2 additions & 2 deletions src/qwiic_grssd1306.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class QwGrSSD1306 : public QwGrBufferDevice {
// Device setup
virtual bool init(void);
bool is_initialized(void) { return _isInit; };
bool reset(void);
bool reset(bool clearDisplay = true);

// method to set the communication bus this object should use
void set_comm_bus(QwI2C &theBus, uint8_t id_bus);
Expand Down Expand Up @@ -234,7 +234,7 @@ class QwGrSSD1306 : public QwGrBufferDevice {
void init_buffers(void); // clear graphics and screen buffer
void clear_screen_buffer(void);
void resend_graphics(void);
void setup_oled_device(void);
void setup_oled_device(bool clearDisplay = true);

// device communication methods
void send_dev_command(uint8_t command);
Expand Down

0 comments on commit cf4cce5

Please sign in to comment.