Mercurial > public > ostc4
annotate FontPack/base_upperRegion.c @ 28:7eabbb5b30ac
... Fighting with internal oscillator.
author | JeanDo |
---|---|
date | Wed, 10 Jan 2018 19:59:50 +0100 |
parents | 97eafbcb81a9 |
children | ea1003f63e44 |
rev | line source |
---|---|
16 | 1 /** |
2 ****************************************************************************** | |
3 * @copyright heinrichs weikamp | |
4 * @file base_upperRegion.c | |
5 * @author heinrichs/weikamp, Christian Weikamp | |
6 * @date 31-August-2015 | |
7 * @version V0.0.3 | |
8 * @since 03-Dez-2016 | |
9 * @brief The beginning of it all. main() is part of this. | |
10 * @bug | |
11 * @warning | |
12 @verbatim | |
13 ============================================================================== | |
14 ##### New characters in fonts ##### | |
15 ============================================================================== | |
16 [..] Use font_tmore.c and add line to corresponding font like font_t54c | |
17 Don't forget to adjust the length of the font in the last line starting | |
18 const tFont ..... | |
19 | |
21 | 20 [..] last char vor der gro�en L�cke, Stand 160217 |
16 | 21 image_data_FontT24_0x002b[364] |
22 __attribute__((at( START_T24_FONT + (1647 * 28) ))), START_T24_FONT (0x08142F00 - MINUS_BANK) | |
23 | |
24 -> frei ab 0x0814E490 | |
25 geht dann weiter mit image_data_ostc_fuer_Tauchcomputer_240px | |
26 sind ca. 120 kByte frei! | |
27 | |
28 @endverbatim | |
29 ****************************************************************************** | |
30 * @attention | |
31 * | |
32 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> | |
33 * | |
34 ****************************************************************************** | |
35 */ | |
36 | |
37 /* Includes ------------------------------------------------------------------*/ | |
21 | 38 |
24
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
39 // From Common/Inc: |
21 | 40 #include "FirmwareData.h" |
24
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
41 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
42 // From Discovery/Inc |
21 | 43 #include "gfx_fonts.h" |
16 | 44 |
24
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
45 // From AC6 support: |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
46 #include <stdio.h> |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
47 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
48 ////////////////////////////////////////////////////////////////////////////// |
16 | 49 |
25
97eafbcb81a9
FIX move bootloader SFirmwareData at fixed address 0x0800A000
jdg@air
parents:
24
diff
changeset
|
50 const SFirmwareData font_FirmwareData __attribute__(( section(".font_firmware_data") )) = |
16 | 51 { |
21 | 52 .versionFirst = 0, |
53 .versionSecond = 9, | |
54 .versionThird = 0, | |
55 .versionBeta = 0, | |
56 | |
57 /* 4 bytes, including trailing 0 */ | |
58 .signature = "cw", | |
16 | 59 |
21 | 60 .release_year = 16, |
61 .release_month = 1, | |
62 .release_day = 13, | |
63 .release_sub = 0, | |
16 | 64 |
21 | 65 /* max 48, including trailing 0 */ |
66 .release_info ="", | |
16 | 67 |
21 | 68 /* for safety reasons and coming functions */ |
69 .magic[0] = FIRMWARE_MAGIC_FIRST, | |
70 .magic[1] = FIRMWARE_MAGIC_SECOND, | |
71 .magic[2] = FIRMWARE_MAGIC_FONT, /* the magic byte for fonts*/ | |
72 .magic[3] = FIRMWARE_MAGIC_END | |
16 | 73 }; |
74 | |
24
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
75 ////////////////////////////////////////////////////////////////////////////// |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
76 |
21 | 77 /* Fonts fixed in upper region */ |
78 #include "Fonts/font_awe48.h" | |
79 #include "Fonts/font_T24.h" | |
80 #include "Fonts/font_T42.h" | |
81 #include "Fonts/font_T48_plus.h" | |
82 #include "Fonts/font_T54.h" | |
83 #include "Fonts/font_T84.h" | |
84 #include "Fonts/font_T105.h" | |
85 #include "Fonts/font_T144_plus.h" | |
16 | 86 |
21 | 87 /* Images fixed in upper region */ |
88 #include "Fonts/image_battery.h" | |
89 #include "Fonts/image_heinrichs_weikamp.h" | |
90 #include "Fonts/image_ostc.h" | |
16 | 91 |
24
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
92 ////////////////////////////////////////////////////////////////////////////// |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
93 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
94 static int errors = 0; |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
95 #define ASSERT(e) \ |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
96 do { if( ! (e) ) {++errors; printf("FAIL at %3d: %s", __LINE__, #e);}} while(0) |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
97 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
98 #define ASSERT_RANGE(e, min, max) \ |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
99 ASSERT(min <= e); ASSERT( e <= max) |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
100 |
21 | 101 int main(void) |
16 | 102 { |
24
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
103 //---- Check the linker puts the directory at the requested address ------ |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
104 ASSERT( & Awe48 == (tFont*)0x8100000 ); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
105 ASSERT( & FontT24 == (tFont*)0x810000c ); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
106 ASSERT( & FontT42 == (tFont*)0x8100018 ); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
107 ASSERT( & FontT48 == (tFont*)0x8100024 ); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
108 ASSERT( & FontT54 == (tFont*)0x8100030 ); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
109 ASSERT( & FontT84 == (tFont*)0x810003c ); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
110 ASSERT( & FontT105 == (tFont*)0x8100048 ); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
111 ASSERT( & FontT144 == (tFont*)0x8100052 ); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
112 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
113 //---- Check the linker puts the font data in the requested section ------ |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
114 extern tChar __upper_font_data; |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
115 extern tChar __upper_font_data_end; |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
116 ASSERT( &__upper_font_data == (tChar*)0x08132040 ); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
117 ASSERT_RANGE( (int)&__upper_font_data_end, 0x08132040, 0x081E0000); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
118 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
119 //---- Walk through the directory data ----------------------------------- |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
120 extern const tFont __font_directory; |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
121 extern const tFont __font_directory_end; |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
122 for(const tFont* font = & __font_directory; font < &__font_directory_end; ++font) |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
123 { |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
124 // Check END-OF-DIRECTORY magic marker |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
125 if( font->length == (uint32_t)-1 ) |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
126 { |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
127 ASSERT( font == &FontT144 + 1 ); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
128 break; |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
129 } |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
130 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
131 // Check font descriptors are inside a safe range. |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
132 ASSERT_RANGE( font->length, 10, 103 ); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
133 ASSERT_RANGE( font->spacesize, 0, 18 ); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
134 ASSERT_RANGE( font->spacesize2Monospaced, 13, 72 ); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
135 ASSERT_RANGE( font->height, 28, 108 ); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
136 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
137 //---- Walk through each char ---------------------------------------- |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
138 for(int i = 0; i < font->length; ++i) |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
139 { |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
140 const tChar* c = &font->chars[i]; |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
141 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
142 // Check char data is indeed stored in the actual data section |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
143 ASSERT_RANGE( c, &__upper_font_data, &__upper_font_data_end); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
144 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
145 // Check char data sanity |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
146 ASSERT_RANGE( c->code, 0x0000, 0xF143); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
147 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
148 // Check image sanity |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
149 const tImage* image = c->image; |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
150 ASSERT_RANGE(image, (tImage*)&__upper_font_data, (tImage*)&__upper_font_data_end); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
151 ASSERT_RANGE(image->width, font->spacesize, font->spacesize2Monospaced); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
152 ASSERT(image->height == font->height); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
153 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
154 // Uncompress image bytes |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
155 const uint8_t* byte = image->data; |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
156 ASSERT_RANGE(byte, (uint8_t*)&__upper_font_data, (uint8_t*)&__upper_font_data_end); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
157 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
158 for(int w=0; w <image->width; ++w) |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
159 { |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
160 // Compression: special 0x01 byte at start of column means just skip it. |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
161 if( *byte++ == 0x01 ) |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
162 continue; |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
163 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
164 int zeros = (byte[-1] == 0x00) ? 1 : 0; |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
165 for(int h = 1; h < image->height; ++h) |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
166 { |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
167 if( *byte == 0x00 ) |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
168 ++zeros; |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
169 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
170 // Other bytes cannot have the 0x01 value... |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
171 ASSERT( *byte++ != 0x01 ); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
172 } |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
173 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
174 if( zeros == image->height ) |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
175 printf("Font[%d] char[%d]: could skip column %d", |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
176 &__font_directory - font, i, w); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
177 } |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
178 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
179 // Check the byte stream do not collide with the next char, |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
180 // or with the first tImage struct of the font. |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
181 if( (i+1) < font->length ) |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
182 ASSERT( byte < font->chars[i+1].image->data ); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
183 else |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
184 ASSERT( byte < (uint8_t*)font->chars[0].image ); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
185 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
186 // TODO: check image bytes are contiguous between chars. |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
187 } |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
188 } |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
189 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
190 if( errors ) |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
191 { |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
192 printf("Font Check: %d errors.", errors); |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
193 return -1; |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
194 } |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
195 |
4de447ee5d1b
ADD font check code that runs at FontPack installation.
JeanDo
parents:
22
diff
changeset
|
196 printf("Font Check: no errors."); |
21 | 197 return 0; |
16 | 198 } |
199 | |
200 /************************ (C) COPYRIGHT heinrichs weikamp *****END OF FILE****/ |