comparison src/cs/drivers/drv_app/r2d/lcds/ColorBoard/custom_process.pl @ 0:b6a5e36de839

src/cs: initial import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 04:39:26 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:b6a5e36de839
1 #!perl
2
3 # Mode os scanning (vertical or horizontal)
4 $mode=$ARGV[0];
5
6 # Name of file used to transfer data between this script and the r2d_font_tool
7 $data=$ARGV[1];
8
9 if (($#ARGV+1)>2)
10 {
11 $x=$ARGV[3];
12 open(DATA,">$data") or die "Cannot create data file : $!\n";
13 $words = int($x/2)+1;
14
15 # One word must be added because the alignement is done by excess
16 print DATA $words;
17 close(DATA);
18
19
20 }
21 else
22 {
23 # Open the data file to import glyph bit matrix generated by r2d_font_tool
24 open(DATA,"$data") or die "Cannot open input file : $!\n";
25
26 # It is the size unmodified by r2d_font_tool (width in vertical mode and
27 # height in horizontal mode). It corresponds to the width/height for the
28 # current glyph
29 $matrix_size=int(<DATA>);
30
31 # It is the size which is word aligned by r2d_font_tool (height in
32 # vertical mode and width in horizontal one)
33 # It corresponds to the max width/height on all fonts.
34 $matrix_aligned_size=int(<DATA>);
35
36 # Original value before word alignment
37 # (Max value on all glyphs before alignment)
38 $matrix_max_size=int(<DATA>);
39
40 # Width of the glyph image in the bitmap
41 $matrix_image_width=int(<DATA>);
42
43 # Height of the glyph in the bitmap
44 $matrix_image_height=int(<DATA>);
45
46 if ($mode =~ /vertical/)
47 {
48 # Scanning of the glyph bit matrix done column per column
49 # (since datas are saved column per column by r2d_font_tool
50 # when in horizontal mode)
51 for($i=0;$i<$matrix_size;$i++)
52 {
53 for($j=0;$j<$matrix_aligned_size;$j++)
54 {
55 $matrix{$i.".".$j}=int(<DATA>);
56 }
57 }
58 }
59 else
60 {
61 # Scanning of the glyph bit matrix done line per line
62 for($i=0;$i<$matrix_aligned_size;$i++)
63 {
64 for($j=0;$j<$matrix_size;$j++)
65 {
66 $matrix{$i.".".$j}=int(<DATA>);
67 }
68 }
69 }
70 close(DATA);
71
72
73 # That part of the code is translating the glyph (initially represented
74 # as a bit matrix) to a format which is compatible with the current LCD.
75 #
76 # In this example, the LCD is a 24 bpp one. So, a bit 0 (correponding to black)
77 # must be converted to 0, and 1 (for white) to 0xFFFFFF.
78 #
79 # The scanning must use the IMAGE width in vertical mode
80 # and the IMAGE height in horizontal mode.
81
82 # In vertical mode, the height must use max_size on all glyph
83 # In horizontal mode, the width must use the max_size.
84 # You can either use the aligned_version if you LCD is a 1bpp one and
85 # or you can use the non aligned one (matrix_max_size) and do the alignment
86 # yourself.
87
88 # In our case, the LCD is a 24bpp, so no alignment is required and the
89 # max_size is used directly.
90
91 $words=int(($matrix_max_size/2)) + 1;
92 $aligned=$words*2;
93
94 open(DATA,">$data") or die "Cannot create data file : $!\n";
95 if ($mode =~ /vertical/)
96 {
97 # Scanning column per column
98 for($i=0;$i<$matrix_image_width;$i++)
99 {
100 for($j=0;$j<$aligned/2;$j++)
101 {
102 $pos=2*$j;
103 $npos=$pos+1;
104 $ra=$matrix{$i.".".$pos};
105 $rb=$matrix{$i.".".$npos};
106
107 # Conversion of bit to color value
108 if ($ra != 0)
109 {
110 $ra=0x0FF;
111 }
112 else
113 {
114 $ra=0;
115 }
116
117 if ($rb != 0)
118 {
119 $rb=0x0FF0000;
120 }
121 else
122 {
123 $rb=0;
124 }
125
126 $rb=$rb | $ra;
127 $res=sprintf "0x%08X\n",$rb;
128 print DATA $res;
129 }
130 }
131 }
132 else
133 {
134 # Scanning line per line
135 for($j=0;$j<$matrix_image_height;$j++)
136 {
137 for($i=0;$i<$aligned/2;$i++)
138 {
139 $pos=2*$i;
140 $npos=$pos+1;
141 $ra=$matrix{$pos.".".$j};
142 $rb=$matrix{$npos.".".$j};
143
144 # Conversion of bit to color value
145 if ($ra != 0)
146 {
147 $ra=0x0FF;
148 }
149 else
150 {
151 $ra=0;
152 }
153
154 if ($rb != 0)
155 {
156 $rb=0x0FF0000;
157 }
158 else
159 {
160 $rb=0;
161 }
162
163 $rb=$rb | $ra;
164 $res=sprintf "0x%08X\n",$rb;
165 print DATA $res;
166 }
167 }
168 }
169 close(DATA);
170 }