olikraus / u8glib

Arduino Monochrom Graphics Library for LCDs and OLEDs
https://github.com/olikraus/u8glib/wiki
Other
1.25k stars 314 forks source link

Issue on Teensy + U8Glib with SleepOn/Off on SSD1322 #429

Closed christophepersoz closed 7 years ago

christophepersoz commented 8 years ago

Hello,

I'm currently running U8Glib on a SSD1322 display on Teensy 3.2 board. Everything is working great, without any issues except if I'm using SleepOn() and SleepOff() functions which creates strange behaviors.

Here the simple code that makes the both functions works (just mentioned the parts that worth it, not the Chris O wrapper for Teensy etc. which is working well) :

void testSleep()
{
  (i) ? _U8G.sleepOn( ) : _U8G.sleepOff();
  (i) ? Serial.println("on") : Serial.println("off");
  i = !i;
}

void loop() {
  _U8G.firstPage();
  do {
    testSleep();
    delay(2000);
  } while( _U8G.nextPage() );
}

And here the code that makes them not working and turn the screen off :

void testSleep()
{
  (i) ? _U8G.sleepOn() : _U8G.sleepOff();
  i = !i;
}

void loop() {
  _U8G.firstPage();
  do {
    testSleep();
    delay(2000);
  } while( _U8G.nextPage() );
}

The only difference is the Serial output which makes the use of sleep function working well. As soon as I'm removing them, any call to sleepOn() or sleepOff() turn off the screen.

I had a look on the SSD1322 reference and the address for those functionality are correct. I thought about a timing issues, but introduce delay() doesn't change anything.

Any idea ?

Thanks

odenizot commented 7 years ago

Hello Christophe,

I think the static declaration of variable i is missing in function testSleep.

Cordially.

Olivier.

olikraus commented 7 years ago

If i is not zero initially, the sleepOn will be called. So: diffucult to say without the rest of the code

christophepersoz commented 7 years ago

Hello Oliver, it seems ok now, sleepOn() and sleepOff() is working correctly, my mistake.