2018-01-07 09:24:32 +01:00
|
|
|
'use strict';
|
2017-12-18 20:39:51 +01:00
|
|
|
|
|
|
|
class DriverFactory {
|
|
|
|
constructor() {
|
|
|
|
}
|
|
|
|
|
|
|
|
createFromConfig( config ) {
|
|
|
|
|
|
|
|
let driver;
|
|
|
|
|
|
|
|
switch ( config.driver.toLowerCase() ) {
|
|
|
|
|
2018-01-07 09:24:32 +01:00
|
|
|
default:
|
|
|
|
// eslint-disable-next-line
|
|
|
|
console.warn( 'Unknown driver defaulting to Dummy' );
|
|
|
|
break;
|
2017-12-18 20:39:51 +01:00
|
|
|
|
2018-01-07 09:24:32 +01:00
|
|
|
case 'dummy':
|
|
|
|
let { Dummy } = require( './dummy' );
|
|
|
|
driver = new Dummy();
|
2017-12-18 20:39:51 +01:00
|
|
|
break;
|
|
|
|
|
2018-01-07 09:24:32 +01:00
|
|
|
case 'pimoroniunicorn':
|
|
|
|
let { PimoroniUnicorn } = require( './pimoroniunicorn' );
|
|
|
|
driver = new PimoroniUnicorn();
|
2017-12-18 20:39:51 +01:00
|
|
|
break;
|
|
|
|
|
2018-07-03 19:39:50 +02:00
|
|
|
case 'motionjpeg':
|
|
|
|
let { MotionJPEG } = require( './motionjpeg' );
|
|
|
|
driver = new MotionJPEG();
|
|
|
|
break;
|
|
|
|
|
2017-12-18 20:39:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
driver.setSize( config.matrix.width, config.matrix.height );
|
|
|
|
driver.setBrightness( config.matrix.brightness );
|
|
|
|
|
|
|
|
driver.flipHorizontal = config.matrix.flipHorizontal;
|
|
|
|
driver.flipVertical = config.matrix.flipVertical;
|
|
|
|
|
|
|
|
return driver;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.DriverFactory = DriverFactory;
|