Hi, those displays are awesome! If you don't mind me asking, how much did your 7x7 one cost?
Normal 'hardware' serial has to output on specific pins on the Original/Pico/WiFi boards (for instance look for USARTx_TX pins on http://www.espruino.com/Pico#pinout). On Puck.js it can be any pin.
However, it sounds like hardware serial won't do as you're limited to 7 or 8 bits.
Instead, you can easily use digitalPulse to send out a series of pulses. What's the baud rate of the data you're sending?
You could do something a bit like this pretty easily:
function toPulses(line, baud) {
pulses = [];
// stop bit
line+="0";
// start bit
var lastBit = false; // start bit
var time = 1;
for (var x in line) {
var bit = line[x]!="0";
if (bit!=lastBit) {
pulses.push(time/baud);
time = 0;
lastBit = bit;
}
time++;
}
if (!lastBit)
pulses.push(time/baud);
return pulses;
}
var p = toPulses("1001010101010001", 9600/*baud rate*/);
digitalPulse(pin, 0, p);
So then all you need to do is set up the string you give to toPulses - start/stop bits are added automatically so you just need your 3 bits of command + x bits of data.
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, those displays are awesome! If you don't mind me asking, how much did your 7x7 one cost?
Normal 'hardware' serial has to output on specific pins on the Original/Pico/WiFi boards (for instance look for
USARTx_TX
pins on http://www.espruino.com/Pico#pinout). On Puck.js it can be any pin.However, it sounds like hardware serial won't do as you're limited to 7 or 8 bits.
Instead, you can easily use
digitalPulse
to send out a series of pulses. What's thebaud
rate of the data you're sending?You could do something a bit like this pretty easily:
So then all you need to do is set up the string you give to
toPulses
- start/stop bits are added automatically so you just need your 3 bits of command + x bits of data.