Good morning to all,
before anything else I want to say that I'm a beginner and I'm simply having fun with Arduino and the like.
I feel a bit embarrassed to post this because I'm afraid it's just a stupid thing I'm fighting with, due to my lack of experience.
In any case, here is the problem.
I'm playing with an OLED display ( 1.30", 132 x 64, SH1106 driven) and I'm trying to have a vertically scrolling text. The program is developed on Arduino but, when complete, it will be ported to an Heltec WiFi-Kit-32 where I have a barometer program, with static display, which runs smoothly .
Now, the simple text scroll program runs in a very erratic way:
on Arduino Nano it goes on forever
on Arduino UNO it runs for 10-12 complete scroll cycles and then freezes
on Arduino Mega it runs for 1-2 complete scroll cycles and then freezes.
It's quite weird and I'm sure there is a simple reason behind it but I cannot figure it out.
has anybody any explanation for such behaviour?
Many thanks in advance
/*
* Fabrizio M. Bianchi 19 - January - 2021
*
* Test program to have a vertically scrolling text on an OLED display
* initially developed on an Arduino but meant for ESP32 based modules
* For some still unknown reason the void loop runs for a few cycles on Arduino Mega and it stops casuallly,
* for some tens of cycles on the UNO and on the NANO .
*
* Display : 1.3" - 128 x 60
* Color : White
* Driver : SH1106 ( SSD1306 for Heltec WiFi-Kit-32)
* Connectivity : I2C default pins (A4 and A5 for Uno, D20 and D21 for Mega2560
*
*/
#include <Wire.h>
#include <U8g2lib.h>
int line;
// Display Constructor for the 0,96" embedded display on Heltec WiFi-Kit-32
// U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, 16, 15, 4);
// Display Constructor for 1.30" display with SH1106
U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0,/*reset*/U8X8_PIN_NONE);
void setup() {
// Graphic Library Initialization
u8g2.begin();
u8g2.setFont(u8g2_font_9x15_tf);
u8g2.setFontRefHeightExtendedText();
u8g2.setDrawColor(1);
u8g2.setFontPosTop();
u8g2.setFontDirection(0);
}
void loop() {
for (line = 0; line <=64; line = line += 8) {
u8g2.clearBuffer();
u8g2.drawStr(24, line, "Barometro");
u8g2.drawStr(24, (line + 18), "Pressione");
u8g2.sendBuffer();
delay(200);
}
}