1
0
Fork 0

added delay to ensure OLED is initialized upon cold boot

This commit is contained in:
Agent725 2025-11-08 19:55:00 +01:00
parent ef76c8f579
commit 5e1a34c9d7
1 changed files with 41 additions and 38 deletions

View File

@ -2,6 +2,8 @@
* SCREENSAVER: bounces a nice little text over the screen
*/
// for some reason the OLED screen needs this timeout
setTimeout(function() {
// offsets must be defined for correct display on screen!
const Xoffset = 8;
const Yoffset = 8;
@ -16,14 +18,14 @@ function displayText(textString, x,y) {
scrn.clearRect(Xoffset + x, Yoffset + y, Xoffset + x + 30, Yoffset + y + 8);
}
// MAIN FUNCTION: bounce text and flash LED (D8)
// MAIN: flash LED (D8)
let on = false;
let x = 0;
let y = 0;
let ix = 1;
let iy = 1;
const txt = 'HELLO';
function main() {
function go() {
setInterval(function() {
on = !on;
digitalWrite("D8",on);
@ -43,4 +45,5 @@ function main() {
I2C1.setup({scl:"D6",sda:"D5"}); // I2C setup
// initialize the screen and its dimensions (null can be replaced by a callback)
const scrn = require("SSD1306").connect(I2C1, main, { width:72, height:48 }); // for 72x48 LCD
}, 5000);