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