1
0
Fork 0
mirror of https://github.com/sexybiggetje/pixdisp.git synced 2024-11-15 06:31:01 +01:00
pixdisp/drivers/pimoroniunicorn.js

35 lines
566 B
JavaScript
Raw Normal View History

2017-12-12 20:41:32 +01:00
"use strict";
let { Driver } = require( './driver' );
class PimoroniUnicorn extends Driver {
2017-12-12 20:41:32 +01:00
constructor() {
super();
this.initializedSpi = false;
2017-12-12 20:41:32 +01:00
}
write( buffer ) {
if ( this.initializedSpi !== true ) {
this.initializedSpi = true;
let SPI = require( 'pi-spi' );
this.spi = SPI.initialize( '/dev/spidev0.0' );
}
2017-12-12 20:41:32 +01:00
this.spi.write(
Buffer.concat(
[ new Buffer( [ 0x72 ] ),
buffer ]
),
function ( err ) {
if ( err ) {
throw 'Failed writing buffer';
}
}
);
}
}
exports.PimoroniUnicorn = PimoroniUnicorn;