aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Code_Composer/twine_graphicslib
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2017-11-16 18:52:12 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2017-11-16 18:52:12 +0200
commit0bb5f7db4d171d4c0567ac3dcd6aadd79d034c5e (patch)
tree2cbfe65e3b5cbcb8b4a5ab48bc44448903d130d9 /Software/Code_Composer/twine_graphicslib
parentfc703faaa6326e28e146e00615db01c48ded0ece (diff)
downloadTango-0bb5f7db4d171d4c0567ac3dcd6aadd79d034c5e.tar.gz
Tango-0bb5f7db4d171d4c0567ac3dcd6aadd79d034c5e.zip
Implemented on twine CCS graphics:
writeLine. writeString. writeFloat. clear.
Diffstat (limited to 'Software/Code_Composer/twine_graphicslib')
-rw-r--r--Software/Code_Composer/twine_graphicslib/graphics_adapter.c45
-rw-r--r--Software/Code_Composer/twine_graphicslib/graphics_adapter.h6
2 files changed, 48 insertions, 3 deletions
diff --git a/Software/Code_Composer/twine_graphicslib/graphics_adapter.c b/Software/Code_Composer/twine_graphicslib/graphics_adapter.c
index 93eb6fa17..5d165599f 100644
--- a/Software/Code_Composer/twine_graphicslib/graphics_adapter.c
+++ b/Software/Code_Composer/twine_graphicslib/graphics_adapter.c
@@ -8,11 +8,15 @@
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
+#include <string.h>
#include "graphics_adapter.h"
#include "grlib/grlib.h"
#include "drivers/frame.h"
#include "drivers/kentec320x240x16_ssd2119.h"
+#define LINE_HEIGHT 25
+int current_position = 0;
+char current_line[100];
void init_graphics(uint32_t ui32SysClock)
{
@@ -39,7 +43,44 @@ void draw_string(char* data, size_t length)
GrContextForegroundSet(&g_sContext, ClrBlack);
GrRectFill(&g_sContext, &backRect);
- GrContextFontSet(&g_sContext, TEXT_FONT);
- GrContextForegroundSet(&g_sContext, ClrWhite);
+
GrStringDraw(&g_sContext, data, length, 0, 0, true);
}
+
+void writeLine(char* text)
+{
+ strcpy(current_line, text);
+ GrStringDraw(&g_sContext, current_line, strlen(current_line), 0, current_position, true);
+ current_position += LINE_HEIGHT;
+}
+
+void writeFloat(float num)
+{
+ char num_buf[10];
+ ltoa(num, num_buf);
+ strcat(current_line, num_buf);
+ GrStringDraw(&g_sContext, current_line, strlen(current_line), 0, current_position - LINE_HEIGHT, true);
+}
+
+void writeString(char* text)
+{
+ strcat(current_line,text);
+ GrStringDraw(&g_sContext, current_line, strlen(current_line), 0, current_position - LINE_HEIGHT, true);
+}
+
+void clear()
+{
+ tRectangle backRect;
+ backRect.i16XMin = 0;
+ backRect.i16XMax = 340;
+ backRect.i16YMin = 240;
+ backRect.i16YMax = 0;
+
+ GrContextForegroundSet(&g_sContext, ClrBlack);
+ GrRectFill(&g_sContext, &backRect);
+
+ GrContextFontSet(&g_sContext, TEXT_FONT);
+ GrContextForegroundSet(&g_sContext, ClrWhite);
+
+ current_position = 0;
+}
diff --git a/Software/Code_Composer/twine_graphicslib/graphics_adapter.h b/Software/Code_Composer/twine_graphicslib/graphics_adapter.h
index c4e651a89..405b88166 100644
--- a/Software/Code_Composer/twine_graphicslib/graphics_adapter.h
+++ b/Software/Code_Composer/twine_graphicslib/graphics_adapter.h
@@ -18,7 +18,7 @@
//
//*****************************************************************************
static tContext g_sContext;
-#define TEXT_FONT g_psFontCmss22b
+#define TEXT_FONT g_psFontCmss18b
#define TEXT_HEIGHT (GrFontHeightGet(TEXT_FONT))
#define BUFFER_METER_HEIGHT TEXT_HEIGHT
#define BUFFER_METER_WIDTH 150
@@ -26,3 +26,7 @@ static tContext g_sContext;
void init_graphics(uint32_t ui32SysClock);
void draw_image(uint8_t* data);
void draw_string(char* data, size_t length);
+void writeLine(char* text);
+void writeFloat(float num);
+void writeString(char* text);
+void clear();