aboutsummaryrefslogtreecommitdiffstats
path: root/Software
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
parentfc703faaa6326e28e146e00615db01c48ded0ece (diff)
downloadTango-0bb5f7db4d171d4c0567ac3dcd6aadd79d034c5e.tar.gz
Tango-0bb5f7db4d171d4c0567ac3dcd6aadd79d034c5e.zip
Implemented on twine CCS graphics:
writeLine. writeString. writeFloat. clear.
Diffstat (limited to 'Software')
-rw-r--r--Software/Code_Composer/twine_graphicslib/graphics_adapter.c45
-rw-r--r--Software/Code_Composer/twine_graphicslib/graphics_adapter.h6
-rw-r--r--Software/Code_Composer/twine_usblib_demo/main.c20
3 files changed, 57 insertions, 14 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();
diff --git a/Software/Code_Composer/twine_usblib_demo/main.c b/Software/Code_Composer/twine_usblib_demo/main.c
index 3b9da30da..84cbf46b7 100644
--- a/Software/Code_Composer/twine_usblib_demo/main.c
+++ b/Software/Code_Composer/twine_usblib_demo/main.c
@@ -77,6 +77,8 @@ void receive_callback(char* buffer, size_t length)
//draw_string(buffer, length);
//draw_image((uint8_t *)buffer);
+ clear();
+
MessageContainer* container = message_container__unpack(NULL, length, (uint8_t*)buffer);
@@ -84,17 +86,10 @@ void receive_callback(char* buffer, size_t length)
{
CalculateRequest* request = calculate_request__unpack(NULL, container->data.len, container->data.data);
- char screen_text[100];
- strcpy(screen_text, "Calculate Request: ");
-
- char num_buf[5];
- ltoa(request->a, num_buf);
- strcat(screen_text, num_buf);
- strcat(screen_text, " + ");
- ltoa(request->b, num_buf);
- strcat(screen_text, num_buf);
-
- draw_string(screen_text,strlen(screen_text));
+ writeLine("Calculate Request: ");
+ writeFloat(request->a);
+ writeString(" + ");
+ writeFloat(request->b);
CalculateResponse response = CALCULATE_RESPONSE__INIT;
response.sum = request->a + request->b;
@@ -116,6 +111,9 @@ void receive_callback(char* buffer, size_t length)
uint8_t* output = malloc(message_container__get_packed_size(&responseContainer));
size = message_container__pack(&responseContainer, output);
+ writeLine("Sending Response: ");
+ writeFloat(response.sum);
+
SendChars(output, size);
}