Graphic Display S7920 128x64 horizontal pixel shifts

Hello Guys, I’am new in the Arduino programming and have a problem.
Sorry my English is not so good :frowning:

I am use an Graphic Display ST7920 128x64 (from Amazon) the basicly programming is not the problem but i think I have a hardware timing problem.

Sporadically / often are some pixel are horizontal shift. see the Pictures in the attachement.

My Hardware Setup

  • Arduino Mega 2560 (Clone)
  • Grafik Display ST7920 128x64 on SPI
  • MAX31865 for PT100
  • Build on Breadborad
  • Library = U8G2

How or where can I change the delay for the write timing ?
I have search in the Library but I haven’t found die section :frowning:

What are meaningful Value ?

Thanks a lot for your support.

Here are the Code:

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

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

//Pins for MAX31865
const int MAX_CS = 53;
const int MAX_CLK = 52;
const int MAX_SDI = 51;
const int MAX_SDO = 50;

//Referenz Widerstand (gemessen) auf der MAX31865 
#define RREF 424.0

//Pins for LCD
const int LCD_CLK =13;
const int LCD_DATA = 11;
const int LCD_CS = 10;
const int LCD_RESET = 8;

//
char StrTemp [5];

// Use software SPI for MAX31865
Adafruit_MAX31865 max = Adafruit_MAX31865(MAX_CS, MAX_SDI, MAX_SDO, MAX_CLK);


// Use software SPI for ST7920
U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0,LCD_CLK,LCD_DATA,LCD_CS,LCD_RESET);

void setup() {
  // put your setup code here, to run once:
  max.begin(MAX31865_4WIRE);
  u8g2.begin();
  u8g2_prepare();
}

void u8g2_prepare(void){
  u8g2.enableUTF8Print();
  u8g2.setFont(u8g2_font_helvB10_tf);
  //u8g2.setFont(u8g2_font_6x10_tf);
  u8g2.setFontRefHeightExtendedText();
  u8g2.setDrawColor(1);
  u8g2.setFontPosTop();
  u8g2.setFontDirection(0);

}


void printValue(void){
//Read Temeratur
float Temp = max.temperature(100, RREF);

//Convert float to String
dtostrf(Temp,3,1,StrTemp);
//Tries
//Display bereinigen
//u8g2.begin();
//u8g2.clearDisplay();
//u8g2_prepare();

//Print static text
u8g2.drawStr(10,13,"Lufttemperatur");
u8g2.drawUTF8(70,30,"°");
u8g2.drawUTF8(76,30,"C");

//Print Values
u8g2.drawStr(35,30,StrTemp);

}

void loop() {
u8g2.firstPage();
  do{
    printValue();
    
  }while (u8g2.nextPage());

  delay(1); //For test 1-1000 tried
}

char StrTemp [5];    //good for ##.#  safer to cope with 100.1 and -10.1 i.e. [###.#]

and unnecessary redraws

  delay(1); //For test 1-1000 tried

As a general rule, you would only redraw when something changes.
All the same, the ST7920 should draw happily from infinity to beyond.

David.

Hello David, thanks for your answer but I think that's not the problem.
Yes, that's not the smallest Code ever but this can't used many resources.

I have made a video from the origanal example code and there can you see the pixel problems.
Any filled area have stripes. That's not correct. Other videos of this example doesn't show these problems.

Thanks a lot!

Yes, your video has some glitches.

I have a similar ST7920 display and it works fine.

I suggest that you post a photo of your wiring.
I suspect that you have an intermittent connection in one of the wires.

It also looks rather a lot of wires for a SPI connection.

David.

So I have a little bit experimented.

I have used the hardware SPI from the Arduino Mega 2560 with the orginal wireing ;-).

Ihe Display works fine and without Problems look at the video.

This confirms my assumption that the wiring is not the problem
but the timing for the software SPI emulator.

Why ever at my project

Maybe someone still has an idea where I can manipulate the timing.

Thx a lot
Frank