1
0
Fork 0
mirror of https://github.com/sexybiggetje/pixdisp.git synced 2024-11-24 20:51:02 +01:00
pixdisp/drivers/driverfactory.js

47 lines
890 B
JavaScript
Raw Permalink Normal View History

2018-01-07 09:24:32 +01:00
'use strict';
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;
2018-01-07 09:24:32 +01:00
case 'dummy':
let { Dummy } = require( './dummy' );
driver = new Dummy();
break;
2018-01-07 09:24:32 +01:00
case 'pimoroniunicorn':
let { PimoroniUnicorn } = require( './pimoroniunicorn' );
driver = new PimoroniUnicorn();
break;
case 'motionjpeg':
let { MotionJPEG } = require( './motionjpeg' );
driver = new MotionJPEG();
break;
}
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;