aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2022-03-30 16:44:04 -0700
committerChristian Cunningham <cc@localhost>2022-03-30 16:44:04 -0700
commit90227ef8d65052622d09698dc80a27cd67f4bc0a (patch)
tree3df4be896d39d10b3bb63d9e068fce4a8ab4a7a7
parent72a403ce29627ad6fb603c366b239ba8c9e5131e (diff)
More example stuff
-rw-r--r--Common.mk2
-rw-r--r--usr/cxx.cpp32
2 files changed, 19 insertions, 15 deletions
diff --git a/Common.mk b/Common.mk
index 5ca4a58..c365ba5 100644
--- a/Common.mk
+++ b/Common.mk
@@ -40,7 +40,7 @@ OBJDUMP = ${CROSS}-objdump
QEMU = qemu-system-arm
GDB = gdb-multiarch
CFLAGS = -mcpu=cortex-a7 -fpic -ffreestanding -std=gnu99 -O3 -Wall -Wextra -nostdlib -Iinclude -g
-CXXFLAGS = -mcpu=cortex-a7 -fpic -ffreestanding -O3 -Wall -Wextra -nostdlib -Iinclude -g
+CXXFLAGS = -mcpu=cortex-a7 -fpic -ffreestanding -fno-exceptions -O3 -Wall -Wextra -nostdlib -Iinclude -g
CFLAGS += -DVERSION="\"0.9z\""
AFLAGS = -mcpu=cortex-a7 -Iinclude -g
QFLAGS = -M raspi2b -cpu cortex-a7 -m 1G
diff --git a/usr/cxx.cpp b/usr/cxx.cpp
index 0c41cca..2240d25 100644
--- a/usr/cxx.cpp
+++ b/usr/cxx.cpp
@@ -1,24 +1,28 @@
extern "C" {
-#include <drivers/uart.h>
+#include <graphics/lfb.h>
+#include <usr/string.h>
};
-class TestClass {
+class Substation {
public:
- unsigned long value;
- TestClass(unsigned long v) {
- value = v;
- }
- void increment() {
- value++;
- }
- void increment(unsigned long v) {
- value += v;
+ unsigned long temperature;
+ unsigned long critical_temperature;
+ unsigned long current_production;
+ unsigned long max_production;
+ unsigned long current_load;
+ Substation(unsigned long ct, unsigned long mp) {
+ temperature = 0;
+ current_production = 0;
+ current_load = 0;
+ critical_temperature = ct;
+ max_production = mp;
}
};
extern "C" void cpp_demo(unsigned long v)
{
- TestClass tc = TestClass(v);
- tc.increment();
- uart_hexn(tc.value);
+ Substation s = Substation(120000+10*v, 95000000 - 23*v);
+ char str[14];
+ char* start = ulong_to_string(s.max_production, str);
+ draw_string(0, 15, start);
}