CLI supports framing and displays as many seconds as provided
This commit is contained in:
parent
275e8261a2
commit
93641a6164
|
|
@ -26,6 +26,7 @@ export declare class CLI {
|
|||
private parse;
|
||||
private parseLine;
|
||||
private execute;
|
||||
private framing;
|
||||
private expose;
|
||||
private forward;
|
||||
private backward;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ const display_1 = require("../display");
|
|||
const files_1 = require("../files");
|
||||
const delay_1 = require("../delay");
|
||||
const camera_1 = require("../camera");
|
||||
const testimage_1 = require("../testimage");
|
||||
const ffprobe_1 = require("../ffprobe");
|
||||
const image_1 = require("../image");
|
||||
let cli;
|
||||
|
|
@ -46,6 +47,9 @@ class CLI {
|
|||
async main() {
|
||||
this.log.info('Starting...');
|
||||
await (0, delay_1.delay)(10000);
|
||||
if (this.args.framing > 0) {
|
||||
await this.framing();
|
||||
}
|
||||
if (typeof this.args.input !== 'undefined') {
|
||||
this.log.info(`Loading ${(0, path_1.basename)(this.args.input)}`);
|
||||
await this.parse(this.args.input);
|
||||
|
|
@ -62,6 +66,7 @@ class CLI {
|
|||
this.height = (0, env_1.envInt)('HEIGHT', 0);
|
||||
this.host = (0, env_1.envString)('FD_HOST', 'localhost');
|
||||
this.altDimensions = this.parseDimensions((0, env_1.envString)('DIMENSIONS', null));
|
||||
//console.dir({ this.width, this.height})
|
||||
this.port = (0, env_1.envInt)('FD_PORT', 8082);
|
||||
}
|
||||
getArgs() {
|
||||
|
|
@ -98,6 +103,11 @@ class CLI {
|
|||
help: 'Enable verbose output',
|
||||
action: 'store_true'
|
||||
});
|
||||
parser.add_argument('-f', '--framing', {
|
||||
help: 'Test screen with framing grid for number of seconds (default=0)',
|
||||
type: 'int',
|
||||
default: 0
|
||||
});
|
||||
this.args = parser.parse_args();
|
||||
if (this.args.verbose) {
|
||||
console.dir(this.args);
|
||||
|
|
@ -277,6 +287,37 @@ class CLI {
|
|||
break;
|
||||
}
|
||||
}
|
||||
async framing() {
|
||||
let framingImage;
|
||||
let dimensions;
|
||||
let len = this.args.framing * 1000;
|
||||
this.display.setSource(this.width, this.height);
|
||||
if (this.altDimensions !== null) {
|
||||
this.display.setOffsetX(this.altDimensions.x);
|
||||
this.display.setOffsetY(this.altDimensions.y);
|
||||
this.display.setWidth(this.altDimensions.w);
|
||||
this.display.setHeight(this.altDimensions.h);
|
||||
framingImage = await testimage_1.TestImage.Frame(this.altDimensions.w, this.altDimensions.h);
|
||||
}
|
||||
else {
|
||||
framingImage = await testimage_1.TestImage.Frame(this.width, this.height);
|
||||
}
|
||||
dimensions = this.display.getOutgoingPosition();
|
||||
this.log.info(`Displaying framing image for ${this.args.framing} seconds...`);
|
||||
try {
|
||||
await this.fd.load(framingImage, dimensions.x, dimensions.y, dimensions.w, dimensions.h);
|
||||
}
|
||||
catch (err) {
|
||||
this.log.error(`Error loading image ${framingImage} for display`, err);
|
||||
}
|
||||
try {
|
||||
await this.fd.display(framingImage, [len]);
|
||||
}
|
||||
catch (err) {
|
||||
this.log.error(`Error displaying image ${framingImage}`, err);
|
||||
}
|
||||
await (0, promises_1.unlink)(framingImage);
|
||||
}
|
||||
async expose(cmd, invert = false) {
|
||||
const start = Date.now();
|
||||
let result;
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,3 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
node dist/cli -w 2560 -H 1600 -d 214,22,2132,1556 -f
|
||||
node dist/cli -w 2560 -H 1600 -d 214,22,2132,1556 -f 530
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ interface Args {
|
|||
height? : number;
|
||||
mock?: boolean;
|
||||
focus? : boolean;
|
||||
framing? : boolean;
|
||||
framing? : number;
|
||||
verbose? : boolean;
|
||||
dimensions? : string;
|
||||
}
|
||||
|
|
@ -92,7 +92,12 @@ export class CLI {
|
|||
|
||||
private async main () {
|
||||
this.log.info('Starting...')
|
||||
|
||||
await delay(10000);
|
||||
|
||||
if (this.args.framing > 0) {
|
||||
await this.framing();
|
||||
}
|
||||
if (typeof this.args.input !== 'undefined') {
|
||||
this.log.info(`Loading ${basename(this.args.input)}`);
|
||||
await this.parse(this.args.input);
|
||||
|
|
@ -111,7 +116,7 @@ export class CLI {
|
|||
this.host = envString('FD_HOST', 'localhost');
|
||||
this.altDimensions = this.parseDimensions(envString('DIMENSIONS', null));
|
||||
|
||||
|
||||
//console.dir({ this.width, this.height})
|
||||
this.port = envInt('FD_PORT', 8082);
|
||||
}
|
||||
|
||||
|
|
@ -155,6 +160,12 @@ export class CLI {
|
|||
help: 'Enable verbose output',
|
||||
action: 'store_true'
|
||||
});
|
||||
|
||||
parser.add_argument('-f', '--framing', {
|
||||
help : 'Test screen with framing grid for number of seconds (default=0)',
|
||||
type: 'int',
|
||||
default : 0
|
||||
})
|
||||
|
||||
this.args = parser.parse_args() as Args;
|
||||
|
||||
|
|
@ -341,6 +352,42 @@ export class CLI {
|
|||
}
|
||||
}
|
||||
|
||||
private async framing () {
|
||||
let framingImage : string;
|
||||
let dimensions : fdOutgoingPosition;
|
||||
let len : number = this.args.framing * 1000;
|
||||
|
||||
this.display.setSource(this.width, this.height);
|
||||
|
||||
if (this.altDimensions !== null) {
|
||||
this.display.setOffsetX(this.altDimensions.x);
|
||||
this.display.setOffsetY(this.altDimensions.y);
|
||||
this.display.setWidth(this.altDimensions.w);
|
||||
this.display.setHeight(this.altDimensions.h);
|
||||
framingImage = await TestImage.Frame(this.altDimensions.w, this.altDimensions.h);
|
||||
} else {
|
||||
framingImage = await TestImage.Frame(this.width, this.height);
|
||||
}
|
||||
|
||||
dimensions = this.display.getOutgoingPosition();
|
||||
|
||||
this.log.info(`Displaying framing image for ${this.args.framing} seconds...`)
|
||||
|
||||
try {
|
||||
await this.fd.load(framingImage, dimensions.x, dimensions.y, dimensions.w, dimensions.h);
|
||||
} catch (err) {
|
||||
this.log.error(`Error loading image ${framingImage} for display`, err);
|
||||
}
|
||||
|
||||
try {
|
||||
await this.fd.display(framingImage, [ len ] );
|
||||
} catch (err) {
|
||||
this.log.error(`Error displaying image ${framingImage}`, err);
|
||||
}
|
||||
|
||||
await unlink(framingImage);
|
||||
}
|
||||
|
||||
private async expose (cmd : CMD, invert : boolean = false) {
|
||||
const start : number = Date.now();
|
||||
let result : fdResult;
|
||||
|
|
@ -640,4 +687,4 @@ process.on('SIGUSR1', exitHandler.bind(null, {exit:true}));
|
|||
process.on('SIGUSR2', exitHandler.bind(null, {exit:true}));
|
||||
|
||||
// catches uncaught exceptions
|
||||
process.on('uncaughtException', exitHandler.bind(null, {exit:true}));
|
||||
process.on('uncaughtException', exitHandler.bind(null, {exit:true}));
|
||||
|
|
|
|||
Loading…
Reference in New Issue