-
Notifications
You must be signed in to change notification settings - Fork 1
/
Display_HAL.c
116 lines (104 loc) · 3.44 KB
/
Display_HAL.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include <ti/grlib/grlib.h>
#include "LcdDriver/Crystalfontz128x128_ST7735.h"
#include "LcdDriver/HAL_MSP_EXP432P401R_Crystalfontz128x128_ST7735.h"
#include <ti/devices/msp432p4xx/driverlib/driverlib.h>
char o1,o2,o3,o4;
Graphics_Context g_sContext;
typedef enum {black, red, green, yellow, blue, magenta, cyan, white} color_t;
void InitGraphics() {
Crystalfontz128x128_Init();
Crystalfontz128x128_SetOrientation(LCD_ORIENTATION_UP);
Graphics_initContext(&g_sContext,
&g_sCrystalfontz128x128,
&g_sCrystalfontz128x128_funcs);
Graphics_setForegroundColor(&g_sContext, GRAPHICS_COLOR_BLACK);
Graphics_setBackgroundColor(&g_sContext, GRAPHICS_COLOR_YELLOW);
GrContextFontSet(&g_sContext, &g_sFontCmtt16);
Graphics_clearDisplay(&g_sContext);
}
void LCDClearDisplay(int color) {
Graphics_setBackgroundColor(&g_sContext, color);
Graphics_clearDisplay(&g_sContext);
}
void LCDDrawChar(unsigned row, unsigned col, int8_t c) {
Graphics_drawString(&g_sContext,
&c,
1,
8 * (col % 16),
16 * (row % 8),
OPAQUE_TEXT);
}
void PrintString(char *str, int row, int col) {
int i;
for (i = 0; str[i] != '\0'; i++) {
LCDDrawChar(row, col, str[i]);
col++;
if (col >= 16) {
col = 0;
row++;
if (row >= 8) {
row = 0;
}
}
}
}
void LCDSetFgColor(color_t c) {
switch (c)
{
case black:
Graphics_setForegroundColor(&g_sContext, GRAPHICS_COLOR_BLACK);
break;
case red:
Graphics_setForegroundColor(&g_sContext, GRAPHICS_COLOR_RED);
break;
case green:
Graphics_setForegroundColor(&g_sContext, GRAPHICS_COLOR_GREEN);
break;
case yellow:
Graphics_setForegroundColor(&g_sContext, GRAPHICS_COLOR_YELLOW);
break;
case blue:
Graphics_setForegroundColor(&g_sContext, GRAPHICS_COLOR_BLUE);
break;
case magenta:
Graphics_setForegroundColor(&g_sContext, GRAPHICS_COLOR_MAGENTA);
break;
case cyan:
Graphics_setForegroundColor(&g_sContext, GRAPHICS_COLOR_CYAN);
break;
case white:
Graphics_setForegroundColor(&g_sContext, GRAPHICS_COLOR_WHITE);
break;
}
}
// this function set the background color for any background input color.
void LCDSetBgColor(color_t c) {
switch (c)
{
case black:
Graphics_setBackgroundColor(&g_sContext, GRAPHICS_COLOR_BLACK);
break;
case red:
Graphics_setBackgroundColor(&g_sContext, GRAPHICS_COLOR_RED);
break;
case green:
Graphics_setBackgroundColor(&g_sContext, GRAPHICS_COLOR_GREEN);
break;
case yellow:
Graphics_setBackgroundColor(&g_sContext, GRAPHICS_COLOR_YELLOW);
break;
case blue:
Graphics_setBackgroundColor(&g_sContext, GRAPHICS_COLOR_BLUE);
break;
case magenta:
Graphics_setBackgroundColor(&g_sContext, GRAPHICS_COLOR_MAGENTA);
break;
case cyan:
Graphics_setBackgroundColor(&g_sContext, GRAPHICS_COLOR_CYAN);
break;
case white:
Graphics_setBackgroundColor(&g_sContext, GRAPHICS_COLOR_WHITE);
break;
}
}
//-----------------------------------------------------------------------