Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions packages/firmata-io/lib/firmata.js
Original file line number Diff line number Diff line change
Expand Up @@ -934,23 +934,14 @@ class Firmata extends Emitter {

pinMode(pin, mode) {
if (mode === this.MODES.ANALOG) {
// Because pinMode may be called before analogRead(pin, () => {}), but isn't
// necessary to initiate an analog read on an analog pin, we'll assign the
// mode here, but do nothing further. In analogRead(), the call to
// reportAnalogPin(pin, 1) is all that's needed to turn on analog input
// reading.
//
// reportAnalogPin(...) will reconcile the pin number as well, the
// same operation we use here to assign a "mode":
this.pins[this.analogPins[pin]].mode = mode;
} else {
pin = this.analogPins[pin];
}
this.pins[pin].mode = mode;
writeToTransport(this, [
PIN_MODE,
pin,
mode
]);
}
}

/**
Expand Down