diff --git a/Makefile b/Makefile index acc023319..096f76626 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ CXXFLAGS = -std=c++11 -fno-exceptions -fno-unwind-tables -fno-rtti -nostdlib products := boot.elf boot.hex boot.bin objs += external/freertos/tasks.o external/freertos/list.o external/freertos/queue.o external/freertos/portable/GCC/ARM_CM4F/port.o external/freertos/portable/MemMang/heap_1.o -objs += external/newlib/libc/string/memset.o external/newlib/libc/string/memcpy.o +objs += $(addprefix external/newlib/libc/, string/memset.o string/memcpy.o string/strlen.o) objs += lib/assert.o diff --git a/external/NEWLIB.txt b/external/NEWLIB.txt index b84900a08..cfe83cffd 100644 --- a/external/NEWLIB.txt +++ b/external/NEWLIB.txt @@ -1,3 +1,4 @@ - Using memcpy and memset - using , , and - using for "bool" +- using strlen from diff --git a/kandinsky/include/kandinsky/rect.h b/kandinsky/include/kandinsky/rect.h index 91be83501..9c6ed5d09 100644 --- a/kandinsky/include/kandinsky/rect.h +++ b/kandinsky/include/kandinsky/rect.h @@ -17,7 +17,7 @@ typedef struct { KDCoordinate width; KDCoordinate height; }; - KDPoint size; + KDSize size; }; } KDRect; diff --git a/kandinsky/include/kandinsky/text.h b/kandinsky/include/kandinsky/text.h index 78292601d..4077d0637 100644 --- a/kandinsky/include/kandinsky/text.h +++ b/kandinsky/include/kandinsky/text.h @@ -5,5 +5,6 @@ void KDDrawChar(char character, KDPoint p); void KDDrawString(char * text, KDPoint p); +KDSize KDStringSize(char * text); #endif diff --git a/kandinsky/src/line.c b/kandinsky/src/line.c index 32a721197..6312a7a61 100644 --- a/kandinsky/src/line.c +++ b/kandinsky/src/line.c @@ -3,6 +3,6 @@ void KDDrawLine(KDPoint p1, KDPoint p2) { for (KDCoordinate x = p1.x; x #include +#include #include "font.h" void KDDrawChar(char character, KDPoint p) { for (int j=0; j +#include Number::Number(int v) : m_value(v) { + for (int i=0; i<16; i++) { + m_stringValue[i] = 0; + } + + int value = v; + for (int i=0; i<15; i++) { + int digit = value - 10*(value/10); + m_stringValue[i] = '0' + digit; + value = value/10; + if (value == 0) { + break; + } + } } void Number::layout() { - m_frame.width = 20; - m_frame.height = 10; + m_frame.size = KDStringSize(m_stringValue); } void Number::draw() { - KDFillRect(m_frame, 0x7F); + KDDrawString(m_stringValue, m_frame.origin); } diff --git a/src/hello.cpp b/src/hello.cpp new file mode 100644 index 000000000..de1ffc538 --- /dev/null +++ b/src/hello.cpp @@ -0,0 +1,32 @@ +extern "C" { +#include "hello.h" +#include +} + +#include + +void hello() { + KDFillRect((KDRect){ + .x = 0, + .y = 0, + .width = 240, + .height = 320}, + 0x00); + /* + for (int i=0; i <255; i++) { + KDFillRect((KDRect){.x = (KDCoordinate)i, .y = (KDCoordinate)i, .width = 100, .height = 200}, i); + } + KDDrawString("Hello, world", (KDPoint){}); + */ + + Number n1 = Number(123); + Number n2 = Number(45); + + Fraction f = Fraction(&n1, &n2); + + f.layout(); + f.m_frame.origin = (KDPoint){.x = 0, .y = 0}; + f.draw();//(KDPoint){.x = 10, .y = 10}); + + +} diff --git a/src/hello.h b/src/hello.h new file mode 100644 index 000000000..9bb085a0d --- /dev/null +++ b/src/hello.h @@ -0,0 +1 @@ +void hello();