-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
mprintf: reduce include overhead\nproper declare symbols with C linka… #791
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,13 @@ char* ltoa(long val, char* buffer, int base) | |
|
||
char* ltoa_w(long val, char* buffer, int base, int width) | ||
{ | ||
int i = 34, p = 0; | ||
char buf[36] = {0}; | ||
return ltoa_wp(val, buffer, base, width, ' '); | ||
} | ||
|
||
char* ltoa_wp(long val, char* buffer, int base, int width, char pad) | ||
{ | ||
int i = 38, p = 0; | ||
char buf[40] = {0}; | ||
bool ngt = val < 0; | ||
if (ngt) val = -val; | ||
|
||
|
@@ -29,8 +34,9 @@ char* ltoa_w(long val, char* buffer, int base, int width) | |
width -= strlen(&buf[i+1]); | ||
if(width > 0) | ||
{ | ||
memset(buffer, ' ', width); | ||
memset(buffer, pad, width); | ||
} | ||
else width = 0; | ||
} | ||
|
||
strcpy(buffer + width, &buf[i+1]); | ||
|
@@ -50,8 +56,8 @@ char* ultoa_w(unsigned long val, char* buffer, unsigned int base, int width) | |
} | ||
char* ultoa_wp(unsigned long val, char* buffer, unsigned int base, int width, char pad) | ||
{ | ||
int i = 34, p = 0; | ||
char buf[36] = {0}; | ||
int i = 38, p = 0; | ||
char buf[40] = {0}; | ||
|
||
for(; val && i ; --i, p++, val /= base) | ||
buf[i] = "0123456789abcdef"[val % base]; | ||
|
@@ -64,17 +70,22 @@ char* ultoa_wp(unsigned long val, char* buffer, unsigned int base, int width, ch | |
{ | ||
memset(buffer, pad, width); | ||
} | ||
else width = 0; | ||
} | ||
strcpy(buffer + width, &buf[i+1]); | ||
|
||
return buffer; | ||
} | ||
|
||
char *dtostrf(double floatVar, int minStringWidthIncDecimalPoint, int numDigitsAfterDecimal, char *outputBuffer) | ||
{ | ||
return dtostrf_p(floatVar, minStringWidthIncDecimalPoint, numDigitsAfterDecimal, outputBuffer, ' '); | ||
} | ||
// Author zitron: http://forum.arduino.cc/index.php?topic=37391#msg276209 | ||
// modified by ADiea: remove dependencies strcat, floor, round; reorganize+speedup code | ||
char *dtostrf(double floatVar, int minStringWidthIncDecimalPoint, int numDigitsAfterDecimal, char *outputBuffer) | ||
extern char *dtostrf_p(double floatVar, int minStringWidthIncDecimalPoint, int numDigitsAfterDecimal, char *outputBuffer, char pad) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ADiea why you have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm agree should be removed, no idea what was on my mind |
||
{ | ||
char temp[24], num[24]; | ||
char temp[40], num[40]; | ||
unsigned long mult = 1, int_part; | ||
int16_t i, processedFracLen = numDigitsAfterDecimal; | ||
|
||
|
@@ -174,7 +185,7 @@ char *dtostrf(double floatVar, int minStringWidthIncDecimalPoint, int numDigitsA | |
i = minStringWidthIncDecimalPoint - strlen(num) + 1; | ||
while (--i > 0) | ||
{ | ||
*buf++ = ' '; | ||
*buf++ = pad; | ||
} | ||
|
||
//Write output buffer | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@ADiea If you want to use only osapi.h then please remove the commented include above.
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.
ok, good to see activity on sming again!