Skip to content

Commit

Permalink
Rename IS_PIN_ANALOG and IS_PIN_PWM to avoid conflicts
Browse files Browse the repository at this point in the history
The UnoR4 toolchain has its own, conflicting definition of these
macros, so use an unique name
  • Loading branch information
pgrawehr committed Sep 15, 2024
1 parent 1ef7af7 commit b858ba5
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 72 deletions.
2 changes: 1 addition & 1 deletion examples/ConfigurableFirmata/ConfigurableFirmata.ino
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void systemResetCallback()
#ifndef ESP32
for (byte i = 0; i < TOTAL_PINS; i++)
{
if (IS_PIN_ANALOG(i))
if (FIRMATA_IS_PIN_ANALOG(i))
{
Firmata.setPinMode(i, PIN_MODE_ANALOG);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/ConfigurableFirmataBLE/ConfigurableFirmataBLE.ino
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void systemResetCallback()
// pins with analog capability default to analog input
// otherwise, pins default to digital output
for (byte i = 0; i < TOTAL_PINS; i++) {
if (IS_PIN_ANALOG(i)) {
if (FIRMATA_IS_PIN_ANALOG(i)) {
#ifdef AnalogInputFirmata_h
// turns off pull-up, configures everything
Firmata.setPinMode(i, PIN_MODE_ANALOG);
Expand Down
8 changes: 4 additions & 4 deletions src/AnalogInputFirmata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void AnalogInputFirmata::reportAnalog(byte analogPin, bool enable, byte physical

boolean AnalogInputFirmata::handlePinMode(byte pin, int mode)
{
if (IS_PIN_ANALOG(pin)) {
if (FIRMATA_IS_PIN_ANALOG(pin)) {
if (mode == PIN_MODE_ANALOG) {
reportAnalog(PIN_TO_ANALOG(pin), true, pin); // turn on reporting
if (IS_PIN_DIGITAL(pin)) {
Expand All @@ -91,7 +91,7 @@ boolean AnalogInputFirmata::handlePinMode(byte pin, int mode)

void AnalogInputFirmata::handleCapability(byte pin)
{
if (IS_PIN_ANALOG(pin)) {
if (FIRMATA_IS_PIN_ANALOG(pin)) {
Firmata.write(PIN_MODE_ANALOG);
Firmata.write(DEFAULT_ADC_RESOLUTION); // Defaults to 10-bit resolution
}
Expand All @@ -103,7 +103,7 @@ boolean AnalogInputFirmata::handleSysex(byte command, byte argc, byte* argv)
Firmata.write(START_SYSEX);
Firmata.write(ANALOG_MAPPING_RESPONSE);
for (byte pin = 0; pin < TOTAL_PINS; pin++) {
Firmata.write(IS_PIN_ANALOG(pin) ? PIN_TO_ANALOG(pin) : 127);
Firmata.write(FIRMATA_IS_PIN_ANALOG(pin) ? PIN_TO_ANALOG(pin) : 127);
}
Firmata.write(END_SYSEX);
return true;
Expand Down Expand Up @@ -133,7 +133,7 @@ void AnalogInputFirmata::report(bool elapsed)
byte pin, analogPin;
/* ANALOGREAD - do all analogReads() at the configured sampling interval */
for (pin = 0; pin < TOTAL_PINS; pin++) {
if (IS_PIN_ANALOG(pin) && Firmata.getPinMode(pin) == PIN_MODE_ANALOG) {
if (FIRMATA_IS_PIN_ANALOG(pin) && Firmata.getPinMode(pin) == PIN_MODE_ANALOG) {
analogPin = PIN_TO_ANALOG(pin);
if (analogInputsToReport & (1 << analogPin)) {
Firmata.sendAnalog(analogPin, analogRead(pin));
Expand Down
4 changes: 2 additions & 2 deletions src/AnalogOutputFirmata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void AnalogOutputFirmata::setupPwmPin(byte pin)

boolean AnalogOutputFirmata::handlePinMode(byte pin, int mode)
{
if (mode == PIN_MODE_PWM && IS_PIN_PWM(pin)) {
if (mode == PIN_MODE_PWM && FIRMATA_IS_PIN_PWM(pin)) {
setupPwmPin(pin);
return true;
}
Expand All @@ -47,7 +47,7 @@ boolean AnalogOutputFirmata::handlePinMode(byte pin, int mode)

void AnalogOutputFirmata::handleCapability(byte pin)
{
if (IS_PIN_PWM(pin)) {
if (FIRMATA_IS_PIN_PWM(pin)) {
Firmata.write(PIN_MODE_PWM);
Firmata.write(DEFAULT_PWM_RESOLUTION);
}
Expand Down
4 changes: 2 additions & 2 deletions src/AnalogOutputFirmataEsp32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void AnalogOutputFirmata::internalReset()

boolean AnalogOutputFirmata::handlePinMode(byte pin, int mode)
{
if (mode == PIN_MODE_PWM && IS_PIN_PWM(pin)) {
if (mode == PIN_MODE_PWM && FIRMATA_IS_PIN_PWM(pin)) {
setupPwmPin(pin);
return true;
}
Expand All @@ -79,7 +79,7 @@ boolean AnalogOutputFirmata::handlePinMode(byte pin, int mode)

void AnalogOutputFirmata::handleCapability(byte pin)
{
if (IS_PIN_PWM(pin)) {
if (FIRMATA_IS_PIN_PWM(pin)) {
Firmata.write(PIN_MODE_PWM);
Firmata.write(DEFAULT_PWM_RESOLUTION);
}
Expand Down
Loading

0 comments on commit b858ba5

Please sign in to comment.