Same hardware: U8g2 works, U8x8 doesn't

Hello wonderful people!

I'm trying to reuse my Creality Ender 3's old screen and encoder for a project in which I need fast display code. It seems to me that U8x8 is the better option.

Now, I can't get U8x8 to work properly. I've tried both HelloWorld examples and while the u8g2 one comes clean, the u8x8 one seems rotated and full of noise.

Has anyone else experienced this?

I'm using a Pro Micro, and I've compiled and uploaded both sketches back-to-back, without changing any wiring.

Code and result for u8g2:

#include <Arduino.h>
#include <U8g2lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif

U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0,/* CS=*/ 10, /* reset=*/ 8);

void setup(void) {

  u8g2.begin();  
}

void loop(void) {
  u8g2.firstPage();
  do {
    u8g2.setFont(u8g2_font_ncenB10_tr);
    u8g2.drawStr(0,24,"Hello World!");
  } while ( u8g2.nextPage() );
  delay(1000);
}

Code and result with u8x8:

#include <Arduino.h>
#include <U8x8lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif


U8X8_ST7920_128X64_HW_SPI u8x8(/* CS=*/ 10, /* reset=*/ 8);

void setup(void)
{
  u8x8.begin();
}

void loop(void)
{
  u8x8.setFont(u8x8_font_5x8_f);
  u8x8.drawString(0,1,"Hello World!");
  u8x8.setInverseFont(1);
  u8x8.drawString(0,0,"012345678901234567890123456789");
  u8x8.setInverseFont(0);
  delay(1000);
}

Thank you all very much.

It's odd...

It looks like you need to clear the display, but u8x8.begin() does that anyway, according to the library reference document.

@olikraus can you help?

The ST7920 is kind of a very sensitive device. Maybe try to reduce bus speed (u8x8.setBusClock).

Oh, excause, I should have read the full content. I am sorry to say, that u8x8 is not supported for ST7920.

It is mentioned here: gallery · olikraus/u8g2 Wiki · GitHub

But yes, I should have told so in the u8x8 manual. Unfortunately the automatic constructor generator seems to create the U8X8 constructors, but actually it will not work.

Oh wow, thank you for such a quick response!

I'll mark this as closed then. Thank you.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.