With the previous version the following code ran correctly, but now I get an error:
____ _
| __|___ ___ ___ _ _|_|___ ___
| __|_ -| . | _| | | | | . |
|____|___| _|_| |___|_|_|_|___|
|_| espruino.com
2v05 (c) 2019 G.Williams
>
Uncaught InternalError: Timeout on SPI RX
at line 1 col 30
b.write([33,191,20,6,32,12],d);void 0!==e&&e()
^
in function called from system
>
my code:
A2.write(0); // GND
A3.write(0); // light off
A4.write(1); // VCC
SPI1.setup({ baud: 1000000, sck:A5, mosi:A7 });
var g;
var MONTHS = [
"Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"
];
function draw() {
g.clear();
var t = new Date();
var date = t.getDate()+" "+MONTHS[t.getMonth()]+" "+t.getFullYear();
var time = t.getHours()+":" +
("0"+t.getMinutes()).substr(-2);
var secs = ("0"+t.getSeconds()).substr(-2);
// top left date
g.setFontBitmap();
g.drawString(date,0,0);
// middle time
g.setFontVector(20);
var timeWidth = g.stringWidth(time);
g.drawString(time,(g.getWidth()-timeWidth-12)/2,10);
// seconds over to the right
g.setFontBitmap();
g.drawString(secs,(g.getWidth()+timeWidth-8)/2,26);
// send to LCD
g.flip();
}
function onInit() {
clearInterval();
// Setup SPI
var spi = new SPI();
// Initialise the LCD
g = require("PCD8544").connect(SPI1,A6,B0,B1, function() {
// When it's initialised, set up an animation at 20fps (50ms per frame)
setInterval(draw, 1000);
});
}
var next_state = 1;
function swap() {
A3.write(next_state);
next_state = !next_state;
}
function swap_on_down() {
if (digitalRead(BTN1) == 1) swap();
}
setWatch(swap_on_down, BTN1, true);
onInit();
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 Gordon,
I have a question:
With the previous version the following code ran correctly, but now I get an error:
my code:
Do I need to adjust the code for this?
rgds,
Reinoud