| Nano102_112 Series BSP V3.03.002 The Board Support Package for Nano102_112 Series

LCDLIB.c
Go to the documentation of this file.
1 /**************************************************************************/
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <string.h>
16 #include <stdint.h>
17
18 #include "Nano1X2Series.h"
19 #include "lcd.h"
20 #include "LCDLIB.h"
21
30
33
35
42 extern char *Zone[];
43 extern const ZoneInfo_TypeDef LCD_ZoneInfo[];
44 extern const uint16_t *Zone_TextDisplay[];
45
46
47 /* end of group NANO1X2_LCDLIB_EXPORTED_VARIABLES */
50
64 void LCDLIB_Printf(uint32_t u32Zone, char *string)
65 {
66 int data, length, index;
67 uint16_t bitfield;
68 uint32_t com, bit;
69 int i;
70
71 length = strlen(string);
72 index = 0;
73
74 /* fill out all characters on display */
75 for (index = 0; index < LCD_ZoneInfo[u32Zone].Sub_Zone_Num; index++)
76 {
77 if (index < length)
78 {
79 data = (int) *string;
80 }
81 else /* padding with space */
82 {
83 data = 0x20; /* SPACE */
84 }
85 /* defined letters currently starts at "SPACE" - 0x20; */
86 data = data - 0x20;
87 bitfield = *(Zone_TextDisplay[u32Zone] + data);
88
89 for (i = 0; i < LCD_ZoneInfo[u32Zone].Zone_Digit_SegNum; i++)
90 {
91 bit = *(Zone[u32Zone]
92 + index*LCD_ZoneInfo[u32Zone].Zone_Digit_SegNum*2
93 + i*2 + 1);
94
95 com = *(Zone[u32Zone]
96 + index*LCD_ZoneInfo[u32Zone].Zone_Digit_SegNum*2
97 + i*2 + 0);
98
99 LCD_SetPixel(com, bit, 0);
100
101 if (bitfield & (1 << i))
102 {
103 /* Turn on segment */
104 LCD_SetPixel(com, bit, 1);
105 }
106 }
107 string++;
108 }
109
110 }
111
112
122 void LCDLIB_PrintNumber(uint32_t u32Zone, long long value)
123 {
124 int index;
125 long long num, i, com, bit, div, len, tmp;
126 uint16_t bitpattern;
127
128 if (value < 0)
129 {
130 value = abs(value);
131 }
132
133 /* Length of number */
134 len = 0;
135 tmp = value;
136 while( 1 )
137 {
138 if( (tmp/10) || (tmp%10) )
139 {
140 tmp = tmp / 10;
141 len++;
142 }
143 else
144 break;
145 }
146
147
148 /* Extract useful digits */
149 div = 1;
150
151 /* fill out all characters on display */
152 for (index = (LCD_ZoneInfo[u32Zone].Sub_Zone_Num-1); index >= 0; index--)
153 {
154 num = (value / div) % 10;
155 num += 16;
156
157 bitpattern = *(Zone_TextDisplay[u32Zone] + num);
158
159 for (i = 0; i < LCD_ZoneInfo[u32Zone].Zone_Digit_SegNum; i++)
160 {
161 bit = *(Zone[u32Zone]
162 + index*LCD_ZoneInfo[u32Zone].Zone_Digit_SegNum*2
163 + i*2 + 1);
164 com = *(Zone[u32Zone]
165 + index*LCD_ZoneInfo[u32Zone].Zone_Digit_SegNum*2
166 + i*2 + 0);
167
168 LCD_SetPixel(com, bit, 0);
169
170 if (bitpattern & (1 << i))
171 {
172 LCD_SetPixel(com, bit, 1);
173 }
174 }
175 div = div * 10;
176
177 }
178
179 }
180
181
182
193 void LCDLIB_PutChar(uint32_t u32Zone, uint32_t u32Index, uint8_t u8Ch)
194 {
195 int data, index;
196 uint16_t bitfield;
197 uint32_t com, bit;
198 int i;
199
200 index = u32Index;
201
202 data = u8Ch;
203
204 if(u32Index > LCD_ZoneInfo[u32Zone].Sub_Zone_Num) return;
205
206 /* defined letters currently starts at "SPACE" - 0x20; */
207 data = data - 0x20;
208 bitfield = *(Zone_TextDisplay[u32Zone] + data);
209
210 for (i = 0; i < LCD_ZoneInfo[u32Zone].Zone_Digit_SegNum; i++)
211 {
212 bit = *(Zone[u32Zone]
213 + index*LCD_ZoneInfo[u32Zone].Zone_Digit_SegNum*2
214 + i*2 + 1);
215
216 com = *(Zone[u32Zone]
217 + index*LCD_ZoneInfo[u32Zone].Zone_Digit_SegNum*2
218 + i*2 + 0);
219
220 LCD_SetPixel(com, bit, 0);
221
222 if (bitfield & (1 << i))
223 {
224 /* Turn on segment */
225 LCD_SetPixel(com, bit, 1);
226 }
227 }
228
229 }
230
242 void LCDLIB_SetSymbol(uint32_t u32Zone, uint32_t u32Index, uint32_t u32OnOff)
243 {
244 uint32_t com, bit;
245
246 bit = *(Zone[u32Zone] + u32Index*2 + 1);
247
248 com = *(Zone[u32Zone] + u32Index*2 + 0);
249
250 if (u32OnOff)
251 LCD_SetPixel(com, bit, 1); /* Turn on segment */
252 else
253 LCD_SetPixel(com, bit, 0); /* Turn off segment */
254
255 }
256 /* end of group NANO1X2_LCDLIB_EXPORTED_FUNCTIONS */
258 /* end of group NANO1X2_LCDLIB_Driver */
260 /* end of group NANO1X2_Library */
262
263 /*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/
264
LCDLIB_PutChar
void LCDLIB_PutChar(uint32_t u32Zone, uint32_t u32Index, uint8_t u8Ch)
Display character on LCD.
Definition: LCDLIB.c:193
ZoneInfo_TypeDef
Definition: LCDLIB.h:33
ZoneInfo_TypeDef::Sub_Zone_Num
uint32_t Sub_Zone_Num
Sub zone number.
Definition: LCDLIB.h:35
LCDLIB_PrintNumber
void LCDLIB_PrintNumber(uint32_t u32Zone, long long value)
Display number on LCD.
Definition: LCDLIB.c:122
LCDLIB_SetSymbol
void LCDLIB_SetSymbol(uint32_t u32Zone, uint32_t u32Index, uint32_t u32OnOff)
Display symbol on LCD.
Definition: LCDLIB.c:242
Nano1X2Series.h
Nano102/112 peripheral access layer header file. This file contains all the peripheral register's def...
LCDLIB.h
Nano 102/112 series LCDLIB header file.
lcd.h
Nano102/112 series LCD driver header file.
ZoneInfo_TypeDef::Zone_Digit_SegNum
uint32_t Zone_Digit_SegNum
Segment number.
Definition: LCDLIB.h:36
LCD_SetPixel
void LCD_SetPixel(uint32_t u32Com, uint32_t u32Seg, uint32_t u32OnFlag)
Enables a segment on the LCD display.
Definition: lcd.c:62
value
return value
Definition: semihosting.h:98
LCDLIB_Printf
void LCDLIB_Printf(uint32_t u32Zone, char *string)
Display text on LCD.
Definition: LCDLIB.c:64