Hello,
i'm writing a simple timer using an Adafruit 7 segment display which uses I2C.
I have made a working prototype using the original kickstarted Espruino and wanted to transfer the design to the pico.
The display requires initialization which I do in an E.on('init') as well as inline:
function ledInit() {
I2C1.setup({scl:B6, sda:B7});
initAddr = (addr) => {
I2C1.writeTo(addr, 0x21); // clock on
I2C1.writeTo(addr, 0x81); // flash
I2C1.writeTo(addr, 0xE0 | 3); // brightness 15
};
initAddr(0x70);
}
E.on('init', function() { //doesn't work on pico
USB.setConsole();
digitalPulse(LED2,1,200);
ledInit();
}
ledInit(); //doesn't work on pico
For the pico, i changed the pins to B10 and B3
The problem is that while i'm on USB, the init works just fine. However, when I save the code and run it with a battery, the LED init fails. I later tried to call the init on BTN1 and that works fine. Something about initial power that's not working. I tried setTimeout to call it and that fails as well.
I also tried the USB.console trick and that didn't help.
setTimeout(ledInit,2000); // doesn't work
setWatch(ledInit, BTN1, { repeat: true, debounce: 50 }); // works but is less than ideal
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.
Hello,
i'm writing a simple timer using an Adafruit 7 segment display which uses I2C.
I have made a working prototype using the original kickstarted Espruino and wanted to transfer the design to the pico.
The display requires initialization which I do in an E.on('init') as well as inline:
For the pico, i changed the pins to B10 and B3
The problem is that while i'm on USB, the init works just fine. However, when I save the code and run it with a battery, the LED init fails. I later tried to call the init on BTN1 and that works fine. Something about initial power that's not working. I tried setTimeout to call it and that fails as well.
I also tried the USB.console trick and that didn't help.
Any ideas?
I'm running latest firmware available