NANO100_BSP V3.04.002
The Board Support Package for Nano100BN Series
LCDLIB.c
Go to the documentation of this file.
1/**************************************************************************/
11#include <stdio.h>
12#include <stdlib.h>
13#include <string.h>
14#include <stdint.h>
15#include "Nano100Series.h"
16#include "LCDLIB.h"
17
27
32extern char *Zone[];
33extern const ZoneInfo_TypeDef LCD_ZoneInfo[];
34extern const uint16_t *Zone_TextDisplay[];
35 /* end of group NANO100_LCDLIB_EXPORTED_VARIABLES */
38
52void LCDLIB_Printf(uint32_t u32Zone, char *string)
53{
54 int data, length, index;
55 uint16_t bitfield;
56 uint32_t com, bit;
57 int i;
58
59 length = strlen(string);
60 index = 0;
61
62 /* fill out all characters on display */
63 for (index = 0; index < LCD_ZoneInfo[u32Zone].Sub_Zone_Num; index++)
64 {
65 if (index < length)
66 {
67 data = (int) *string;
68 }
69 else /* padding with space */
70 {
71 data = 0x20; /* SPACE */
72 }
73 /* defined letters currently starts at "SPACE" - 0x20; */
74 data = data - 0x20;
75 bitfield = *(Zone_TextDisplay[u32Zone] + data);
76
77 for (i = 0; i < LCD_ZoneInfo[u32Zone].Zone_Digit_SegNum; i++)
78 {
79 bit = *(Zone[u32Zone]
80 + index*LCD_ZoneInfo[u32Zone].Zone_Digit_SegNum*2
81 + i*2 + 1);
82
83 com = *(Zone[u32Zone]
84 + index*LCD_ZoneInfo[u32Zone].Zone_Digit_SegNum*2
85 + i*2 + 0);
86
87 LCD_SetPixel(com, bit, 0);
88
89 if (bitfield & (1 << i))
90 {
91 /* Turn on segment */
92 LCD_SetPixel(com, bit, 1);
93 }
94 }
95 string++;
96 }
97
98}
99
100
110void LCDLIB_PrintNumber(uint32_t u32Zone, long long value)
111{
112 int index;
113 long long num, i, com, bit, div, len, tmp;
114 uint16_t bitpattern;
115
116 if (value < 0)
117 {
118 value = abs(value);
119 }
120
121 /* Length of number */
122 len = 0;
123 tmp = value;
124 while( 1 )
125 {
126 if( (tmp/10) || (tmp%10) )
127 {
128 tmp = tmp / 10;
129 len++;
130 }
131 else
132 break;
133 }
134
135
136 /* Extract useful digits */
137 div = 1;
138
139 /* fill out all characters on display */
140 for (index = (LCD_ZoneInfo[u32Zone].Sub_Zone_Num-1); index >= 0; index--)
141 {
142 num = (value / div) % 10;
143 num += 16;
144
145 bitpattern = *(Zone_TextDisplay[u32Zone] + num);
146
147 for (i = 0; i < LCD_ZoneInfo[u32Zone].Zone_Digit_SegNum; i++)
148 {
149 bit = *(Zone[u32Zone]
150 + index*LCD_ZoneInfo[u32Zone].Zone_Digit_SegNum*2
151 + i*2 + 1);
152 com = *(Zone[u32Zone]
153 + index*LCD_ZoneInfo[u32Zone].Zone_Digit_SegNum*2
154 + i*2 + 0);
155
156 LCD_SetPixel(com, bit, 0);
157
158 if (bitpattern & (1 << i))
159 {
160 LCD_SetPixel(com, bit, 1);
161 }
162 }
163 div = div * 10;
164
165 }
166
167}
168
169
170
181void LCDLIB_PutChar(uint32_t u32Zone, uint32_t u32Index, uint8_t u8Ch)
182{
183 int data, index;
184 uint16_t bitfield;
185 uint32_t com, bit;
186 int i;
187
188 index = u32Index;
189
190 data = u8Ch;
191
192 if(u32Index > LCD_ZoneInfo[u32Zone].Sub_Zone_Num) return;
193
194 /* defined letters currently starts at "SPACE" - 0x20; */
195 data = data - 0x20;
196 bitfield = *(Zone_TextDisplay[u32Zone] + data);
197
198 for (i = 0; i < LCD_ZoneInfo[u32Zone].Zone_Digit_SegNum; i++)
199 {
200 bit = *(Zone[u32Zone]
201 + index*LCD_ZoneInfo[u32Zone].Zone_Digit_SegNum*2
202 + i*2 + 1);
203
204 com = *(Zone[u32Zone]
205 + index*LCD_ZoneInfo[u32Zone].Zone_Digit_SegNum*2
206 + i*2 + 0);
207
208 LCD_SetPixel(com, bit, 0);
209
210 if (bitfield & (1 << i))
211 {
212 /* Turn on segment */
213 LCD_SetPixel(com, bit, 1);
214 }
215 }
216
217}
218
230void LCDLIB_SetSymbol(uint32_t u32Zone, uint32_t u32Index, uint32_t u32OnOff)
231{
232 uint32_t com, bit;
233
234 bit = *(Zone[u32Zone] + u32Index*2 + 1);
235
236 com = *(Zone[u32Zone] + u32Index*2 + 0);
237
238 if (u32OnOff)
239 LCD_SetPixel(com, bit, 1); /* Turn on segment */
240 else
241 LCD_SetPixel(com, bit, 0); /* Turn off segment */
242
243}
244 /* end of group NANO100_LCDLIB_EXPORTED_FUNCTIONS */
246 /* end of group NANO100_LCDLIB_Driver */
248 /* end of group NANO100_Library */
250
251/*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/
252
NANO100 LCDLIB header file.
Nano100 series peripheral access layer header file. This file contains all the peripheral register's ...
void LCD_SetPixel(uint32_t u32Com, uint32_t u32Seg, uint32_t u32OnFlag)
Enables a segment on the LCD display.
Definition: lcd.c:64
uint32_t Zone_Digit_SegNum
Definition: LCDLIB.h:35
uint32_t Sub_Zone_Num
Definition: LCDLIB.h:34
void LCDLIB_PrintNumber(uint32_t u32Zone, long long value)
Display number on LCD.
Definition: LCDLIB.c:110
void LCDLIB_Printf(uint32_t u32Zone, char *string)
Display text on LCD.
Definition: LCDLIB.c:52
void LCDLIB_SetSymbol(uint32_t u32Zone, uint32_t u32Index, uint32_t u32OnOff)
Display symbol on LCD.
Definition: LCDLIB.c:230
void LCDLIB_PutChar(uint32_t u32Zone, uint32_t u32Index, uint8_t u8Ch)
Display character on LCD.
Definition: LCDLIB.c:181
return value
Definition: semihosting.h:98