-
-
Notifications
You must be signed in to change notification settings - Fork 442
Add begin() function to class example as best practice #849
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
Conversation
The guide instructs the user to place a hardware configuration call, pinMode(), in the class constructor. The problem is that the constructor will execute this in globals scope before Arduino core's main() has time to call the init() function to initialize the hardware. In many cases, this will be fine, but there are cases where the hardware is not ready until after init() is called. To address this, the Morse library class example should include a `begin()` function similar to `Serial.begin()` that is placed in `setup()`. This will encourage students of this guide to follow that best practice. Note, the Morse.zip file will need to be updated. I have an updated version here: https://github.com/jasonacox/Morse and will zip and submit that for a replacement if this PR is acceptable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this important correction @jasonacox!
I have offered a few suggestions.
...t/learn/08.contributions/03.arduino-creating-library-guide/arduino-creating-library-guide.md
Outdated
Show resolved
Hide resolved
...t/learn/08.contributions/03.arduino-creating-library-guide/arduino-creating-library-guide.md
Outdated
Show resolved
Hide resolved
...t/learn/08.contributions/03.arduino-creating-library-guide/arduino-creating-library-guide.md
Outdated
Show resolved
Hide resolved
Co-authored-by: per1234 <accounts@perglass.com>
Co-authored-by: per1234 <accounts@perglass.com>
Co-authored-by: per1234 <accounts@perglass.com>
Change configure to configures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great (and thanks for fixing the grammar error I introduced in my suggestion 🤦♂️)!
Thank you @per1234 ! I hope this helps provide more clarity for the community. Morse.zipNow we need to submit a new Morse.zip file with the adjustments to the code. The link in the document is https://www.arduino.cc/en/uploads/Hacking/Morse.zip in the tutorial, but I'm not sure how to update that. I captured the example code here: https://github.com/jasonacox/Morse and there is a zip file release we could use but I would like a peer review on that as well. |
I will be happy to provide one. Are you planning to maintain https://github.com/jasonacox/Morse permanently, or did you only create it as a temporary staging repository to accompany this PR? Either is fine of course. I ask only because I have a few suggestions that are specific to the content of the tutorial ZIP file, but not necessarily applicable to your repository. If the repo is only for this PR then I would submit a PR to your repo for my suggestions. Otherwise I would describe them here in this PR thread. |
Thanks! This repo is for only for this tutorial, so please feel free to open a PR. Also, I have no issue leaving the repo up for others to reference. My thought is that it should be a helpful "reference template" we anonymize (I just realize I had my properties file in there with my contact info we should anonymize). Also, we may want it hosted in github.com/arduino somewhere or just leave it as a zip archive. |
I have now submitted PRs to your repo for my two minor suggestions: |
Thank you, @per1234 ! 🙏 - Both of your changes make sense to me. I accepted and merged. I released 1.0.0 using the updated files: https://github.com/jasonacox/Morse/releases/tag/v1.0.0 with a zip file that could be use as the replacement for https://www.arduino.cc/en/uploads/Hacking/Morse.zip Please let me know if I can do anything else to help. |
Hi @per1234 is there anything else I can do to help complete this merge? |
@jasonacox not that I know of. I'm not in a role to merge PRs in this repository so one of the primary maintainers will need to find time to do a review. They will let you know if any action is needed on your part. |
Understood! Thanks @per1234! 🙏 Maintainer: We do need to update the Morse.zip file at https://www.arduino.cc/en/uploads/Hacking/Morse.zip - I'm not sure how to do that. Ideally it should happen at the same time this is merged so the document matches the zip file. The updated files are stored here https://github.com/jasonacox/Morse/releases/tag/v1.0.0 with help from @per1234, if we want to use that. Let me know if you need anything else. |
Hi friends - If it helps with the review and merge, I have attached the updated Morse.zip of the code that needs to replace https://www.arduino.cc/en/uploads/Hacking/Morse.zip as part of this merge request. Updated zip file here: Morse.zip This is the example code described in the tutorial that includes the files needed to build an Arduino library: Alternatively, I could submit an update to this PR to change the link in the tutorial text to point to the above github hosted link (https://github.com/arduino/docs-content/files/11130152/Morse.zip. However, I assumed we would want to keep the example code host under the arduino.cc URL. Thoughts? Please let me know if you have any questions or you need anything else to help review/accept this PR. Thank you! |
@jasonacox thank you for your contribution! We will now merge your updates to this tutorial ⭐ |
Thank you @jhansson-ard !!! I notice the updated "Writing a Library for Arduino" Tutorial is live. 🚀 ❤️ 👏 However, I did notice the link on the page for Morse.zip (see below) still downloads the old zip file. Can the zip file at https://github.com/arduino/docs-content/files/11130152/Morse.zip be uploaded to https://www.arduino.cc/en/uploads/Hacking/Morse.zip? |
Updated the link to the morse zip file in the Library tutorial. See more [here](#849)
Yes of course, I've made a PR here: #1012 ⭐ |
What This PR Changes
begin()
function similar toSerial.begin()
that is placed insetup()
. This will encourage students of this guide to follow that best practice.Contribution Guidelines