sparkfun / SparkFun_Qwiic_OLED_Arduino_Library

Arduino Library for SparkFun's OLED Qwiic (I²C) boards
https://docs.sparkfun.com/SparkFun_Qwiic_OLED_Arduino_Library/introduction/
Other
9 stars 7 forks source link

OLED power cycling issue #3

Closed adamgarbo closed 2 years ago

adamgarbo commented 2 years ago

Hi folks,

Looking forward to using this new library.

Currently kicking the tires with the MicroMod Data Logging Carrier Board, Artemis Processor and the Qwiic OLED. I'm running into difficulties getting the OLED working after powering down (via AP2112 LDO) and entering deep sleep on the Artemis.

The OLED successfully reinitializes when powered back up, but doesn't respond to any subsquent commands to display new data. I've used generous delays in case it needed additional time. Any thoughts on power cycling best practices?

Cheers, Adam

adamgarbo commented 2 years ago

Here's a minimum reproducible example:

#include <SparkFun_Qwiic_OLED.h>

QwiicNarrowOLED myOLED;

void setup() {
  pinMode(G2, OUTPUT); // Configure Qwiic power
  digitalWrite(G2, HIGH); // Enable Qwiic power
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);
  Serial.begin(115200);
}

void loop() {
  digitalWrite(G2, HIGH); // Enable Qwiic power
  digitalWrite(LED_BUILTIN, HIGH);
  delay(2000); // Delay to allow OLED to power on
  configureOled(); // Configure OLED
  digitalWrite(G2, LOW);  // Disable Qwiic power
  digitalWrite(LED_BUILTIN, LOW);
  delay(2000);
}

void configureOled() {
  if (!myOLED.begin())
    Serial.println("Failed to initialize!");
  else
    Serial.println("Initialized.");
  delay(2000);
  myOLED.text(0, 0, "Test", 1); // Display text
  myOLED.display();
  delay(2000);
}
ghost commented 2 years ago

Thanks for example - that really helps debug. I think the OLED needs to be re-init'd when power is re-applied.

Note: The call to begin() will only work once., since it checks if it's been called already.

Let me take a look and pull out the device init code and put it into a "resetOLED()" like method and see if that works. I think it will.

adamgarbo commented 2 years ago

Thanks @kirk-sfe,

I was just measuring the AP803 reset IC on the SSD1306 to confirm that the correct voltage threshold was being reached to properly reset the OLED. Everything looked good, so my suspicion was that it may have been initialization-related. Happy to keep testing.

Cheers, Adam

ghost commented 2 years ago

Added a reset() method, it's at the head of main.

Docs: https://sparkfun.github.io/SparkFun_Qwiic_OLED_Arduino_Library/api_device/#reset

Not tested - didn't have hardware handy - but will tomorrow.

It's using the same code that begin() uses to setup the OLED and clear out the draw/raster buffers (local and OLED device).

adamgarbo commented 2 years ago

Thanks again, @kirk-sfe!

I can also test this tomorrow. So will reset() be required before reinitializing after a power cycle?

ghost commented 2 years ago

The cycle should be:

adamgarbo commented 2 years ago

Hi @kirk-sfe ,

I just tested the reset() functionality and it's working well when removing power to the OLED. However, I haven't gotten it to work with deep sleep on the Artemis yet, though it may be specific to my application. Will keep working on it. Just got it working with deep sleep!

Also, a quicker reminder to add displayOff and reset to keywords.txt.

Thanks again.

ghost commented 2 years ago

@adamgarbo Great to hear this is working! Closing issue.

-Kirk