mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[ion] Fix hexNumber().
Change-Id: Ic12e3f17ec5e6508613034c4b259eee2fd103be4
This commit is contained in:
@@ -30,11 +30,12 @@ bool isHex(char c) {
|
||||
return hexChar(c) >= 0;
|
||||
}
|
||||
|
||||
uint32_t hexNumber(const char * s) {
|
||||
uint32_t hexNumber(const char * s, int maxLength) {
|
||||
uint32_t result = 0;
|
||||
int8_t digit = 0;
|
||||
while ((digit = hexChar(*s++)) >= 0) {
|
||||
result = (result << 4) | digit;
|
||||
int index = 0;
|
||||
while ((maxLength < 0 || index < maxLength) && s[index] != NULL) {
|
||||
result = (result << 4) | hexChar(s[index]);
|
||||
index++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ extern const char * const sOFF;
|
||||
void reply(const char * s);
|
||||
int8_t hexChar(char c);
|
||||
bool isHex(char c);
|
||||
uint32_t hexNumber(const char * s);
|
||||
uint32_t hexNumber(const char * s, int maxLength = -1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ void Print(const char * input) {
|
||||
return;
|
||||
}
|
||||
|
||||
char x = hexNumber(input);
|
||||
char y = hexNumber(input+3);
|
||||
char x = hexNumber(input, 2);
|
||||
char y = hexNumber(input+3, 2);
|
||||
|
||||
KDContext * ctx = KDIonContext::sharedContext();
|
||||
ctx->drawString(input+6, KDPoint(x, y));
|
||||
|
||||
Reference in New Issue
Block a user