1 | /*
|
---|
2 | * TOPPERS/ASP Kernel
|
---|
3 | * Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
4 | * Advanced Standard Profile Kernel
|
---|
5 | *
|
---|
6 | * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
|
---|
7 | * Toyohashi Univ. of Technology, JAPAN
|
---|
8 | * Copyright (C) 2004-2012 by Embedded and Real-Time Systems Laboratory
|
---|
9 | * Graduate School of Information Science, Nagoya Univ., JAPAN
|
---|
10 | * Copyright (C) 2015-2019 by TOPPERS PROJECT Educational Working Group.
|
---|
11 | *
|
---|
12 | * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
|
---|
13 | * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
---|
14 | * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
---|
15 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
16 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
17 | * スコード中に含まれていること.
|
---|
18 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
19 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
20 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
21 | * の無保証規定を掲載すること.
|
---|
22 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
23 | * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
24 | * と.
|
---|
25 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
26 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
27 | * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
28 | * 報告すること.
|
---|
29 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
30 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
31 | * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
---|
32 | * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
---|
33 | * 免責すること.
|
---|
34 | *
|
---|
35 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
36 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
---|
37 | * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
---|
38 | * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
---|
39 | * の責任を負わない.
|
---|
40 | *
|
---|
41 | * $Id$
|
---|
42 | */
|
---|
43 |
|
---|
44 | /*
|
---|
45 | * GRAPHIC-LCDテキスト表示プログラムの本体
|
---|
46 | */
|
---|
47 |
|
---|
48 | #include <kernel.h>
|
---|
49 | #include <t_syslog.h>
|
---|
50 | #include <t_stdlib.h>
|
---|
51 | #include <stdio.h>
|
---|
52 | #include <string.h>
|
---|
53 | #include <target_syssvc.h>
|
---|
54 | #include "syssvc/serial.h"
|
---|
55 | #include "syssvc/syslog.h"
|
---|
56 | #include "glcd_disp.h"
|
---|
57 | #include "font24.c"
|
---|
58 | #include "font20.c"
|
---|
59 | #include "font16.c"
|
---|
60 | #include "font12.c"
|
---|
61 | #include "font8.c"
|
---|
62 |
|
---|
63 | /*
|
---|
64 | * 文字描画
|
---|
65 | * param1 pDrawProp: Pointer to Draw Prop
|
---|
66 | * param2 x0: 文字描画 X座標始点
|
---|
67 | * param3 y0: 文字描画 Y座標始点
|
---|
68 | * param4 c: 文字イメージへのポインタ
|
---|
69 | */
|
---|
70 | #ifndef MAX_FONT_IMAGE
|
---|
71 | static void
|
---|
72 | DrawChar(LCD_DrawProp_t *pDrawProp, uint16_t x0, uint16_t y0, const uint8_t *c)
|
---|
73 | {
|
---|
74 | LCD_Handler_t *hlcd = pDrawProp->hlcd;
|
---|
75 | sFONT *pFont = pDrawProp->pFont;
|
---|
76 | uint32_t h, w, stride;
|
---|
77 | uint8_t *pchar;
|
---|
78 |
|
---|
79 | stride = ((pFont->Width + 7)/8);
|
---|
80 | for(h = 0 ; h < pFont->Height ; h++){
|
---|
81 | pchar = ((uint8_t *)c + stride * h);
|
---|
82 | for(w = 0; w < pFont->Width ; w++){
|
---|
83 | if(pchar[w/8] & (1 << (7 - (w % 8)))){
|
---|
84 | lcd_drawPixel(hlcd, (x0 + w), (y0 + h), pDrawProp->TextColor);
|
---|
85 | }
|
---|
86 | else{
|
---|
87 | lcd_drawPixel(hlcd, (x0 + w), (y0 + h), pDrawProp->BackColor);
|
---|
88 | }
|
---|
89 | }
|
---|
90 | }
|
---|
91 | }
|
---|
92 | #else
|
---|
93 | static void
|
---|
94 | DrawChar(LCD_DrawProp_t *pDrawProp, uint16_t x0, uint16_t y0, const uint8_t *c)
|
---|
95 | {
|
---|
96 | LCD_Handler_t *hlcd = pDrawProp->hlcd;
|
---|
97 | sFONT *pFont = pDrawProp->pFont;
|
---|
98 | uint32_t h, w, stride;
|
---|
99 | const uint8_t *pchar;
|
---|
100 | color_t image[MAX_FONT_IMAGE];
|
---|
101 |
|
---|
102 | stride = ((pFont->Width + 7)/8);
|
---|
103 | for(h = 0 ; h < pFont->Height ; h++){
|
---|
104 | pchar = ((uint8_t *)c + stride * h);
|
---|
105 | for(w = 0; w < pFont->Width ; w++){
|
---|
106 | if(pchar[w/8] & (1 << (7 - (w % 8)))){
|
---|
107 | image[w] = pDrawProp->TextColor;
|
---|
108 | }
|
---|
109 | else{
|
---|
110 | image[w] = pDrawProp->BackColor;
|
---|
111 | }
|
---|
112 | }
|
---|
113 | lcd_drawImageHLine(hlcd, x0, (y0 + h), pFont->Width, image);
|
---|
114 | }
|
---|
115 | }
|
---|
116 | #endif
|
---|
117 |
|
---|
118 | /*
|
---|
119 | * 文字列表示ラインクリア
|
---|
120 | * param1 pDrawProp: Pointer to Draw Prop
|
---|
121 | * param2 ライン番号
|
---|
122 | */
|
---|
123 | void
|
---|
124 | lcd_clearStringLine(LCD_DrawProp_t *pDrawProp, uint16_t Line)
|
---|
125 | {
|
---|
126 | sFONT *pFont = pDrawProp->pFont;
|
---|
127 | lcd_fillRect(pDrawProp->hlcd, 0, (Line * pFont->Height), pDrawProp->hlcd->_width, pFont->Height, pDrawProp->BackColor);
|
---|
128 | }
|
---|
129 |
|
---|
130 | /*
|
---|
131 | * 一文字描画
|
---|
132 | * param1 pDrawProp: Pointer to Draw Prop
|
---|
133 | * param2 x0: 文字描画 X座標始点
|
---|
134 | * param3 y0: 文字描画 Y座標始点
|
---|
135 | * param4 描画アスキーコード(範囲は0x20から0x7Eまで)
|
---|
136 | */
|
---|
137 | void
|
---|
138 | lcd_DisplayChar(LCD_DrawProp_t *pDrawProp, uint16_t x0, uint16_t y0, uint8_t Ascii)
|
---|
139 | {
|
---|
140 | sFONT *pFont = pDrawProp->pFont;
|
---|
141 | DrawChar(pDrawProp, x0, y0, &pFont->table[(Ascii-' ') * pFont->Height * ((pFont->Width + 7) / 8)]);
|
---|
142 | }
|
---|
143 |
|
---|
144 | /*
|
---|
145 | * 文字列描画
|
---|
146 | * param1 pDrawProp: Pointer to Draw Prop
|
---|
147 | * param1 x0: 文字列描画 X座標始点
|
---|
148 | * param2 y0: 文字列描画 Y座標始点
|
---|
149 | * param3 Text: 描画文字列へのポインタ
|
---|
150 | */
|
---|
151 | void
|
---|
152 | lcd_DisplayStringAt(LCD_DrawProp_t *pDrawProp, uint16_t x0, uint16_t y0, uint8_t *Text, Line_ModeTypdef Mode)
|
---|
153 | {
|
---|
154 | sFONT *pFont = pDrawProp->pFont;
|
---|
155 | uint16_t ref_column = 1, i = 0;
|
---|
156 | uint32_t size = 0, xsize = 0;
|
---|
157 | uint8_t *ptr = (uint8_t *)Text;
|
---|
158 |
|
---|
159 | /* Get the text size */
|
---|
160 | while (*ptr++) size++;
|
---|
161 |
|
---|
162 | /* Characters number per line */
|
---|
163 | xsize = (pDrawProp->hlcd->_width / pFont->Width);
|
---|
164 |
|
---|
165 | switch(Mode){
|
---|
166 | case CENTER_MODE:
|
---|
167 | ref_column = x0 + ((xsize - size) * pFont->Width) / 2;
|
---|
168 | break;
|
---|
169 | case LEFT_MODE:
|
---|
170 | ref_column = x0;
|
---|
171 | break;
|
---|
172 | case RIGHT_MODE:
|
---|
173 | ref_column = - x0 + ((xsize - size) * pFont->Width);
|
---|
174 | break;
|
---|
175 | default:
|
---|
176 | ref_column = x0;
|
---|
177 | break;
|
---|
178 | }
|
---|
179 |
|
---|
180 | /*
|
---|
181 | * 開始カラム位置をスクリーン内に収める
|
---|
182 | */
|
---|
183 | if((ref_column < 1) || (ref_column >= 0x8000)){
|
---|
184 | ref_column = 1;
|
---|
185 | }
|
---|
186 |
|
---|
187 | /*
|
---|
188 | * 一文字描画を使って文字列を描画する
|
---|
189 | */
|
---|
190 | while((*Text != 0) & (((pDrawProp->hlcd->_width - (i*pFont->Width)) & 0xFFFF) >= pFont->Width)){
|
---|
191 | lcd_DisplayChar(pDrawProp, ref_column, y0, *Text);
|
---|
192 | ref_column += pFont->Width; /* 次のカラムに移動 */
|
---|
193 | Text++; /* 次の文字に移動 */
|
---|
194 | i++;
|
---|
195 | }
|
---|
196 | }
|
---|
197 |
|
---|
198 | /*
|
---|
199 | * 文字列描画
|
---|
200 | * param1 pDrawProp: Pointer to Draw Prop
|
---|
201 | * param2 x0: 文字列描画 X座標始点
|
---|
202 | * param3 y0: 文字列描画 Y座標始点
|
---|
203 | * param4 Text: 描画文字列へのポインタ
|
---|
204 | */
|
---|
205 | void
|
---|
206 | lcd_DisplayStringAtLine(LCD_DrawProp_t *pDrawProp, uint16_t Line, uint8_t *ptr)
|
---|
207 | {
|
---|
208 | sFONT *pFont = pDrawProp->pFont;
|
---|
209 |
|
---|
210 | lcd_DisplayStringAt(pDrawProp, 0, Line * pFont->Height, ptr, LEFT_MODE);
|
---|
211 | }
|
---|
212 |
|
---|