1) Maybe the PCD is booting up slower than the Espruino, and on startup, the Espruino is trying to talk to it before it's ready? This sounds familiar to me. Try putting the connect call in a timeout, ie:
setTimeout(function() {
g = require("PCD8544").connect(SPI1,B6,B7,B8, function() {
g.clear();
g.setContrast(0.45);
g.flip(); // copy this to the screen
setInterval(onTimer, 1000);
});},2000);
2) Remove the onInit(); on the last line. When you send the code, kick off onInit() manually for testing, or do save(); if ready to save it. I don't think this is the issue in your case, but as things get more complicated, it becomes increasingly likely that saving after onInit() will run differently than saving before 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.
Two things I'd try:
1) Maybe the PCD is booting up slower than the Espruino, and on startup, the Espruino is trying to talk to it before it's ready? This sounds familiar to me. Try putting the connect call in a timeout, ie:
2) Remove the onInit(); on the last line. When you send the code, kick off onInit() manually for testing, or do save(); if ready to save it. I don't think this is the issue in your case, but as things get more complicated, it becomes increasingly likely that saving after onInit() will run differently than saving before onInit();