30
|
1 ///////////////////////////////////////////////////////////////////////////////
|
|
2 /// -*- coding: UTF-8 -*-
|
|
3 ///
|
|
4 /// \file FontPack/./base_upperRegion.c
|
|
5 /// \brief The beginning of it all. main() is part of this.
|
36
|
6 /// \author heinrichs weikamp gmbh
|
30
|
7 /// \date 31-August-2015
|
|
8 ///
|
|
9 /// $Id$
|
|
10 ///////////////////////////////////////////////////////////////////////////////
|
|
11 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh
|
|
12 ///
|
|
13 /// This program is free software: you can redistribute it and/or modify
|
|
14 /// it under the terms of the GNU General Public License as published by
|
|
15 /// the Free Software Foundation, either version 3 of the License, or
|
|
16 /// (at your option) any later version.
|
|
17 ///
|
|
18 /// This program is distributed in the hope that it will be useful,
|
|
19 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21 /// GNU General Public License for more details.
|
|
22 ///
|
|
23 /// You should have received a copy of the GNU General Public License
|
|
24 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
25 //////////////////////////////////////////////////////////////////////////////
|
|
26 /**
|
|
27 @verbatim
|
|
28 ==============================================================================
|
|
29 ##### New characters in fonts #####
|
|
30 ==============================================================================
|
|
31 [..] Use font_tmore.c and add line to corresponding font like font_t54c
|
|
32 Don't forget to adjust the length of the font in the last line starting
|
|
33 const tFont .....
|
|
34
|
|
35 [..] last char vor der gro�en L�cke, Stand 160217
|
|
36 image_data_FontT24_0x002b[364]
|
|
37 __attribute__((at( START_T24_FONT + (1647 * 28) ))), START_T24_FONT (0x08142F00 - MINUS_BANK)
|
|
38
|
|
39 -> frei ab 0x0814E490
|
|
40 geht dann weiter mit image_data_ostc_fuer_Tauchcomputer_240px
|
|
41 sind ca. 120 kByte frei!
|
|
42
|
|
43 @endverbatim
|
|
44 ******************************************************************************
|
|
45 */
|
|
46
|
|
47 /* Includes ------------------------------------------------------------------*/
|
|
48
|
|
49 // From Common/Inc:
|
|
50 #include "FirmwareData.h"
|
|
51
|
|
52 // From Discovery/Inc
|
|
53 #include "gfx_fonts.h"
|
|
54
|
|
55 // From AC6 support:
|
|
56 #include <stdio.h>
|
|
57
|
|
58 //////////////////////////////////////////////////////////////////////////////
|
|
59
|
|
60 const SFirmwareData font_FirmwareData __attribute__(( section(".font_firmware_data") )) =
|
|
61 {
|
|
62 .versionFirst = 0,
|
|
63 .versionSecond = 9,
|
|
64 .versionThird = 0,
|
|
65 .versionBeta = 0,
|
|
66
|
|
67 /* 4 bytes, including trailing 0 */
|
|
68 .signature = "cw",
|
|
69
|
|
70 .release_year = 16,
|
|
71 .release_month = 1,
|
|
72 .release_day = 13,
|
|
73 .release_sub = 0,
|
|
74
|
|
75 /* max 48, including trailing 0 */
|
|
76 .release_info ="",
|
|
77
|
|
78 /* for safety reasons and coming functions */
|
|
79 .magic[0] = FIRMWARE_MAGIC_FIRST,
|
|
80 .magic[1] = FIRMWARE_MAGIC_SECOND,
|
|
81 .magic[2] = FIRMWARE_MAGIC_FONT, /* the magic byte for fonts*/
|
|
82 .magic[3] = FIRMWARE_MAGIC_END
|
|
83 };
|
|
84
|
|
85 //////////////////////////////////////////////////////////////////////////////
|
|
86
|
|
87 /* Fonts fixed in upper region */
|
|
88 #include "Fonts/font_awe48.h"
|
|
89 #include "Fonts/font_T24.h"
|
|
90 #include "Fonts/font_T42.h"
|
|
91 #include "Fonts/font_T48_plus.h"
|
|
92 #include "Fonts/font_T54.h"
|
|
93 #include "Fonts/font_T84.h"
|
|
94 #include "Fonts/font_T105.h"
|
|
95 #include "Fonts/font_T144_plus.h"
|
|
96
|
|
97 /* Images fixed in upper region */
|
|
98 #include "Fonts/image_battery.h"
|
|
99 #include "Fonts/image_heinrichs_weikamp.h"
|
|
100 #include "Fonts/image_ostc.h"
|
|
101
|
|
102 //////////////////////////////////////////////////////////////////////////////
|
|
103
|
|
104 static int errors = 0;
|
|
105 #define ASSERT(e) \
|
|
106 do { if( ! (e) ) {++errors; printf("FAIL at %3d: %s", __LINE__, #e);}} while(0)
|
|
107
|
|
108 #define ASSERT_RANGE(e, min, max) \
|
|
109 ASSERT(min <= e); ASSERT( e <= max)
|
|
110
|
|
111 int main(void)
|
|
112 {
|
|
113 //---- Check the linker puts the directory at the requested address ------
|
|
114 ASSERT( & Awe48 == (tFont*)0x8100000 );
|
|
115 ASSERT( & FontT24 == (tFont*)0x810000c );
|
|
116 ASSERT( & FontT42 == (tFont*)0x8100018 );
|
|
117 ASSERT( & FontT48 == (tFont*)0x8100024 );
|
|
118 ASSERT( & FontT54 == (tFont*)0x8100030 );
|
|
119 ASSERT( & FontT84 == (tFont*)0x810003c );
|
|
120 ASSERT( & FontT105 == (tFont*)0x8100048 );
|
|
121 ASSERT( & FontT144 == (tFont*)0x8100052 );
|
|
122
|
|
123 //---- Check the linker puts the font data in the requested section ------
|
|
124 extern tChar __upper_font_data;
|
|
125 extern tChar __upper_font_data_end;
|
|
126 ASSERT( &__upper_font_data == (tChar*)0x08132040 );
|
|
127 ASSERT_RANGE( (int)&__upper_font_data_end, 0x08132040, 0x081E0000);
|
|
128
|
|
129 //---- Walk through the directory data -----------------------------------
|
|
130 extern const tFont __font_directory;
|
|
131 extern const tFont __font_directory_end;
|
|
132 for(const tFont* font = & __font_directory; font < &__font_directory_end; ++font)
|
|
133 {
|
|
134 // Check END-OF-DIRECTORY magic marker
|
|
135 if( font->length == (uint32_t)-1 )
|
|
136 {
|
|
137 ASSERT( font == &FontT144 + 1 );
|
|
138 break;
|
|
139 }
|
|
140
|
|
141 // Check font descriptors are inside a safe range.
|
|
142 ASSERT_RANGE( font->length, 10, 103 );
|
|
143 ASSERT_RANGE( font->spacesize, 0, 18 );
|
|
144 ASSERT_RANGE( font->spacesize2Monospaced, 13, 72 );
|
|
145 ASSERT_RANGE( font->height, 28, 108 );
|
|
146
|
|
147 //---- Walk through each char ----------------------------------------
|
|
148 for(int i = 0; i < font->length; ++i)
|
|
149 {
|
|
150 const tChar* c = &font->chars[i];
|
|
151
|
|
152 // Check char data is indeed stored in the actual data section
|
|
153 ASSERT_RANGE( c, &__upper_font_data, &__upper_font_data_end);
|
|
154
|
|
155 // Check char data sanity
|
|
156 ASSERT_RANGE( c->code, 0x0000, 0xF143);
|
|
157
|
|
158 // Check image sanity
|
|
159 const tImage* image = c->image;
|
|
160 ASSERT_RANGE(image, (tImage*)&__upper_font_data, (tImage*)&__upper_font_data_end);
|
|
161 ASSERT_RANGE(image->width, font->spacesize, font->spacesize2Monospaced);
|
|
162 ASSERT(image->height == font->height);
|
|
163
|
|
164 // Uncompress image bytes
|
|
165 const uint8_t* byte = image->data;
|
|
166 ASSERT_RANGE(byte, (uint8_t*)&__upper_font_data, (uint8_t*)&__upper_font_data_end);
|
|
167
|
|
168 for(int w=0; w <image->width; ++w)
|
|
169 {
|
|
170 // Compression: special 0x01 byte at start of column means just skip it.
|
|
171 if( *byte++ == 0x01 )
|
|
172 continue;
|
|
173
|
|
174 int zeros = (byte[-1] == 0x00) ? 1 : 0;
|
|
175 for(int h = 1; h < image->height; ++h)
|
|
176 {
|
|
177 if( *byte == 0x00 )
|
|
178 ++zeros;
|
|
179
|
|
180 // Other bytes cannot have the 0x01 value...
|
|
181 ASSERT( *byte++ != 0x01 );
|
|
182 }
|
|
183
|
|
184 if( zeros == image->height )
|
|
185 printf("Font[%d] char[%d]: could skip column %d",
|
|
186 &__font_directory - font, i, w);
|
|
187 }
|
|
188
|
|
189 // Check the byte stream do not collide with the next char,
|
|
190 // or with the first tImage struct of the font.
|
|
191 if( (i+1) < font->length )
|
|
192 ASSERT( byte < font->chars[i+1].image->data );
|
|
193 else
|
|
194 ASSERT( byte < (uint8_t*)font->chars[0].image );
|
|
195
|
|
196 // TODO: check image bytes are contiguous between chars.
|
|
197 }
|
|
198 }
|
|
199
|
|
200 if( errors )
|
|
201 {
|
|
202 printf("Font Check: %d errors.", errors);
|
|
203 return -1;
|
|
204 }
|
|
205
|
|
206 printf("Font Check: no errors.");
|
|
207 return 0;
|
|
208 }
|
|
209
|
|
210 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/
|