EPS32 using U8g2_for_TFT_eSPI libaray

I'm trying to set 2 3.2" TFT displays up using separate CS pins, My code below is for testing purpose at the moment and is working, The basic idea so that I can see that the correct displays are been written to with the code below.
Display 1.
The first line counting up from 1.023
The second line is counting down from 12.34
Display 2.
The first line counting up from 9.099
The second line is counting down from 33.21

This is working perfectly and bot displays are updating nicely, The trouble is I want to print (display) a V after the 1.023, But the trouble is that only the V is flashing faster than the count even if I change the count form 500 to 3000 interval.

I want the V to remain solid, Tried a few ways but I either don't print the V or just Print the V without the counter part showing.

Has it is at the moment it all working apart form the V flashing

/*
  In the TFT_ESPI user_setup.h file
  be sure to comment out the line for TFT_CS
  //#define TFT_CS   21  // Chip select control pin
*/

#include "SPI.h"
#include "TFT_eSPI.h"
#include "U8g2_for_TFT_eSPI.h"

#define firstScreenCS 13
#define secondScreenCS 14
TFT_eSPI tft = TFT_eSPI();       // Invoke custom library
U8g2_for_TFT_eSPI u8f;       // U8g2 font instance
unsigned long previousMillis = 0;        // will store last time LED was updated
unsigned long previousMillis1 = 0;        // will store last time LED was updated
float volts1 = 12.34;
float volts2 = 1.023;// constants won't change:
float volts3 = 9.099;
float volts4 = 33.21;// constants won't change:
const long interval = 500;

void setup() {
  pinMode(firstScreenCS, OUTPUT);
  digitalWrite(firstScreenCS, HIGH);

  pinMode(secondScreenCS, OUTPUT);
  digitalWrite(secondScreenCS, HIGH);
  // We need to 'init' both displays
  // at the same time. so set both cs pins low
  digitalWrite(firstScreenCS, LOW);
  digitalWrite(secondScreenCS, LOW);

  tft.init();
  u8f.begin(tft);
  tft.setRotation(3);
  tft.fillScreen(TFT_BLACK);
  // Set both cs pins HIGH, or 'inactive'
  digitalWrite(firstScreenCS, HIGH);
  digitalWrite(secondScreenCS, HIGH);

}

void loop() {
  u8f.setFontMode(0);                 // use u8g2 none transparent mode
  u8f.setFontDirection(0);            // left to right (this is default)
  unsigned long currentMillis1 = millis();
  unsigned long currentMillis = millis();
  //#######################
  //# COUNT ON SCREEN ONE #
  //#######################
  if (currentMillis - previousMillis >= interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;
    volts2 = volts2 + 0.001;
    volts1 = volts1 - 0.01;
  }
  //#######################
  //# COUNT ON SCREEN TWO #
  //#######################
  if (currentMillis1 - previousMillis1 >= interval) {
    // save the last time you blinked the LED
    previousMillis1 = currentMillis1;
    volts3 = volts3 + 0.001;
    volts4 = volts4 - 0.01;
  }
  //#######################
  //# PRINT ON SCREEN ONE #
  //#######################

  digitalWrite(firstScreenCS, LOW);
  u8f.setFontMode(0);
  u8f.setFontDirection(0);
  u8f.setFont(u8g2_font_logisoso46_tr);
  u8f.setForegroundColor(TFT_WHITE);  // apply color// start writing at this position
  u8f.setCursor(230, 100);
  u8f.print(" V "); // numerical value
  u8f.setFont(u8g2_font_inb63_mn);    // select u8g2 font from here: https://github.com/olikraus/u8g2/wiki/fntlistall
  u8f.setForegroundColor(TFT_GREEN);  // apply color// start writing at this position
  u8f.setCursor(0, 100);
  u8f.print(volts2, 3);
  u8f.print(" "); // numerical value
  u8f.setForegroundColor(TFT_YELLOW);  // apply color
  u8f.print(" "); // numerical value
  u8f.setCursor(0, 180);
  u8f.print(volts1, 2);
  u8f.print(" "); // numerical value
  digitalWrite(firstScreenCS, HIGH);
  //#######################
  //# PRINT ON SCREEN TWO #
  //#######################

  digitalWrite(secondScreenCS, LOW);
  u8f.setFont(u8g2_font_inb63_mn);    // select u8g2 font from here: https://github.com/olikraus/u8g2/wiki/fntlistall
  u8f.setForegroundColor(TFT_GREEN);  // apply color// start writing at this position
  u8f.setCursor(0, 100);
  u8f.print(volts3, 3);
  u8f.print(" "); // numerical value
  u8f.setForegroundColor(TFT_YELLOW);  // apply color
  u8f.print(" "); // numerical value
  u8f.setCursor(0, 180);
  u8f.print(volts4, 2);
  u8f.print(" "); // numerical value
  digitalWrite(secondScreenCS, HIGH);
}

Also not sure if there is a better way to update the screens other than toggling the CS pins for each display

Ignore my flashing V part, I left a space Gap " " in there which I thought I'd already commented out as I got the display working first.

So is this the nest way to update the display or is there an more elegant way of doing it rather than setting the CS pin low - then print data -Setting CS pin HIGH ?

This topic was automatically closed after 120 days. New replies are no longer allowed.