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

40 lines
744 B
JavaScript
Raw Normal View History

"use strict";
class DriverFactory {
constructor() {
}
createFromConfig( config ) {
let driver;
switch ( config.driver.toLowerCase() ) {
default:
console.warn( "Unknown driver defaulting to Dummy" );
case "dummy":
let { Dummy } = require( './dummy' );
driver = new Dummy();
break;
case "pimoroniunicorn":
let { PimoroniUnicorn } = require( './pimoroniunicorn' );
driver = new PimoroniUnicorn();
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;