Added value object MotorPins for pins in MotorOption, added class Motors and update SensorOption to use new attribute enabled

This commit is contained in:
xtrimsystems
2018-10-20 21:51:02 +02:00
parent 0e95a07e46
commit 4b0e234427
2 changed files with 33 additions and 3 deletions
+28 -3
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;
@@ -540,6 +548,22 @@ export declare class Motor {
release(): void;
}
export declare class Motors {
constructor(option: Array<number> | MotorOption[]);
readonly isOn: boolean;
forward(speed: number): void;
fwd(speed: number): void;
reverse(speed: number): void;
rev(speed: number): void;
start(): void;
start(speed: number): void;
stop(): void;
brake(): void;
release(): void;
}
export interface OrientiationOption {
controller?: string;
freq?: number;
@@ -625,7 +649,7 @@ export declare class Ping {
export declare interface ProximityOption {
pin: number | string;
controller: string;
}
}
export declare interface ProximityData {
cm: number;
@@ -665,6 +689,7 @@ export interface SensorOption {
pin: number | string;
freq?: boolean;
threshold?: number;
enabled?: boolean;
}
export declare class Sensor {
+5
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