DefinitelyTyped/types/pi-camera/pi-camera-tests.ts
Ata Berk Yılmaz 7b58985484
Added 'pi-camera' type definition (#42857)
* Added pi-camera type definition

* Revised test file
2020-03-06 10:08:29 -08:00

41 lines
921 B
TypeScript

import PiCamera = require('pi-camera');
declare function log(msg: string | number | boolean): string;
const camera = new PiCamera({
mode: 'photo',
output: './test.jpg',
width: 1920,
height: 1080,
nopreview: true
});
const camera2 = new PiCamera({
mode: 'video',
output: './video.h264',
width: 1920,
height: 1080,
timeout: 5000, // Record for 5 seconds
nopreview: true,
});
camera.snap().then((result) => {
log(`Your picture was captured ${result}`);
}).catch((error: Error) => {
log(`error happened while taking picture, message: ${error}`);
});
camera2.record().then((result) => {
log(`Your video was captured ${result}`);
}).catch((error: Error) => {
log(`error happened while taking picture, message: ${error}`);
});
const widthValue = camera.get('width');
log(widthValue);
camera.set('fps', 25);
const fpsValue = camera.get('width');
log(fpsValue);