aboutsummaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2022-03-24 09:38:08 -0700
committerChristian Cunningham <cc@localhost>2022-03-24 09:38:08 -0700
commit93bf62580a68533dc8252b9a2a055c02f34ecb67 (patch)
tree1b1ca92ebbe107a998136a1442c0dba5be885e13 /usr
parent3e64dda5d5c350cc325650133f7e64967f1efe84 (diff)
Modularized
Diffstat (limited to 'usr')
-rw-r--r--usr/main.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/usr/main.c b/usr/main.c
new file mode 100644
index 0000000..7091580
--- /dev/null
+++ b/usr/main.c
@@ -0,0 +1,32 @@
+#include <graphics/lfb.h>
+#include <symbols.h>
+
+char* ulong_to_string(unsigned long value, char* data)
+{
+ unsigned long t = value;
+ unsigned long c;
+ char* dptr = data + 9;
+ for (int i = 0; i <= 10; i++) {
+ c = t%10;
+ *dptr = 0x30 + (c&0xF);
+ t /= 10;
+ if (t==0)
+ break;
+ dptr -= 1;
+ }
+ return dptr;
+}
+
+void main(void)
+{
+ static char str[13];
+ static unsigned long previous = 0;
+ char* start;
+ unsigned long current = *(volatile unsigned long*)SYS_TIMER_CHI;
+ start = ulong_to_string(current, str);
+ draw_string(0, 10, start);
+ start = ulong_to_string(current - previous, str);
+ draw_string(0, 11, " ");
+ draw_string(0, 11, start);
+ previous = current;
+}