mirror of
https://github.com/sexybiggetje/pixdisp.git
synced 2024-11-24 17:21:02 +01:00
Initialize SPI device only whenn first write occurs
This commit is contained in:
parent
8cfa5721e1
commit
b35e2b8dc0
1 changed files with 8 additions and 2 deletions
|
@ -6,11 +6,17 @@ class PimoroniUnicorn extends Driver {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
this.initializedSpi = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
write( buffer ) {
|
||||||
|
if ( this.initializedSpi !== true ) {
|
||||||
|
this.initializedSpi = true;
|
||||||
|
|
||||||
let SPI = require( 'pi-spi' );
|
let SPI = require( 'pi-spi' );
|
||||||
this.spi = SPI.initialize( '/dev/spidev0.0' );
|
this.spi = SPI.initialize( '/dev/spidev0.0' );
|
||||||
}
|
}
|
||||||
|
|
||||||
write( buffer ) {
|
|
||||||
this.spi.write(
|
this.spi.write(
|
||||||
Buffer.concat(
|
Buffer.concat(
|
||||||
[ new Buffer( [ 0x72 ] ),
|
[ new Buffer( [ 0x72 ] ),
|
||||||
|
|
Loading…
Reference in a new issue