aboutsummaryrefslogtreecommitdiff
path: root/src/console/vtxprintf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/console/vtxprintf.c')
-rw-r--r--src/console/vtxprintf.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/console/vtxprintf.c b/src/console/vtxprintf.c
index 28c5a604e0..9de25845bd 100644
--- a/src/console/vtxprintf.c
+++ b/src/console/vtxprintf.c
@@ -69,8 +69,22 @@ static int number(void (*tx_byte)(unsigned char byte),
i = 0;
if (num == 0)
tmp[i++]='0';
- else while (num != 0)
- tmp[i++] = digits[do_div(num,base)];
+ else while (num != 0){
+ /* there are some nice optimizations in the
+ * Macros-From-Hell that form the div64 code
+ * *IF* you call it with a constant.
+ * We're firmware, we only do bases
+ * 8, 10, and 16. Let's be smart.
+ * This greatly helps ARM, reduces the
+ * code footprint at compile time, and does not hurt x86.
+ */
+ if (base == 10)
+ tmp[i++] = digits[do_div(num,10)];
+ else if (base == 8)
+ tmp[i++] = digits[do_div(num,8)];
+ else /* sorry, you're out of choices */
+ tmp[i++] = digits[do_div(num,16)];
+ }
if (i > precision)
precision = i;
size -= precision;