Skip to content

Commit 7993c35

Browse files
author
pjs
committed
Add extended analog write
1 parent 6796524 commit 7993c35

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Firmata/Firmata.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@
4747
#define SHIFT_DATA 0x75 // a bitstream to/from a shift register
4848
#define I2C_REQUEST 0x76 // send an I2C read/write request
4949
#define I2C_REPLY 0x77 // a reply to an I2C read request
50-
#define I2C_CONFIG 0x78 // config I2C settings such as delay times and power pins
50+
#define I2C_CONFIG 0x78 // config I2C settings such as delay times and power pins
51+
#define EXT_ANALOG_WRITE 0x6F // analog write (PWM, Servo, etc) to any pin
52+
#define PIN_MODE_QUERY 0x72 // ask for current and supported pin modes
53+
#define PIN_MODE_RESPONSE 0x73 // reply with current and supported pin modes
5154
#define REPORT_FIRMWARE 0x79 // report name and version of the firmware
5255
#define SAMPLING_INTERVAL 0x7A // set the poll rate of the main loop
5356
#define SYSEX_NON_REALTIME 0x7E // MIDI Reserved for non-realtime messages

Firmata/examples/StandardFirmata/StandardFirmata.pde

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,14 @@ void sysexCallback(byte command, byte argc, byte *argv)
247247
else
248248
Firmata.sendString("Not enough data");
249249
break;
250+
case EXT_ANALOG_WRITE:
251+
if (argc > 1) {
252+
int val = argv[1];
253+
if (argc > 2) val |= (argv[2] << 7);
254+
if (argc > 3) val |= (argv[3] << 14);
255+
analogWriteCallback(argv[0], val);
256+
}
257+
break;
250258
}
251259
}
252260

0 commit comments

Comments
 (0)