Skip to content

Commit

Permalink
Merge pull request #168 from pgrawehr/UnoR4Fix
Browse files Browse the repository at this point in the history
Fix build for UnoR4 Wifi/Minima
  • Loading branch information
pgrawehr authored Oct 6, 2024
2 parents b5fe2c6 + 4e5e946 commit 0134a9c
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 83 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
arduino-cli core update-index
arduino-cli core install arduino:avr
arduino-cli core install arduino:sam
arduino-cli core install arduino:renesas_uno
- run: |
arduino-cli core install esp32:esp32
Expand All @@ -47,4 +48,6 @@ jobs:

- run: arduino-cli compile --fqbn arduino:sam:arduino_due_x_dbg ./examples/ConfigurableFirmata --warnings more

- run: arduino-cli compile --fqbn arduino:renesas_uno:unor4wifi ./examples/ConfigurableFirmata --warnings more

- run: arduino-cli compile --fqbn esp32:esp32:esp32:PSRAM=disabled,PartitionScheme=default,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none ./examples/ConfigurableFirmata --warnings more
5 changes: 1 addition & 4 deletions examples/ConfigurableFirmata/ConfigurableFirmata.ino
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,13 @@ 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);
}
else if (IS_PIN_DIGITAL(i))
{
Firmata.setPinMode (i, PIN_MODE_OUTPUT);
// Uncomment following 2 lines, if you want to start the board at HIGH output state on powering up:
// Firmata.digitalWrite(i, HIGH);
// Firmata.setPinState (i, HIGH);
}
}
#endif
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
4 changes: 2 additions & 2 deletions src/ConfigurableFirmata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ extern "C" {
*/
void FirmataClass::sendValueAsTwo7bitBytes(int value)
{
FirmataStream->write(value & B01111111); // LSB
FirmataStream->write(value >> 7 & B01111111); // MSB
FirmataStream->write(value & 0B01111111); // LSB
FirmataStream->write(value >> 7 & 0B01111111); // MSB
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/FirmataExt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void handleSetPinModeCallback(byte pin, int mode)
void handleSysexCallback(byte command, byte argc, byte* argv)
{
if (!FirmataExtInstance->handleSysex(command, argc, argv)) {
Firmata.sendString(F("Unhandled sysex command"));
Firmata.sendStringf(F("Unhandled sysex command: 0x%x (len: %d)"), (int)command, (int)argc);
}
}

Expand Down
Loading

0 comments on commit 0134a9c

Please sign in to comment.