-
Notifications
You must be signed in to change notification settings - Fork 147
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
Multiple Digital Writes: Feature Proposal #181
Comments
One way to do this would be to add a |
I thought about that, but the 8-pins per port is unique to firmata and I need to create something that will work for all the different IO plugins. writeDigitalPort doesn't make sense on other platforms. That's the reason I wanted to handle the pin to port stuff in firmata.js |
What about an // psuedocoding
let digitalWriteQueue = [];
Board.prototype.enqueueDigitalWrite = function(pin, value) {
if (!digitalWriteQueue.length) {
process.nextTick(processDIgitalWriteQueue);
}
digitalWriteQueue.push([pin, value]);
};
function processDigitalWriteQueue() {
let portsToWrite = [];
digitalWriteQueue.forEach(command => {
let port = command[0] >> 3;
portsToWrite.push(port);
let bit = 1 << (command[0] & 0x07);
this.pins[pin].value = value;
if (value) {
this.ports[port] |= bit;
} else {
this.ports[port] &= ~bit;
}
});
portsToWrite.forEach(port => writeDigitalPort);
});
function digitalWritePort(port) {
writeToTransport(this, [
DIGITAL_MESSAGE | port,
this.ports[port] & 0x7F,
(this.ports[port] >> 7) & 0x7F
]);
} |
I've finally got the new stepper class in J5 far enough along that I was able to test this with a full J5 stack and it doubled the speed that I could move a stepper using standardFirmata. Gonna submit a PR soon. |
On digitalWrites I would like to be able to call writeToTransport once instead of once for each pin.
My plan was to either overload digitalWrite with arrays or create a new method (i.e. digitalWriteMulti).
For example:
I want this because I believe that I can get a reasonable speed on stepper motors with whole or half steps using just standardFirmata.
Perhaps there is already a way to do this?
The text was updated successfully, but these errors were encountered: