Hi,
The following (much cut down) code works fine when uploaded from the IDE but after using save() and power cycling it appears as if setInterval has no effect. The LCD and clock then update as quickly as possible (the clock goes through a day in about 6 seconds).
On power-up or after using load() it exhibits this problem.
However, if I then press the physical reset button or use E.reboot() from the IDE it will run properly.
I may just be that I'm not setting things up properly for using save() with setInterval (I rarely use save).
This is on an original Espruino board with added 32.168kHz crystal.
Firmware is version 2v03.21 but with some fonts compiled in.
Any ideas?
Thanks,
Jamie
let data_rec = Array(7)
let lcd = undefined
let Tmin = undefined
let Tmax = undefined
function LCD_init(spi) {
let lcd = require("PCD8544").connect(spi,A6,B0,B1, function() {
lcd.clear()
lcd.flip()
}
)
return lcd
}
function LCD_update() {
lcd.clear()
let d = new Date().toISOString()
// split the datetime string to fit the screen
lcd.drawString(d.split('T')[0].replace('-','.').replace('-','.'),0,0)
lcd.drawString(d.split('T')[1].split('.')[0],50,0)
// update display with data
lcd.drawString(data_rec[6],20,20)
lcd.flip()
}
function data_update() {
// updates the data_rec with data from other sources
data_rec[6]=analogRead(C1)*3.3*3/2
}
function onInit() {
clearInterval()
clearWatch()
// initialize the rtc from the DS3231
I2C1.setup({sda:B9,scl:B8})
rtc = require("DS3231_J").connect(I2C1)
let t = rtc.timeArray()
setTime((new Date(t[0],t[1]-1,t[2],t[3],t[4],t[5],0).getTime())/1000)
data_rec = [new Date(), 0,0, 0.0, 0.0, 'K', 1, 0.0]
// initialize the LCD
SPI1.setup({sck:A5, mosi:A7})
lcd = LCD_init(SPI1)
setTimeout(function() {
setInterval(LCD_update, 500)
}, 1000)
// timeout used here to allow for the initial data reading to complete
setTimeout(function () {setInterval(data_update,1000)}, 1500)
}
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi,
The following (much cut down) code works fine when uploaded from the IDE but after using save() and power cycling it appears as if setInterval has no effect. The LCD and clock then update as quickly as possible (the clock goes through a day in about 6 seconds).
On power-up or after using load() it exhibits this problem.
However, if I then press the physical reset button or use E.reboot() from the IDE it will run properly.
I may just be that I'm not setting things up properly for using save() with setInterval (I rarely use save).
This is on an original Espruino board with added 32.168kHz crystal.
Firmware is version 2v03.21 but with some fonts compiled in.
Any ideas?
Thanks,
Jamie