From 90227ef8d65052622d09698dc80a27cd67f4bc0a Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Wed, 30 Mar 2022 16:44:04 -0700 Subject: More example stuff --- usr/cxx.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'usr') 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 +#include +#include }; -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); } -- cgit v1.2.1