Good morning all,
Freshly new in the arduino world, I'm now at the point I discover everything.
As an arduino beginner, i didn't play with it for years before few weeks ago, I got a need when the idea to make my own power consumption supervision for my self-built camper van came to me.
The project is not so complicated on progamming side. Two main steps : ADC inputs settings at first, for then measures displaying on LCD 128x64 screen (based on ST7920).
First step, I easily managed it.
Same for 2nd one. I can show up all the informations I was expecting to, on different pages for each values which I can navigate into using an external push button. That's all good. BUT......
There's something wrong with what I could call the "refresh" of the screen. I'll try to develop it....
Let say at the first loop "lap 1"; i read my value at ADC input, and display it. Fine.
Then, loop goes back to the beginning and dive in it again "lap 2". I read the value on ADC input, to me that point is ok. (confirmed using serial monitor in IDE)
Then i display it on screen. And that's the point, at some moment, display freezes on some pixels or lines, as if I was displaying the new value of lap 2, while value of lap 1 is still on.
I think that 1 pic will make more sense than my poor poor english :
After many test with other display models, changes in loops and instructions sequencies, slowing the readings, displaying etc.... it came to me than something wrong with my understanding of ST7920 implementation. I put my project on the shelf for a while, and came back to an easier progam I found on github, pretty close to mine on the structure an clearier to understand. Same problem, some "freezes" occur each loop lap.
Find under the prog I used to debug it :
#include <DHT.h>
#include <U8g2lib.h>
#include <U8x8lib.h>
#define DHTTYPE DHT22
char temperature [5];
char humidity [5];
const char DEGREE_SYMBOL[] = { 0xB0, '\0' };
DHT dht(7, DHTTYPE);
U8G2_ST7920_128X64_1_HW_SPI u8g2(U8G2_R0, /* CS=*/ 17, /* reset=*/ 8);
void setup() {
dht.begin();
Serial.begin(9600);
u8g2.begin();
u8g2.enableUTF8Print();
u8g2.setFont(u8g2_font_helvB10_tf);
u8g2.setColorIndex(1);
}
**void loop() { **
** u8g2.firstPage();**
** do { **
** display();**
** } while( u8g2.nextPage() );**
**}**
void display(){
readTemperature();
readHumidity();
u8g2.drawFrame(0,0,128,31);
u8g2.drawFrame(0,33,128,31);
u8g2.drawStr( 15, 13, "Temperature");
u8g2.drawStr( 35, 28, temperature);
u8g2.drawUTF8(70, 28, DEGREE_SYMBOL);
u8g2.drawUTF8(76, 28, "C");
delay(100);
u8g2.drawStr(30,46, "Humidity");
u8g2.drawStr( 37, 61, humidity);
u8g2.drawStr(75,61, "%");
}
void readTemperature()
{
float t = analogRead(0);
dtostrf(t, 3, 1, temperature);
}
void readHumidity()
{
int h = dht.analogRead(1);
dtostrf(h, 3, 1, humidity);
}
My feeling is, it's something around " u8g2.firstPage();"....
If any help, informations, links, suggestions to solve that point, I'll be pleased to hear you for sure !!
Thanks in advance !