Skip to content

Instantly share code, notes, and snippets.

@simonprickett
Last active June 5, 2023 10:44
Show Gist options
  • Save simonprickett/7c5e36e37bed1ae5279aa011f06960d9 to your computer and use it in GitHub Desktop.
Save simonprickett/7c5e36e37bed1ae5279aa011f06960d9 to your computer and use it in GitHub Desktop.
Flip dots example with Node.js for Raspberry Pint talk
import FlipDot from 'flipdot-display';
const flippy = new FlipDot('/dev/ttyUSB0', 6, 7, 84);
async function sleep(millis) {
return new Promise((resolve) => {
setTimeout(resolve, millis);
});
}
flippy.once('open', async function() {
console.log('Writing...');
await sleep(5000);
const SLEEP_TIME=1000;
flippy.writeText('FLIP DOTS!', { font: 'Banner' }, [0, 8], false, true);
flippy.send();
await sleep(SLEEP_TIME);
flippy.writeText('AT', { font: 'Banner' }, [0, 35], false, true);
flippy.send();
await sleep(SLEEP_TIME);
flippy.writeText('RASPBERRY', { font: 'Banner' }, [0, 6], false, true);
flippy.send();
await sleep(SLEEP_TIME);
flippy.writeText('PINT', { font: 'Banner' }, [0, 30], false, true);
flippy.send();
await sleep(SLEEP_TIME);
flippy.writeText('MAY 30 7PM', { font: 'Banner' }, [0, 7], false, true);
flippy.send();
await sleep(SLEEP_TIME);
flippy.fill(0xFF);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment