Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7k
Added support for HEX leading zero in print#6750
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
if PRINT_LEADINGZERO is in the arg, add a leading zero to a HEX if the value is smaler than 0x10
Tijgerd commentedSep 26, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@clivepengelly,@fake-name,@technikadonis,@cmaglie is this a solution for the problem? |
fake-name commentedSep 26, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I still stand that the current implementation is broken, and the correct option is to have print Really, this seems overcomplicated. Why not just have an alternative to the |
Tijgerd commentedSep 26, 2017
@fake-name , BUT HEX, DEC, etc. are a bunch of predefined values indicating the base of the value (e.g. HEX = 16) adding a strange value for the base, like ACTUAL_HEX, will be a bit odd because it will be something like: 42 which is not a base value. I added a OPTIONAL input value which defaults to PRINT_NOARG when not assigned. With this solution, old scripts can still be used :) |
fake-name commentedSep 26, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
So change that to an enum? Also, gah, what terrible API design. |
Tijgerd commentedSep 26, 2017
That's what my initial plan was BUT there may be some users that did actual write the base number and so.. It won't be backward compatible. I know, it doesnt feel right for the HEX not printing the leading zero but this was once implemented and changing it would make a small group of arduino users unhappy ;) |
fake-name commentedSep 26, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
That's not documented, and the documentation makes no statements aboutwhat In fact the documentationexplicitly states:
So passing anythingbut |
Tijgerd commentedSep 26, 2017
https://www.arduino.cc/en/Serial/Print It's kind of documented... |
fake-name commentedSep 26, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Ah, it's kind of crappily documented onhttps://www.arduino.cc/en/Serial/Println, the contents of which actuallycontradicthttps://www.arduino.cc/en/Serial/Print (which I'm quoting literally above). Siiiiiiiigh, Arduino code in a nutshell. |
Tijgerd commentedSep 26, 2017
True 👍 |
fake-name commentedSep 26, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Anyways, It's horrible, yeah, but not any more so then the implementation it's papering over top of. |
Tijgerd commentedDec 22, 2017
@facchinm any news on this? |
cousteaulecommandant commentedDec 25, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Some ideas/opinions/thoughts:
|
| do { | ||
| //the argument is only valid for HEX values smaler than 0x10 | ||
| if(base !=8 || n>=16) arg =0; |
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.
if(base !=HEX || n>=16) arg = 0;
Tijgerd commentedMay 2, 2018
@retfie , if I remember correctly,HEX is defines as 16 (By default in the original arduino code) |
CLAassistant commentedApr 9, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
for issue #1097
Added the leading zero for the print funcionality
if the argument PRINT_LEADINGZERO is added after the base definition, a leading zero is added to the hex