Skip to content

Commit 3bc605b

Browse files
committed
declare FirmataSerial as 'Stream *' instead of 'Stream &'
1 parent 79168e6 commit 3bc605b

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

Firmata.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,25 @@ extern "C" {
2828

2929
void FirmataClass::sendValueAsTwo7bitBytes(int value)
3030
{
31-
FirmataSerial.write(value & B01111111); // LSB
32-
FirmataSerial.write(value >> 7 & B01111111); // MSB
31+
FirmataSerial->write(value & B01111111); // LSB
32+
FirmataSerial->write(value >> 7 & B01111111); // MSB
3333
}
3434

3535
void FirmataClass::startSysex(void)
3636
{
37-
FirmataSerial.write(START_SYSEX);
37+
FirmataSerial->write(START_SYSEX);
3838
}
3939

4040
void FirmataClass::endSysex(void)
4141
{
42-
FirmataSerial.write(END_SYSEX);
42+
FirmataSerial->write(END_SYSEX);
4343
}
4444

4545
//******************************************************************************
4646
//* Constructors
4747
//******************************************************************************
4848

49-
FirmataClass::FirmataClass(Stream &s) : FirmataSerial(s)
49+
FirmataClass::FirmataClass()
5050
{
5151
firmwareVersionCount = 0;
5252
systemReset();
@@ -66,25 +66,25 @@ void FirmataClass::begin(void)
6666
void FirmataClass::begin(long speed)
6767
{
6868
Serial.begin(speed);
69-
FirmataSerial = Serial;
69+
FirmataSerial = &Serial;
7070
blinkVersion();
7171
printVersion();
7272
printFirmwareVersion();
7373
}
7474

7575
void FirmataClass::begin(Stream &s)
7676
{
77-
FirmataSerial = s;
77+
FirmataSerial = &s;
7878
systemReset();
7979
printVersion();
8080
printFirmwareVersion();
8181
}
8282

8383
// output the protocol version message to the serial port
8484
void FirmataClass::printVersion(void) {
85-
FirmataSerial.write(REPORT_VERSION);
86-
FirmataSerial.write(FIRMATA_MAJOR_VERSION);
87-
FirmataSerial.write(FIRMATA_MINOR_VERSION);
85+
FirmataSerial->write(REPORT_VERSION);
86+
FirmataSerial->write(FIRMATA_MAJOR_VERSION);
87+
FirmataSerial->write(FIRMATA_MINOR_VERSION);
8888
}
8989

9090
void FirmataClass::blinkVersion(void)
@@ -103,9 +103,9 @@ void FirmataClass::printFirmwareVersion(void)
103103

104104
if(firmwareVersionCount) { // make sure that the name has been set before reporting
105105
startSysex();
106-
FirmataSerial.write(REPORT_FIRMWARE);
107-
FirmataSerial.write(firmwareVersionVector[0]); // major version number
108-
FirmataSerial.write(firmwareVersionVector[1]); // minor version number
106+
FirmataSerial->write(REPORT_FIRMWARE);
107+
FirmataSerial->write(firmwareVersionVector[0]); // major version number
108+
FirmataSerial->write(firmwareVersionVector[1]); // minor version number
109109
for(i=2; i<firmwareVersionCount; ++i) {
110110
sendValueAsTwo7bitBytes(firmwareVersionVector[i]);
111111
}
@@ -146,7 +146,7 @@ void FirmataClass::setFirmwareNameAndVersion(const char *name, byte major, byte
146146

147147
int FirmataClass::available(void)
148148
{
149-
return FirmataSerial.available();
149+
return FirmataSerial->available();
150150
}
151151

152152

@@ -180,7 +180,7 @@ void FirmataClass::processSysexMessage(void)
180180

181181
void FirmataClass::processInput(void)
182182
{
183-
int inputData = FirmataSerial.read(); // this is 'int' to handle -1 when no data
183+
int inputData = FirmataSerial->read(); // this is 'int' to handle -1 when no data
184184
int command;
185185

186186
// TODO make sure it handles -1 properly
@@ -272,7 +272,7 @@ void FirmataClass::processInput(void)
272272
void FirmataClass::sendAnalog(byte pin, int value)
273273
{
274274
// pin can only be 0-15, so chop higher bits
275-
FirmataSerial.write(ANALOG_MESSAGE | (pin & 0xF));
275+
FirmataSerial->write(ANALOG_MESSAGE | (pin & 0xF));
276276
sendValueAsTwo7bitBytes(value);
277277
}
278278

@@ -303,17 +303,17 @@ void FirmataClass::sendDigital(byte pin, int value)
303303
// send an 8-bit port in a single digital message (protocol v2)
304304
void FirmataClass::sendDigitalPort(byte portNumber, int portData)
305305
{
306-
FirmataSerial.write(DIGITAL_MESSAGE | (portNumber & 0xF));
307-
FirmataSerial.write((byte)portData % 128); // Tx bits 0-6
308-
FirmataSerial.write(portData >> 7); // Tx bits 7-13
306+
FirmataSerial->write(DIGITAL_MESSAGE | (portNumber & 0xF));
307+
FirmataSerial->write((byte)portData % 128); // Tx bits 0-6
308+
FirmataSerial->write(portData >> 7); // Tx bits 7-13
309309
}
310310

311311

312312
void FirmataClass::sendSysex(byte command, byte bytec, byte* bytev)
313313
{
314314
byte i;
315315
startSysex();
316-
FirmataSerial.write(command);
316+
FirmataSerial->write(command);
317317
for(i=0; i<bytec; i++) {
318318
sendValueAsTwo7bitBytes(bytev[i]);
319319
}
@@ -335,7 +335,7 @@ void FirmataClass::sendString(const char* string)
335335
// expose the write method
336336
void FirmataClass::write(byte c)
337337
{
338-
FirmataSerial.write(c);
338+
FirmataSerial->write(c);
339339
}
340340

341341

Firmata.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ extern "C" {
8787
class FirmataClass
8888
{
8989
public:
90-
FirmataClass(Stream &s);
90+
FirmataClass();
9191
/* Arduino constructors */
9292
void begin();
9393
void begin(long);

0 commit comments

Comments
 (0)