OLED DISPLAY

I have NodeMCU (ESP8266) to display on 128x64 I2C OLED

I wanted to update Few parameter values on display with timer Interrupt. but i could able to see any
updation here. can someone helpme out

MODE: AUTO/MANUAL

TIME: 15:55:55

TimeZOne: Timezone1/Timezone2/Timezone3/Timezone4

Relay_Status:ON/OFF
The problem i am facing is data is updating in next windows. & keep going.
in First screen my first string are same i,e MODE: TIme: Timezone:Reelay_status
others are just status output. but below code it keep moving in next window. if any idle space is there it occupy that space. like wise 16X2 i could not able to set cursor postion and then write value /update values

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET LED_BUILTIN  //4
Adafruit_SSD1306 display(OLED_RESET);

void setup()
{
  Serial.begin(115200);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.display();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
 timer.setInterval(1000, Display);
}



void Display()
{
  // display.clearDisplay();
  display.print("MODE:");
  if (manual == 0)
  {
    //  display.setTextColor(WHITE);
    display.println("AUTO");
      display.display();
  } else
  {
    // display.setTextColor(WHITE);
    display.println("MODE");
      display.display();
  }
   display.setTextColor(WHITE);
  display.print("TIME:");
  display.println(currentTime);
  display.display();
  display.clearDisplay();

}

I wanted to update Few parameter values on display with timer Interrupt.

Can you not use millis() for timing the update ?

If i am using like this it wont updating. It display only first paras. Serial print displaying chnage in status of auto/ manual mode.current time , relay status but not updating in display

void loop()
{
updateScreen() ;
}

void updateScreen() {
unsigned long currentTime = millis();
static unsigned long previousTime = 0;
const unsigned long interval = 500;  // Every half second
if (currentTime - previousTime >= interval) {
    previousTime += interval;
   Display();
  }
}




void Display()
{
  display.print("MODE:");
  if (manual == 0)
  {
    //display.setTextColor(WHITE);
    display.println("AUTO");
    display.display();
  } else
  {
    // display.setTextColor(WHITE);
    display.println("MANUAL");
    display.display();
  }
  // display.setTextColor(WHITE);
  display.print("TIME:");
  display.println(currentTime);
  display.display();
  //display.setTextColor(WHITE);
  display.print("TIME_ZONE:");
  display.println(TimeZone_Status);
  display.display();
  display.print("RELAY STATUS:");
  if (Relay_Status == 1)
  {
    display.println("ON");
    display.display();
  } else
  {
    display.println("OFF");
    display.display();
  }

  //display.clearDisplay();

}

Whatever the Intial value while upload its being reflected in Display & it wont change . even status are changed

Don't you need to set the output position on the screen before printing to it ?

How can i do that. I am setting postion only once in setup()

void setup()
{
  Serial.begin(115200);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.display();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
 timer.setInterval(1000, Display);
}

If I am doing like this Text not updating properly.its just ovelap on each other

void Display()
{
   display.setCursor(0, 0);
  //display.clearDisplay();
 display.print("MODE:");
  if (manual == 0)
  {
    //display.setTextColor(WHITE);
    display.println("AUTO");
    display.display();
  } else
  {
    // display.setTextColor(WHITE);
    display.println("MANUAL");
    display.display();
  }
  // display.setTextColor(WHITE);
  display.print("TIME:");
  display.println(currentTime);
  display.display();
  //display.setTextColor(WHITE);
  display.print("TIME_ZONE:");
  display.println(TimeZone_Status);
  display.display();
  display.print("RELAY STATUS:");
  if (Relay_Status == 1)
  {
    display.println("ON");
    display.display();
  } else
  {
    display.println("OFF");
    display.display();
  }


}

If I am doing like this Text not updating properly.its just ovelap on each other

Crude way : clear the display and set the cursor to 0, 0 at the start of the Display function

Nicer way : blank the current text that has changed with the background colour before writing the new text in the Display() function

Overall you would be better to use setCursor() before each print to allow fine control of the text position.

I have modified code as below. So its started working. I need help in displaying text color
i have attched display image for reference.

i would like to Know Things with MODE:,Currenttime:TIME_ZONE:RELAY STATUS:
must be display with one colours other status with other colour

void Display()
{
  Chk_manual_Auto_Status();
  display.setCursor(0, 0);
  //display.clearDisplay();
  display.print("MODE:");
  if (manual == 0)
  {
    //display.setTextColor(WHITE);
    display.clearDisplay();
    display.println("AUTO");
    display.display();
  } else
  {
    // display.setTextColor(WHITE);
    display.clearDisplay();
    display.println("MANUAL");
    display.display();
  }
  // display.setTextColor(WHITE);
  display.print("TIME:");
  display.println(currentTime);
  display.display();
  //display.setTextColor(WHITE);
  display.print("TIME_ZONE:");
  display.println(TimeZone_Status);
  display.display();
  display.print("RELAY STATUS:");
  if (Relay_Status == 1)
  {
    display.println("ON");
    display.display();
  } else
  {
    display.println("OFF");
    display.display();
  }
  delay(2000);

}

What happens when you use the setTextColor() function ?

i can use only 2 color White or black. if its white remain same ,if black no text will be displayed.
I would like to know how yellow color being displayed.

I would like to know how yellow color being displayed.

It is likely that the library has a number of constants defined for common colours, but you can do it yourself (see below)

Have a look at https://cdn-learn.adafruit.com/downloads/pdf/adafruit-gfx-graphics-library.pdf which I think relates to the library that you are using but I cannot be sure. In particular look at page 6

For the most common primary and secondary colors, we have this handy cheat-sheet that you
can include in your own code. Of course, you can pick any of 65,536 different colors, but this
basic list may be easiest when starting out:
// Color definitions
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF

i tried using by defining it. displaying is blackout by adding part of it

void Display()
{
  Chk_manual_Auto_Status();
  display.setCursor(0, 0);
  //display.clearDisplay();
  display.print("MODE:");
  if (manual == 0)
  {
   //display.setTextColor(WHITE);
   display.clearDisplay();
    display.println("AUTO");
    display.display();
  } else
  {
    //display.setTextColor(WHITE);
    display.clearDisplay();
    display.println("MANUAL");
    display.display();
  }
  display.setTextColor(BLUE);
  display.print("TIME:");
   //display.clearDisplay();
  display.println(currentTime);
 
  display.display();
  //display.setTextColor(WHITE);
  display.print("TIME_ZONE:");
  display.println(TimeZone_Status);
  display.display();
  display.print("RELAY STATUS:");
  if (Relay_Status == 1)
  {
    display.println("ON");
    display.display();
  } else
  {
    display.println("OFF");
    display.display();
  }
  delay(2000);

}

Come on AMPS. You have been here long enough to know that if you change your code and still want help then you should post the whole revised program.