TM1638 LED controller. Max 80 LEDs, Max 24 Key scan. Supports LED&KEY, QYF-TM1638 and JY-LKM1638 module.
Dependents: mbed_TM1638 Otjimaniya RL0201-V1
Font_7Seg.h
00001 /* mbed LED Font Library, for TM1638 LED Controller 00002 * Copyright (c) 2015, v01: WH, Initial version, Test in LEDKEY8 00003 * 2016, v02: WH, Added ASCII alphabet, changed fonttable into short 00004 * 2016, v03: WH, Added QYF-TM1638 and LKM1638 00005 * 00006 * Permission is hereby granted, free of charge, to any person obtaining a copy 00007 * of this software and associated documentation files (the "Software"), to deal 00008 * in the Software without restriction, including without limitation the rights 00009 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00010 * copies of the Software, and to permit persons to whom the Software is 00011 * furnished to do so, subject to the following conditions: 00012 * 00013 * The above copyright notice and this permission notice shall be included in 00014 * all copies or substantial portions of the Software. 00015 * 00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00017 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00018 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00019 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00020 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00021 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00022 * THE SOFTWARE. 00023 */ 00024 #ifndef MBED_FONT_7SEG_H 00025 #define MBED_FONT_7SEG_H 00026 00027 // Select one of the testboards for TM1638 controller 00028 #include "TM1638_Config.h" 00029 00030 #if ((LEDKEY8_TEST == 1) || (TM1638_TEST == 1)) 00031 // Segment bit positions for 7 Segment display using the LEDKEY8 mapping for TM1638 00032 // Modify this table for different 'bit-to-segment' mappings. The ASCII character defines and the FONT_7S const table below 00033 // will be adapted automatically according to the bit-to-segment mapping. Obviously this will only work when the segment 00034 // mapping is identical for every digit position. This will be the case unless the hardware designer really hates software developers. 00035 // 00036 // A 00037 // ----- 00038 // | | 00039 // F | | B 00040 // | G | 00041 // ----- 00042 // | | 00043 // E | | C 00044 // | | 00045 // ----- * DP 00046 // D 00047 // 00048 #define S7_A 0x0001 00049 #define S7_B 0x0002 00050 #define S7_C 0x0004 00051 #define S7_D 0x0008 00052 #define S7_E 0x0010 00053 #define S7_F 0x0020 00054 #define S7_G 0x0040 00055 #define S7_DP 0x0080 00056 00057 //Mask for blending out and setting 7 segments digits 00058 #define MASK_7S_ALL = (S7_A | S7_B | S7_C | S7_D | S7_E | S7_F | S7_G} 00059 00060 //Icons Grid 1 00061 #define S7_DP1 0x0080 00062 #define S7_LD1 0x0100 00063 #define S7_ICON_GR1 (S7_LD1) 00064 //#define S7_ICON_GR1 (S7_LD1 | S7_DP1) 00065 00066 //Icons Grid 2 00067 #define S7_DP2 0x0080 00068 #define S7_LD2 0x0100 00069 #define S7_ICON_GR2 (S7_LD2) 00070 //#define S7_ICON_GR2 (S7_LD2 | S7_DP2) 00071 00072 //Icons Grid 3 00073 #define S7_DP3 0x0080 00074 #define S7_LD3 0x0100 00075 #define S7_ICON_GR3 (S7_LD3) 00076 //#define S7_ICON_GR3 (S7_LD3 | S7_DP3) 00077 00078 //Icons Grid 4 00079 #define S7_DP4 0x0080 00080 #define S7_LD4 0x0100 00081 #define S7_ICON_GR4 (S7_LD4) 00082 //#define S7_ICON_GR4 (S7_LD4 | S7_DP4) 00083 00084 //Icons Grid 5 00085 #define S7_DP5 0x0080 00086 #define S7_LD5 0x0100 00087 #define S7_ICON_GR5 (S7_LD5) 00088 //#define S7_ICON_GR5 (S7_LD5 | S7_DP5) 00089 00090 //Icons Grid 6 00091 #define S7_DP6 0x0080 00092 #define S7_LD6 0x0100 00093 #define S7_ICON_GR6 (S7_LD6) 00094 //#define S7_ICON_GR6 (S7_LD6 | S7_DP6) 00095 00096 //Icons Grid 7 00097 #define S7_DP7 0x0080 00098 #define S7_LD7 0x0100 00099 #define S7_ICON_GR7 (S7_LD7) 00100 //#define S7_ICON_GR7 (S7_LD7 | S7_DP7) 00101 00102 //Icons Grid 8 00103 #define S7_DP8 0x0080 00104 #define S7_LD8 0x0100 00105 #define S7_ICON_GR8 (S7_LD8) 00106 //#define S7_ICON_GR8 (S7_LD8 | S7_DP8) 00107 00108 00109 //Mask for blending out and restoring Icons 00110 extern const char MASK_ICON_GRID[][2]; 00111 #endif 00112 00113 #if (QYF_TEST == 1) 00114 // Segment bit positions for 7 Segment display using the QYF mapping for TM1638 00115 // This display module uses a single byte of each grid to drive a specific segment of all digits. 00116 // So the bits in byte 0 (Grid 1) drive all A-segments, the bits in byte 2 (Grid 2) drive all B-segments etc. 00117 // Bit0 is for the segment in Digit 8, Bit1 is for the segment in Digit 7 etc.. This bit manipulation is handled in _putc(). 00118 // 00119 // The ASCII character defines and the FONT_7S const table below will be adapted automatically according to the bit-to-segment mapping. 00120 // 00121 // A 00122 // ----- 00123 // | | 00124 // F | | B 00125 // | G | 00126 // ----- 00127 // | | 00128 // E | | C 00129 // | | 00130 // ----- * DP 00131 // D 00132 // 00133 //Generic segment placeholders 00134 #define S7_A 0x0001 00135 #define S7_B 0x0002 00136 #define S7_C 0x0004 00137 #define S7_D 0x0008 00138 #define S7_E 0x0010 00139 #define S7_F 0x0020 00140 #define S7_G 0x0040 00141 #define S7_DP 0x0080 00142 00143 //Mask for blending out and setting 7 segments digits 00144 //#define MASK_7S_ALL = (S7_A | S7_B | S7_C | S7_D | S7_E | S7_F | S7_G} 00145 00146 //Segments and Icons Grid 1 00147 #define S7_A1 0x0080 00148 #define S7_B1 0x0080 00149 #define S7_C1 0x0080 00150 #define S7_D1 0x0080 00151 #define S7_E1 0x0080 00152 #define S7_F1 0x0080 00153 #define S7_G1 0x0080 00154 #define S7_DP1 0x0080 00155 #define S7_ICON_GR1 (0x0000) 00156 00157 //Segments and Icons Grid 2 00158 #define S7_A2 0x0040 00159 #define S7_B2 0x0040 00160 #define S7_C2 0x0040 00161 #define S7_D2 0x0040 00162 #define S7_E2 0x0040 00163 #define S7_F2 0x0040 00164 #define S7_G2 0x0040 00165 #define S7_DP2 0x0040 00166 #define S7_ICON_GR2 (0x0000) 00167 00168 //Segments and Icons Grid 3 00169 #define S7_A3 0x0020 00170 #define S7_B3 0x0020 00171 #define S7_C3 0x0020 00172 #define S7_D3 0x0020 00173 #define S7_E3 0x0020 00174 #define S7_F3 0x0020 00175 #define S7_G3 0x0020 00176 #define S7_DP3 0x0020 00177 #define S7_ICON_GR3 (0x0000) 00178 00179 //Segments and Icons Grid 4 00180 #define S7_A4 0x0010 00181 #define S7_B4 0x0010 00182 #define S7_C4 0x0010 00183 #define S7_D4 0x0010 00184 #define S7_E4 0x0010 00185 #define S7_F4 0x0010 00186 #define S7_G4 0x0010 00187 #define S7_DP4 0x0010 00188 #define S7_ICON_GR4 (0x0000) 00189 00190 //Segments and Icons Grid 5 00191 #define S7_A5 0x0008 00192 #define S7_B5 0x0008 00193 #define S7_C5 0x0008 00194 #define S7_D5 0x0008 00195 #define S7_E5 0x0008 00196 #define S7_F5 0x0008 00197 #define S7_G5 0x0008 00198 #define S7_DP5 0x0008 00199 #define S7_ICON_GR5 (0x0000) 00200 00201 //Segments and Icons Grid 6 00202 #define S7_A6 0x0004 00203 #define S7_B6 0x0004 00204 #define S7_C6 0x0004 00205 #define S7_D6 0x0004 00206 #define S7_E6 0x0004 00207 #define S7_F6 0x0004 00208 #define S7_G6 0x0004 00209 #define S7_DP6 0x0004 00210 #define S7_ICON_GR6 (0x0000) 00211 00212 //Segments and Icons Grid 7 00213 #define S7_A7 0x0002 00214 #define S7_B7 0x0002 00215 #define S7_C7 0x0002 00216 #define S7_D7 0x0002 00217 #define S7_E7 0x0002 00218 #define S7_F7 0x0002 00219 #define S7_G7 0x0002 00220 #define S7_DP7 0x0002 00221 #define S7_ICON_GR7 (0x0000) 00222 00223 //Segments and Icons Grid 8 00224 #define S7_A8 0x0001 00225 #define S7_B8 0x0001 00226 #define S7_C8 0x0001 00227 #define S7_D8 0x0001 00228 #define S7_E8 0x0001 00229 #define S7_F8 0x0001 00230 #define S7_G8 0x0001 00231 #define S7_DP8 0x0001 00232 #define S7_ICON_GR8 (0x0000) 00233 00234 //Mask for blending out and restoring Icons 00235 extern const char MASK_ICON_GRID[][2]; 00236 #endif 00237 00238 #if (LKM1638_TEST == 1) 00239 // Segment bit positions for 7 Segment display using the LKM1638 mapping for TM1638 00240 // Modify this table for different 'bit-to-segment' mappings. The ASCII character defines and the FONT_7S const table below 00241 // will be adapted automatically according to the bit-to-segment mapping. Obviously this will only work when the segment 00242 // mapping is identical for every digit position. This will be the case unless the hardware designer really hates software developers. 00243 // 00244 // The ASCII character defines and the FONT_7S const table below will be adapted automatically according to the bit-to-segment mapping. 00245 // 00246 // A 00247 // ----- 00248 // | | 00249 // F | | B 00250 // | G | 00251 // ----- 00252 // | | 00253 // E | | C 00254 // | | 00255 // ----- * DP 00256 // D 00257 // 00258 //Generic segment placeholders 00259 #define S7_A 0x0001 00260 #define S7_B 0x0002 00261 #define S7_C 0x0004 00262 #define S7_D 0x0008 00263 #define S7_E 0x0010 00264 #define S7_F 0x0020 00265 #define S7_G 0x0040 00266 #define S7_DP 0x0080 00267 00268 //Mask for blending out and setting 7 segments digits 00269 //#define MASK_7S_ALL = (S7_A | S7_B | S7_C | S7_D | S7_E | S7_F | S7_G} 00270 00271 //Icons Grid 1 00272 #define S7_DP1 0x0080 00273 #define S7_GR1 0x0100 00274 #define S7_RD1 0x0200 00275 #define S7_YL1 0x0300 00276 #define S7_ICON_GR1 (S7_RD1 | S7_GR1 | S7_YL1) 00277 //#define S7_ICON_GR1 (S7_RD1 | S7_GR1 | S7_YL1 | S7_DP1) 00278 00279 //Icons Grid 2 00280 #define S7_DP2 0x0080 00281 #define S7_GR2 0x0100 00282 #define S7_RD2 0x0200 00283 #define S7_YL2 0x0300 00284 #define S7_ICON_GR2 (S7_RD2 | S7_GR2 | S7_YL2) 00285 //#define S7_ICON_GR2 (S7_RD2 | S7_GR2 | S7_YL2 | S7_DP2) 00286 00287 //Icons Grid 3 00288 #define S7_DP3 0x0080 00289 #define S7_GR3 0x0100 00290 #define S7_RD3 0x0200 00291 #define S7_YL3 0x0300 00292 #define S7_ICON_GR3 (S7_RD3 | S7_GR3 | S7_YL3) 00293 //#define S7_ICON_GR3 (S7_RD3 | S7_GR3 | S7_YL3 | S7_DP3) 00294 00295 //Icons Grid 4 00296 #define S7_DP4 0x0080 00297 #define S7_GR4 0x0100 00298 #define S7_RD4 0x0200 00299 #define S7_YL4 0x0300 00300 #define S7_ICON_GR4 (S7_RD4 | S7_GR4 | S7_YL4) 00301 //#define S7_ICON_GR4 (S7_RD4 | S7_GR4 | S7_YL4 | S7_DP4) 00302 00303 //Icons Grid 5 00304 #define S7_DP5 0x0080 00305 #define S7_GR5 0x0100 00306 #define S7_RD5 0x0200 00307 #define S7_YL5 0x0300 00308 #define S7_ICON_GR5 (S7_RD5 | S7_GR5 | S7_YL5) 00309 //#define S7_ICON_GR5 (S7_RD5 | S7_GR5 | S7_YL5 | S7_DP5) 00310 00311 //Icons Grid 6 00312 #define S7_DP6 0x0080 00313 #define S7_GR6 0x0100 00314 #define S7_RD6 0x0200 00315 #define S7_YL6 0x0300 00316 #define S7_ICON_GR6 (S7_RD6 | S7_GR6 | S7_YL6) 00317 //#define S7_ICON_GR6 (S7_RD6 | S7_GR6 | S7_YL6 | S7_DP6) 00318 00319 //Icons Grid 7 00320 #define S7_DP7 0x0080 00321 #define S7_GR7 0x0100 00322 #define S7_RD7 0x0200 00323 #define S7_YL7 0x0300 00324 #define S7_ICON_GR7 (S7_RD7 | S7_GR7 | S7_YL7) 00325 //#define S7_ICON_GR7 (S7_RD7 | S7_GR7 | S7_YL7 | S7_DP7) 00326 00327 //Icons Grid 8 00328 #define S7_DP8 0x0080 00329 #define S7_GR8 0x0100 00330 #define S7_RD8 0x0200 00331 #define S7_YL8 0x0300 00332 #define S7_ICON_GR8 (S7_RD8 | S7_GR8 | S7_YL8) 00333 //#define S7_ICON_GR8 (S7_RD8 | S7_GR8 | S7_YL8 | S7_DP8) 00334 00335 //Mask for blending out and restoring Icons 00336 extern const char MASK_ICON_GRID[][2]; 00337 #endif 00338 00339 // ASCII Font definitions for segments in each character 00340 // 00341 //32 0x20 Symbols 00342 #define C7_SPC (0x0000) 00343 #define C7_EXC (S7_B | S7_C) //! 00344 #define C7_QTE (S7_B | S7_F) //" 00345 #define C7_HSH (S7_C | S7_D | S7_E | S7_G) //# 00346 #define C7_DLR (S7_A | S7_C | S7_D | S7_F | S7_G) //$ 00347 #define C7_PCT (S7_C | S7_F) //% 00348 #define C7_AMP (S7_A | S7_C | S7_D | S7_E | S7_F | S7_G) //& 00349 #define C7_ACC (S7_B) //' 00350 #define C7_LBR (S7_A | S7_D | S7_E | S7_F) //( 00351 #define C7_RBR (S7_A | S7_B | S7_C | S7_D) //) 00352 #define C7_MLT (S7_B | S7_C | S7_E | S7_F | S7_G) //* 00353 #define C7_PLS (S7_B | S7_C | S7_G) //+ 00354 #define C7_CMA (S7_DP) 00355 #define C7_MIN (S7_G) 00356 #define C7_DPT (S7_DP) 00357 #define C7_RS (S7_B | S7_E | S7_G) // / 00358 00359 //48 0x30 Digits 00360 #define C7_0 (S7_A | S7_B | S7_C | S7_D | S7_E | S7_F) 00361 #define C7_1 (S7_B | S7_C) 00362 #define C7_2 (S7_A | S7_B | S7_D | S7_E | S7_G) 00363 #define C7_3 (S7_A | S7_B | S7_C | S7_D | S7_G) 00364 #define C7_4 (S7_B | S7_C | S7_F | S7_G) 00365 #define C7_5 (S7_A | S7_C | S7_D | S7_F | S7_G) 00366 #define C7_6 (S7_A | S7_C | S7_D | S7_E | S7_F | S7_G) 00367 #define C7_7 (S7_A | S7_B | S7_C) 00368 #define C7_8 (S7_A | S7_B | S7_C | S7_D | S7_E | S7_F | S7_G) 00369 #define C7_9 (S7_A | S7_B | S7_C | S7_D | S7_F | S7_G) 00370 00371 //58 0x3A 00372 #define C7_COL (S7_D | S7_G) // : 00373 #define C7_SCL (S7_D | S7_G) // ; 00374 #define C7_LT (S7_D | S7_E | S7_G) // < 00375 #define C7_EQ (S7_D | S7_G) // = 00376 #define C7_GT (S7_C | S7_D | S7_G) // > 00377 #define C7_QM (S7_A | S7_B | S7_E | S7_G) // ? 00378 #define C7_AT (S7_A | S7_B | S7_C | S7_D | S7_E | S7_G) // @ 00379 00380 //65 0x41 Upper case alphabet 00381 #define C7_A (S7_A | S7_B | S7_C | S7_E | S7_F | S7_G ) 00382 #define C7_B (S7_C | S7_D | S7_E | S7_F | S7_G) 00383 #define C7_C (S7_A | S7_D | S7_E | S7_F) 00384 #define C7_D (S7_B | S7_C | S7_D | S7_E | S7_G) 00385 #define C7_E (S7_A | S7_D | S7_E | S7_F | S7_G) 00386 #define C7_F (S7_A | S7_E | S7_F | S7_G) 00387 00388 #define C7_G (S7_A | S7_C | S7_D | S7_E | S7_F) 00389 #define C7_H (S7_B | S7_C | S7_E | S7_F | S7_G) 00390 #define C7_I (S7_B | S7_C) 00391 #define C7_J (S7_B | S7_C | S7_D | S7_E) 00392 #define C7_K (S7_B | S7_C | S7_E | S7_F | S7_G) 00393 #define C7_L (S7_D | S7_E | S7_F) 00394 #define C7_M (S7_A | S7_C | S7_E) 00395 #define C7_N (S7_A | S7_B | S7_C | S7_E | S7_F) 00396 #define C7_O (S7_A | S7_B | S7_C | S7_D | S7_E | S7_F) 00397 #define C7_P (S7_A | S7_B | S7_E | S7_F | S7_G) 00398 #define C7_Q (S7_A | S7_B | S7_C | S7_F | S7_G) 00399 #define C7_R (S7_E | S7_G ) 00400 #define C7_S (S7_A | S7_C | S7_D | S7_F | S7_G) 00401 #define C7_T (S7_D | S7_E | S7_F | S7_G) 00402 #define C7_U (S7_B | S7_C | S7_D | S7_E | S7_F) 00403 #define C7_V (S7_B | S7_C | S7_D | S7_E | S7_F) 00404 #define C7_W (S7_B | S7_D | S7_F) 00405 #define C7_X (S7_B | S7_C | S7_E | S7_F | S7_G) 00406 #define C7_Y (S7_B | S7_C | S7_D | S7_F | S7_G) 00407 #define C7_Z (S7_A | S7_B | S7_D | S7_E | S7_G) 00408 00409 //91 0x5B 00410 #define C7_SBL (S7_A | S7_D | S7_E | S7_F) // [ 00411 #define C7_LS (S7_C | S7_F | S7_G) // left slash 00412 #define C7_SBR (S7_A | S7_B | S7_C | S7_D) // ] 00413 #define C7_PWR (S7_A | S7_B | S7_F) // ^ 00414 #define C7_UDS (S7_D) // _ 00415 #define C7_DSH (S7_F) // ` 00416 00417 //97 0x61 Lower case alphabet 00418 #define C7_a C7_A 00419 #define C7_b C7_B 00420 #define C7_c C7_C 00421 #define C7_d C7_D 00422 #define C7_e C7_E 00423 #define C7_f C7_H 00424 00425 #define C7_g C7_G 00426 #define C7_h C7_H 00427 #define C7_i C7_I 00428 #define C7_j C7_J 00429 #define C7_k C7_K 00430 #define C7_l C7_L 00431 #define C7_m C7_M 00432 //#define C7_n C7_N 00433 #define C7_n (S7_C | S7_E | S7_G) 00434 //#define C7_o C7_O 00435 #define C7_o (S7_C | S7_D | S7_E | S7_G) 00436 #define C7_p C7_P 00437 #define C7_q C7_Q 00438 //#define C7_r C7_R 00439 #define C7_r (S7_E | S7_G) 00440 #define C7_s C7_S 00441 #define C7_t C7_T 00442 #define C7_u C7_U 00443 #define C7_v C7_V 00444 #define C7_w C7_W 00445 #define C7_x C7_X 00446 #define C7_y C7_Y 00447 #define C7_z C7_Z 00448 00449 //123 0x7B 00450 #define C7_CBL (S7_A | S7_D | S7_E | S7_F) // { 00451 #define C7_OR (S7_B | S7_C) // | 00452 #define C7_CBR (S7_A | S7_B | S7_C | S7_D) // } 00453 #define C7_TLD (S7_B | S7_E | S7_G ) // ~ 00454 #define C7_DEL (0x0000) 00455 00456 00457 //User Defined Characters (some examples) 00458 #define C7_DGR (S7_A | S7_B | S7_F | S7_G) //Degrees 00459 00460 // Font data selection for transmission to TM1638 memory 00461 #define LO(x) ( x & 0xFF) 00462 #define HI(x) ((x >> 8) & 0xFF) 00463 00464 00465 // ASCII Font definition table 00466 // 00467 #define FONT_7S_START 0x20 00468 #define FONT_7S_END 0x7F 00469 //#define FONT_7S_NR_CHARS (FONT_7S_END - FONT_7S_START + 1) 00470 extern const short FONT_7S[]; 00471 00472 #endif
Generated on Tue Jul 12 2022 19:03:47 by 1.7.2