Skip to content

Relax digitalWrite parameter check #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 14, 2015

Conversation

facchinm
Copy link
Member

calling digitalWrite with any value different from 0 will end in performing digitalWrite(HIGH)
(to make it compatible with existing implementations for other cores)

calling digitalWrite with any value different from 0 will end
in performing digitalWrite(HIGH)
@ArduinoBot
Copy link

✅ Build completed.

⬇️ Build URL: http://downloads.arduino.cc/PR/samd/package_samd-b25_index.json

ℹ️ To test this build:

  1. Open the Preferences of the Arduino IDE.
  2. Add the Build URL above in the Additional Boards Manager URLs field, and click OK.
  3. Open the Boards Manager (menu Tools->Board->Board Manager...)
  4. Install Arduino SAMD core - Pull Request Relax digitalWrite parameter check #26
  5. Select one of the boards under SAMD Pull Request Relax digitalWrite parameter check #26 in Tools->Board menu
  6. Compile/Upload as usual

@matthijskooijman
Copy link
Collaborator

Looks good to me. The only reason this would be bad if we ever want to support a third parameter to digitalWrite (like digitalWrite(HALF) or something unexpected like that), but I think that would break too many sketches out here to work), so no practical downsides to this change.

@aethaniel
Copy link
Contributor

@facchinm, just for fun, this isn't matching the spec from https://www.arduino.cc/en/Reference/DigitalWrite

@matthijskooijman
Copy link
Collaborator

But it does match other implementations and, I think, user expectation. Perhaps this expectation should be solidified by updating the reference, though.

@aethaniel
Copy link
Contributor

Indeed, the reference must be updated as it can be considered as the base spec for any new implementation. Well, it has been for me for the Due and Zero ports.

@cmaglie cmaglie merged commit 9a5422d into arduino:master Aug 14, 2015
@cmaglie
Copy link
Member

cmaglie commented Aug 14, 2015

@aethaniel
to be precise, the new implementation match the specification exactly as the old one: the pin goes high when you pass HIGH and low when you pass LOW.

The specification leaves undefined all the other cases but the majority of implementations sets the pin high (I guess it's a consequence of the fact that in C/C++ 0 is considered false and everything else is true).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants