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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
/*++
Copyright (c) 2010 WonderMedia Technologies, Inc.
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details. You
should have received a copy of the GNU General Public License along with this
program. If not, see http://www.gnu.org/licenses/>.
WonderMedia Technologies, Inc.
4F, 531, Chung-Cheng Road, Hsin-Tien, Taipei 231, R.O.C.
--*/
#include <common.h>
#include <command.h>
#include <linux/ctype.h>
#include <asm/arch/common_def.h>
#include "wmt_display.h"
#include "minivgui.h"
//#define CHAR_WIDTH 8
//#define CHAR_HEIGHT 20 // 16
int text_x = 30, text_y = 30 - CHAR_HEIGHT;
// ------------------- Extern Variable ------------------------
extern int g_display_direction;
//-------------------- Extern Function -----------------------
extern void mv_initPrimary(int no,const mv_surface * s);
//extern void arm_memset(void * s, int c, size_t count);
extern int display_init(int on, int force);
static int atoi(char *s) //added by howayhuo
{
int i,n,sign;
for(i=0;isspace(s[i]);i++) //Ìø¹ý¿Õ°×·û
;
sign=(s[i]=='-')?-1:1;
if(s[i]=='+'||s[i]=='-') //Ìø¹ý·ûºÅ
i++;
for(n=0;isdigit(s[i]);i++)
n=10*n+(s[i]-'0'); //½«Êý×Ö×Ö·ûת»»³ÉÕûÐÎÊý×Ö
return sign *n;
}
int do_textout(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
int tmpx, tmpy;
unsigned int rgb = 0;
char *text_first, *text_last;
char r, g, b;
int i, len, textLen;
mv_Rect rect;
char tmpbuf[200];
int no;
mv_surface *s;
if(display_init(1, 0))
return -1;
switch (argc) {
case 1:
case 2:
case 3: /* use load_addr as default address */
case 4: /* use argument */
printf("<ERROR> too few argument\n");
printf ("Usage:\n%s\n", cmdtp->usage);
return -1;
default:
//tmpx = simple_strtoul(argv[1], NULL, 10);
//tmpy = simple_strtoul(argv[2], NULL, 10);
tmpx = atoi(argv[1]);
tmpy = atoi(argv[2]);
//printf("tmpx=%d, tmpy=%d\n", tmpx,tmpy);
if(tmpx >= 0)
text_x = tmpx;
if(tmpy >= 0)
text_y = tmpy;
else
text_y = text_y + CHAR_HEIGHT;
printf("x=%d, y=%d\n", text_y, text_y);
rgb = simple_strtoul(argv[argc - 1], NULL, 16);
text_first = argv[3];
if(*text_first != '"') {
printf("<ERROR> please specify the text begin with \" \n", *text_first);
printf ("Usage:\n%s\n", cmdtp->usage);
return -1;
}
text_last = argv[argc - 2];
while(*text_last != '\0')
text_last++;
if(*--text_last != '"') {
printf("<ERROR> please specify the text end with \" \n", *text_last);
printf ("Usage:\n%s\n", cmdtp->usage);
return -1;
}
break;
}
len = 0;
for(i = 3; i < argc - 1; i++) {
printf("%s ", argv[i]);
len += sprintf(tmpbuf + len, "%s ", argv[i]);
}
printf("\n");
//if you input:
// drawtext 0 0 "aa bb cc" ff0000
//then the tmpbuf is ["aa bb cc" ], it have redundant space at the end.
tmpbuf[len - 2] = '\0'; //ignore the last 'double quotation marks' and 'space'
for(no = 0; no < VPP_VOUT_INFO_NUM; no++) {
s = mv_getSurface(no);
if(s->startAddr == 0)
continue;
textLen = len - 3; // total len- ' start " ' (1 char) - 'space' (1 char) -' end " ' (1 char)
rect.left = 0;
rect.top = text_y;
rect.right = s->width; //vfb_var.xres;
rect.bottom = text_y + CHAR_HEIGHT;
if(g_display_direction == 0 || g_display_direction == 2) //the screen is portrait
rect.right = s->height; //vfb_var.yres;
mv_fillRect(no, &rect, 0, 0, 0);
r = (rgb >> 16) & 0xFF;
g = (rgb >> 8) & 0xFF;
b = rgb & 0xFF;
mv_textOut(no, text_x, text_y, tmpbuf + 1, r, g, b);
}
return 0;
}
U_BOOT_CMD(
textout, 100, 5, do_textout,
"textout - show text to the screen. Example: textout 0 0 \\\"hello world\\\" FFFFFF\n",
"- show text to the screen \n"
"usage: textout x y \"str\" color\n"
"(x,y) is the coordinate. x, y are decimal. (x,y) default value is (30,30)\n"
"if x < 0, the x coordinate is unchaged\n"
"if y < 0, the y coordinate auto add 22 pixels to move to next line\n"
"color is 24bit Hex, R[23:16], G[15:8], B[7:0]\n"
"for example: textout 0 0 \\\"hello world\\\" FFFFFF\n"
" textout -1 -1 \\\"come on\\\" FF0000\n"
);
|