Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate pin map dependency #68

Open
soundanalogous opened this issue Sep 8, 2014 · 1 comment
Open

Eliminate pin map dependency #68

soundanalogous opened this issue Sep 8, 2014 · 1 comment
Milestone

Comments

@soundanalogous
Copy link
Owner

In order to support host applications (StandardFirmata, AdvancedFirmata and ConfigurableFirmata are a "host applications") that don't use the capability query, each time a pin mode is set by the client, first check if the pin map contains a Pin object for that pin. If not, create an object for that pin and store it in the pin map. This way as long as clients specify pin modes, they should be able to use hosts that do not use capability queries.

May also need to first create a pin map with a range of pins set to a mode of DOUT (default). You wouldn't know what board is used in most cases so the range would have to be 0-64 or 0-128. This would support the case where a user expects the pins to be set to DOUT by default and therefore do not set a pin mode before attempting to use a pin.

@soundanalogous
Copy link
Owner Author

It may actually only require initializing all pins to digital on startup if the host doesn't issue a capability query on startup:

// call from checkForQueryResponse if _capabilityQueryResponseReceived === false
initPins: function () {
    for (var i = 0; i < 128; i++) {
        var pin = new Pin(i, Pin.DOUT);
        this._digitalPinMapping[i] = i;
        this.managePinListener(pin);
        this._ioPins[i] = pin;
    }
}

And then whenever a pin is used, make sure its type is properly set.

@soundanalogous soundanalogous added this to the 0.4.0 milestone Dec 7, 2015
@soundanalogous soundanalogous modified the milestones: 0.5, 0.4 Jan 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant