u8g2 and LCD ST7920 in SPI MOde[SOLVED]

I want to be able to use 2 ST7920 128X64 in SPI mode, Both LCD'S are working ok. I have used the hardware SPI has I though it would be quicker than the software SPI. LCD1 CS pin is connected Pin 10 & LCD2 CS Pin is connected to Pin 9.

But on LCD1 I've got some thin lines about 2/3 pixels going across the middle and bottom of the screen, LCD2 has the same but it's double the thickness of the LCD1.

If I highlight out either one of the LCD'S so it will only print on one there's no lines going across when there is two connected it's just displaying the text. I've added a simple counter just so that I can see the digits move on the screen. If I just connect one LCD at a time and using the Graphics test example file they are perfect and don't display any thick pixels line across the middle and bottom so I know the LCD'S are good..

If I set them up using the SW_SPI as below again they work perfectly again not showing any extra pixels across the screens. Software SPI set up

U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 12, /* CS=*/ 11);
U8G2_ST7920_128X64_1_SW_SPI u8g(U8G2_R0, /* clock=*/ 10, /* data=*/ 8, /* CS=*/ 9);

Here's my test code that I've been using.

#include <Arduino.h>
#include <U8g2lib.h>
#include <SPI.h>
float Volts_disp_Ch1 = 12.36; // Holds raw battery voltage value
float Volts_disp_Ch2 = 1.057; // Holds raw battery current value
float Amps_disp_Ch1 = 0.536;
float Amps_disp_Ch2 = 1.352 ;    // MILLIAMPS
float LCD1_COUNTER = 0.00;
float LCD2_COUNTER = 00.000;
unsigned long previousMillis = 0;        // will store last time Conter was updated
const long interval = 5000;           // interval at which to blink (milliseconds)
// LCD Pins
U8G2_ST7920_128X64_2_HW_SPI u8g2(U8G2_R2, /* CS=*/ 10); // LCD 1
U8G2_ST7920_128X64_2_HW_SPI u8g(U8G2_R2, /* CS=*/ 9); // LCD 2

void setup() {
  u8g2.begin();
  u8g.begin();

}

void loop() {
  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    // save the last time it counted up
    previousMillis = currentMillis;
    LCD1_COUNTER ++;
    LCD2_COUNTER  ++;
    Volts_disp_Ch1 = Volts_disp_Ch1 + LCD1_COUNTER;
    Volts_disp_Ch2 = Volts_disp_Ch2 + LCD2_COUNTER ;
  }

  // Service LCDs
  u8g2.firstPage();          // Update LCD 1
  do {
    LCD1updatedraw();

  } while ( u8g2.nextPage() );

  u8g.firstPage();           // Update LCD 2
  do {
    LCD2updatedraw();
  } while ( u8g.nextPage() );

}
void LCD1updatedraw() {

  // Write large text to LCD (col, row, text), Sizes = 11,14,17,20,25,30,35,42,49
  u8g2.setFont(u8g2_font_fub25_tn);
  u8g2.setFontPosTop();

  //#########################
  //# DISPLAY LIVE READINGS #
  //#########################
  //if (KeyChannelSelect != 1) {  // 0=none, 1=Ch1, 2=Ch2
  if ( Volts_disp_Ch1 >= 10.00) {
    u8g2.setCursor(10, 2);
    u8g2.print(Volts_disp_Ch1, 2); // 2 dp's
  } else {
    u8g2.setCursor(10, 2);
    u8g2.print(Volts_disp_Ch1, 3); // 3 dp's
  }
  //////////////////////////////
  u8g2.setFont(u8g2_font_fub17_tn);
  if ( Amps_disp_Ch1 >= 1.00) {
    u8g2.setCursor(12, 42);
    u8g2.print(Amps_disp_Ch1, 2); // 2 dp's
  } else {
    u8g2.setCursor(2, 42);
    u8g2.print(Amps_disp_Ch1, 3); // 2 dp's
  }

  u8g2.setFont(u8g2_font_fub11_tf);
  u8g2.setFontPosTop();
  u8g2.drawStr(108, 14, "V"); // 105,13
  u8g2.setFont(u8g2_font_micro_mr );
  u8g2.drawStr(22, 33, "AMPS");
  u8g2.setFont(u8g2_font_micro_mr );
  u8g2.drawStr(74, 33, "SET AMPS");

}
// ************************ LCD 2 **************************
void LCD2updatedraw() {

  // Write large text to LCD (col, row, text), Sizes = 11,14,17,20,25,30,35,42,49
  u8g.setFont(u8g2_font_fub25_tn);
  u8g.setFontPosTop();

  //#########################
  //# DISPLAY LIVE READINGS #
  //#########################
  // if (KeyChannelSelect != 2) {  // 0=none, 1=Ch1, 2=Ch2
  if ( Volts_disp_Ch2 >= 10.00) {
    u8g.setCursor(10, 5);
    u8g.print(Volts_disp_Ch2, 2); // 2 dp's
  } else {
    u8g.setCursor(10, 5);
    u8g.print(Volts_disp_Ch2, 3); // 3 dp's
  }
  //////////////////////////////
  u8g.setFontPosTop();

  u8g.setFont(u8g2_font_fub17_tn);
  if ( Amps_disp_Ch2 >= 1.00) {
    u8g.setCursor(12, 42);
    u8g.print(Amps_disp_Ch2, 2); // 2 dp's
  } else {
    u8g.setCursor(2, 42);
    u8g.print(Amps_disp_Ch2, 3); // 2 dp's
  }
  u8g.setFontPosTop();
  u8g.setFont(u8g2_font_fub11_tf);
  u8g.setFontPosTop();
  u8g.drawStr(108, 14, "V"); // 105,13
  u8g.setFont(u8g2_font_micro_mr );
  u8g.drawStr(22, 33, "AMPS");
  u8g.setFont(u8g2_font_micro_mr );
  u8g.drawStr(74, 33, "SET AMPS");

}

I want to able to hardware SPI because it uses less pins than Hardware running out of pinns, Plus I need to add 2 MCP4822 (SPI 12Bit Dac's ) if possible using the 4 SPI devices on the 2 SPI pins with each own unit having there own CS pins ?

Found the answer to my problem here :slight_smile: