r33ttr0
February 16, 2023, 6:48pm
1
Hello, i am trying to make a PC performance monitor using a lcd, but i have ran into a problem.
I don't know how to clear the display properly. The lcd shows 3 different screens, a main screen, update screen and a performance screen. When pressing a button it goes like this:
MAIN SCREEN -> UPDATE SCREEN -> 1 second delay -> PERFORMANCE SCREEN.
The problem occurs when transitioning from the update to the performace screen. The text from the main screen stays and doesn't clear overlaping the text from the perfomance screen. I've been trying to fix it, but haven't been succesfull. I am providing the code and pictures to get a closer idea of the problem. In advance i thank you for all the help and tips.
#include <LiquidCrystal.h>
LiquidCrystal lcd(1, 2, 4, 5, 6, 7);
int menuButton = 13;
int menu = 1;
void setup ()
{
lcd.begin (16, 2);
pinMode(menuButton, INPUT_PULLUP);
}
void loop ()
{
MainScreen();
if (!digitalRead(menuButton))
{
UpdateScreen();
delay(1000);
PerformanceMenu();
while(!digitalRead(menuButton));
}
}
void MainScreen()
{
lcd.setCursor(5, 0);
lcd.print("SenseX");
lcd.setCursor(6, 1);
lcd.print("1.1.");
}
void PerformanceMenu ()
{
lcd.clear();
lcd.print("RAM:0%");
lcd.setCursor(0,1);
lcd.print("CPU:0%");
}
void UpdateScreen ()
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Performance menu");
}
Pictures:
hi,
try this way:
PS: Recommendation Do not use pin 1 as it is part of the serial.
#include <LiquidCrystal.h>
LiquidCrystal lcd(1, 2, 4, 5, 6, 7);
int menuButton = 13;
int menu = 1;
void setup ()
{
lcd.begin (16, 2);
pinMode(menuButton, INPUT_PULLUP);
}
void loop ()
{
MainScreen();
if (!digitalRead(menuButton))
{
UpdateScreen();
delay(1000);
PerformanceMenu();
while(!digitalRead(menuButton));
}
}
void MainScreen()
{
lcd.setCursor(5, 0);
lcd.print("SenseX");
lcd.print(" ");
lcd.setCursor(6, 1);
lcd.print("1.1.");
lcd.print(" ");
}
void PerformanceMenu ()
{
lcd.clear();
lcd.print("RAM:0%");
lcd.setCursor(0,1);
lcd.print("CPU:0%");
lcd.print(" ");
}
void UpdateScreen ()
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Performance menu");
}
1 Like
r33ttr0
February 16, 2023, 6:57pm
3
Hello. Still the same problem occurs. Thanks for the pin tip tho!
OK
try this now.
#include <LiquidCrystal.h>
LiquidCrystal lcd(1, 2, 4, 5, 6, 7);
int menuButton = 13;
int menu = 1;
void setup ()
{
lcd.begin (16, 2);
pinMode(menuButton, INPUT_PULLUP);
}
void loop ()
{
MainScreen();
if (!digitalRead(menuButton))
{
UpdateScreen();
delay(1000);
PerformanceMenu();
while (!digitalRead(menuButton));
}
}
void MainScreen()
{
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(5, 0);
lcd.print("SenseX");
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(6, 1);
lcd.print("1.1.");
}
void PerformanceMenu ()
{
lcd.clear();
lcd.print("RAM:0%");
lcd.setCursor(0, 1);
lcd.print("CPU:0%");
}
void UpdateScreen ()
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Performance menu");
}
1 Like
r33ttr0
February 16, 2023, 7:23pm
5
Thanks for the help. I found the problem. I put the function for the main screen in setup. Now it doesn't loop and interfere with other stuff.
system
Closed
August 15, 2023, 7:23pm
6
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.