You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! I am interested in finding a definition file for firmata.js (or in helping to generate one). The way I'm giving myself typescript support for firmata.js right now is INCREDIBLY HACKY. In fact, I know its the wrong way and I know all it is doing is keeping the compiler from complaining and helping provide me with some auto-completion. So I would really like some help in figuring out the right way to do this. Eventually I'd like to include a typings file in DefinitelyTyped so I can use $ typings search firmata and $ typings install --save --global dt~firmata.
What I have so far I use with
import { IBoard } from './interfaces/Firmata';
And the file Firmata.d.ts has this for its contents
/** * Created by troy on 9/19/16. */// Most of these are generated by observing https://github.com/firmata/firmata.js/blob/master/lib/firmata.js// TODO this can definitely be done better with a better understanding of prototypal inheritanceimportSerialPort= require("serialport");exportinterfaceIBoard{// ==========// Properties// ==========MODES:{INPUT:number,OUTPUT:number,ANALOG:number,PWM:number,SERVO:number,SHIFT:number,I2C:number,ONEWIRE:number,STEPPER:number,SERIAL:number,PULLUP:number,IGNORE:number,PING_READ:number,UNKOWN:number},I2C_MODES:{WRITE:number,READ:number,CONTINUOUS_READ:number,STOP_READING:number},STEPPER:{TYPE:{DRIVER:number,TWO_WIRE:number,FOUR_WIRE:number},RUNSTATE:{STOP:number,ACCEL:number,DECEL:number,RUN:number},DIRECTION:{CCW:number,CW:number}},SERIAL_MODES:{CONTINUOUS_READ:number,STOP_READING:number},SERIAL_PORT_IDs:{HW_SERIAL0:number,HW_SERIAL1:number,HW_SERIAL2:number,HW_SERIAL3:number,SW_SERIAL0:number,SW_SERIAL1:number,SW_SERIAL2:number,SW_SERIAL3:number,DEFAULT:number,},SERIAL_PIN_TYPES:{RES_RX0:number,RES_TX0:number,RES_RX1:number,RES_TX1:number,RES_RX2:number,RES_TX2:number,RES_RX3:number,RES_TX3:number,},HIGH:number,LOW:number,pins:[{mode:number,value:number,supportedModes:number[],analogChannel:number,state:number}],ports:number[],analogPins:number[],version:{},firmware:{name:string,version:{major:number,minor:number},},currentBuffer:number[],versionReceived:boolean,name:string,settings:IOptions,// TODO handle this more cleanly, currently a black boxtransport:SerialPort,// ====================// Constructor Function// ====================Board:(port:string|IPort,options?:IOptions,callback?:(err:any)=>void)=>IBoard,// =================// Prototype Methods// =================reportVersion:()=>void,queryFirmware:()=>void,analogRead:()=>void,analogWrite:()=>void,pwmWrite:()=>void,servoConfig:()=>void,servoWrite:()=>void,pinMode:(pin:number,mode:number)=>void,digitalWrite:(pin:number,val:number)=>void,digitalRead:(pin:number,callback:(val:number)=>void)=>void,queryCapabilities:()=>void,// TODO give these better definitionsqueryAnalogMapping:()=>void,queryPinState:()=>void,sendString:()=>void,sendI2CConfig:()=>void,i2cConfig:()=>void,sendI2CWriteRequest:()=>void,i2cWrite:()=>void,i2cWriteReg:()=>void,sendI2CReadRequest:()=>void,i2cRead:()=>void,i2cStop:()=>void,i2cReadOnce:()=>void,sendOneWireConfig:()=>void,sendOneWireSearch:()=>void,sendOneWireAlarmsSearch:()=>void,_sendOneWireSearch:()=>void,sendOneWireRead:()=>void,sendOneWireReset:()=>void,sendOneWireWrite:()=>void,sendOneWireDelay:()=>void,sendOneWireWriteAndRead:()=>void,_sendOneWireRequest:()=>void,setSamplingInterval:(interval:number)=>void,getSamplingInterval:()=>void,reportAnalogPin:()=>void,reportDigitalPin:(pin:number,value:number)=>void,pingRead:()=>void,stepperConfig:(deviceNum:number,type:number,stepsPerRev:number,dirOrMotor1Pin:number,stepOrMotor2Pin:number,motor3Pin?:number,motor4Pin?:number)=>void,// TODO define callback function betterstepperStep:(deviceNum:number,direction:number,steps:number,speed:number,accel:number,decel:number,callback:Function)=>void,serialConfig:()=>void,serialWrite:()=>void,serialRead:()=>void,serialStop:()=>void,serialClose:()=>void,serialFlush:()=>void,serialListen:()=>void,sysexResponse:()=>void,sysexCommand:()=>void,reset:()=>void,// ==============// Static Methods (I think)// ==============isAcceptablePort:(port:IPort)=>boolean,requestPort:(callback:(err:any,port:IPort)=>any)=>void,encode:(data:number[])=>number[],decode:(data:number[])=>number[],// TODO define callback function better// TODO these need to be organized betteron:(event:string,callback:Function)=>void,emit:(event:string)=>void,// ======// Custom (added by Joshua's firmata connector)// ======log:(message:any, ... optParams:any[])=>void,error:(message:any, ... optParams:any[])=>void,debug:(message:any, ... optParams:any[])=>void,info:(message:any, ... optParams:any[])=>void,warn:(message:any, ... optParams:any[])=>void,}interfaceIPort{comName:string,}interfaceIOptions{reportVersionTimeout?:number,samplingInterval?:number,serialPort?:{baudRate:number,bufferSize:number,}}
As you can see, there are incomplete functions and I'm probably doing this the worst way possible, so any help is greatly appreciated.
The text was updated successfully, but these errors were encountered:
Thanks. I'm not sure anyone will jump in directly to help you unless they're using it. If you have something that works, perhaps the best approach is to create a repo and add it to the registry and hope someone else finds it useful also to contribute?
Hello! I am interested in finding a definition file for firmata.js (or in helping to generate one). The way I'm giving myself typescript support for firmata.js right now is INCREDIBLY HACKY. In fact, I know its the wrong way and I know all it is doing is keeping the compiler from complaining and helping provide me with some auto-completion. So I would really like some help in figuring out the right way to do this. Eventually I'd like to include a typings file in DefinitelyTyped so I can use
$ typings search firmata
and$ typings install --save --global dt~firmata
.What I have so far I use with
And the file
Firmata.d.ts
has this for its contentsAs you can see, there are incomplete functions and I'm probably doing this the worst way possible, so any help is greatly appreciated.
The text was updated successfully, but these errors were encountered: