Merge pull request #29909 from xtrimsystems/master

Package: Johnny-five - Added objects MotorPins and Motors
This commit is contained in:
Daniel Rosenwasser 2018-11-12 10:58:54 -08:00 committed by GitHub
commit 867913d396
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 6 deletions

View File

@ -3,6 +3,7 @@
// Definitions by: Toshiya Nakakura <https://github.com/nakakura>
// Zoltan Ujvary <https://github.com/ujvzolee>
// Simon Colmer <https://github.com/workshop2>
// XtrimSystems <https://github.com/xtrimsystems>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///<reference types="node"/>
@ -514,9 +515,16 @@ export class Motion {
on(event: "calibrated", cb: () => void): this;
}
export interface MotorPins {
pwm: number;
dir: number;
cdir?: number;
brake?:number;
}
export interface MotorOption {
pins: any;
current?: any;
pins: MotorPins;
current?: SensorOption;
invertPWM?: boolean;
address?: number;
controller?: string;
@ -525,7 +533,7 @@ export interface MotorOption {
}
export declare class Motor {
constructor(option: Array<number> | MotorOption);
constructor(option: number[] | MotorOption);
readonly isOn: boolean;
@ -533,8 +541,22 @@ export declare class Motor {
fwd(speed: number): void;
reverse(speed: number): void;
rev(speed: number): void;
start(): void;
start(speed: number): void;
start(speed?: number): void;
stop(): void;
brake(): void;
release(): void;
}
export declare class Motors {
constructor(option: number[] | MotorOption[]);
readonly isOn: boolean;
forward(speed: number): void;
fwd(speed: number): void;
reverse(speed: number): void;
rev(speed: number): void;
start(speed?: number): void;
stop(): void;
brake(): void;
release(): void;
@ -625,7 +647,7 @@ export declare class Ping {
export declare interface ProximityOption {
pin: number | string;
controller: string;
}
}
export declare interface ProximityData {
cm: number;
@ -665,6 +687,7 @@ export interface SensorOption {
pin: number | string;
freq?: boolean;
threshold?: number;
enabled?: boolean;
}
export declare class Sensor {

View File

@ -155,6 +155,11 @@ board.on('ready', function(){
}
});
var motors = new five.Motors([
{ controller: 'PCA9685', pins: { pwm: 4, dir: 6 }},
{ controller: 'PCA9685', pins: { pwm: 5, dir: 7 }}
]);
var piezo = new five.Piezo(3);
// Plays a song