Difficulty viewing text on display

Hello, everyone,
after several attempts I have been unable to display a text on my display.
The code looks like this :

long Elm = 52703000;

void DisplayElements(){

  unsigned int m = Elm/1000000;  
  unsigned int k = (Elm % 1000000)/1000; 
  unsigned int h = (Elm % 1000) / 1;  
 
  char EL_buffer[15] = "";

  if (m < 1) {
    sprintf(EL_buffer, "%003d.%003d", k, h);
  }
  else if (m < 100) {
    sprintf(EL_buffer, "%2d.%003d.%003d", m, k, h);
  }
  else if (m >= 100) {
    sprintf(EL_buffer, "%2d.%003d.%02d", m, k, h);
  }

tft.print(EL_buffer);             // don't work !! :(
}

I have tried a myriad of variations, but I have been unable to display anything!!!

Can you suggest something ?

Thank you, Roberto

You'll need to post the whole thing.

Can you get anything working with the library examples?

I have only published a small example, as the entire file is 'only' 2000 lines!

I have been unable to display a text

What actually happens? Please post the smallest, complete program that shows the problem.

What is dividing by "1" supposed to accomplish?

 unsigned int h = (Elm % 1000) / 1;  

Hi, @robymak

Have you ?
If your code is so big, did you develop it in stages, getting each stage to work separately before going to the next.
Then combining them one at a time, getting the combination working before adding the next.

This method will minimise the red herrings that a massive code is written, then tried to be debugged logically.

Please write a short code, possibly the library example and see if it works.
If not, then post the short code and a circuit diagram showing how you power and connected your hardware.

What is the display, please post links to data/spec.
What library are you using?
What model Arduino are you using?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Thank you for your answers.

I am using the following libraries with ESP32-WROOM MCU:


#include <Adafruit_GFX.h>.
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
#include <TouchScreen.h>
#include <Wire.h>

The display is a 3.5" TFT with parallel input (no clock).

The problem I have is being able to insert the display the "EL_buffer" content in different sketch locations, which I found hard to do.

Thanks again.... Roberto

If you using TFT display, why all this operations with digits?
Do you try just this:

Which problem is the problem?

When you wired up the display did you use a display example to see if the display works? It's simple, select from examples the display library and then select an example. Change the example to match the pins being used, load it up and see if it runs. Does it? See no need to post your 1000000 lines of code just post the display example code that is not working.

OK, dear friends !
Now all work correctly, thanks your suggestions.
Many thanks!

Please share your solution for others newbies.

OK b707,
this is all due to an oversight, an my idiotic mistake.
I followed the print command with 'tft.fillScreen(TFT_BLACK)'.
That's why I couldn't see anything on the display, if I had used TFT_RED (or another colour), I would have avoided bothering you and not made this bad impression..
Thank you for your attention.
Roberto

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