Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: ADXL345Test ADXL345Test1
Fork of TM1638 by
Font_7Seg.cpp@2:532ce15ea9ec, 2016-01-15 (annotated)
- Committer:
- wim
- Date:
- Fri Jan 15 19:09:59 2016 +0000
- Revision:
- 2:532ce15ea9ec
- Parent:
- 1:1f2453ed85d7
- Child:
- 4:b2bbdc58967e
Refactored display and keyboard defines, added ASCII font.
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| wim | 0:201dfacbe0e5 | 1 | /* mbed LED Font Library, for TM1638 LED controller | 
| wim | 0:201dfacbe0e5 | 2 | * Copyright (c) 2015, v01: WH, Initial version, Test in LEDKEY8 | 
| wim | 2:532ce15ea9ec | 3 | * 2016, v02: WH, Added ASCII alphabet, changed fonttable into short | 
| wim | 0:201dfacbe0e5 | 4 | * | 
| wim | 0:201dfacbe0e5 | 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy | 
| wim | 0:201dfacbe0e5 | 6 | * of this software and associated documentation files (the "Software"), to deal | 
| wim | 0:201dfacbe0e5 | 7 | * in the Software without restriction, including without limitation the rights | 
| wim | 0:201dfacbe0e5 | 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 
| wim | 0:201dfacbe0e5 | 9 | * copies of the Software, and to permit persons to whom the Software is | 
| wim | 0:201dfacbe0e5 | 10 | * furnished to do so, subject to the following conditions: | 
| wim | 0:201dfacbe0e5 | 11 | * | 
| wim | 0:201dfacbe0e5 | 12 | * The above copyright notice and this permission notice shall be included in | 
| wim | 0:201dfacbe0e5 | 13 | * all copies or substantial portions of the Software. | 
| wim | 0:201dfacbe0e5 | 14 | * | 
| wim | 0:201dfacbe0e5 | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
| wim | 0:201dfacbe0e5 | 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
| wim | 0:201dfacbe0e5 | 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 
| wim | 0:201dfacbe0e5 | 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
| wim | 0:201dfacbe0e5 | 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 
| wim | 0:201dfacbe0e5 | 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 
| wim | 0:201dfacbe0e5 | 21 | * THE SOFTWARE. | 
| wim | 0:201dfacbe0e5 | 22 | */ | 
| wim | 0:201dfacbe0e5 | 23 | #include "Font_7Seg.h" | 
| wim | 0:201dfacbe0e5 | 24 | |
| wim | 0:201dfacbe0e5 | 25 | // Select one of the testboards for TM1638 LED controller | 
| wim | 0:201dfacbe0e5 | 26 | #if (LEDKEY8_TEST == 1) | 
| wim | 0:201dfacbe0e5 | 27 | |
| wim | 0:201dfacbe0e5 | 28 | //Mask for blending out and restoring Icons | 
| wim | 0:201dfacbe0e5 | 29 | const char MASK_ICON_GRID[][2] = { | 
| wim | 0:201dfacbe0e5 | 30 | {LO(S7_ICON_GR1), HI(S7_ICON_GR1)}, | 
| wim | 0:201dfacbe0e5 | 31 | {LO(S7_ICON_GR2), HI(S7_ICON_GR2)}, | 
| wim | 0:201dfacbe0e5 | 32 | {LO(S7_ICON_GR3), HI(S7_ICON_GR3)}, | 
| wim | 0:201dfacbe0e5 | 33 | {LO(S7_ICON_GR4), HI(S7_ICON_GR4)}, | 
| wim | 0:201dfacbe0e5 | 34 | {LO(S7_ICON_GR5), HI(S7_ICON_GR5)}, | 
| wim | 0:201dfacbe0e5 | 35 | {LO(S7_ICON_GR6), HI(S7_ICON_GR6)}, | 
| wim | 0:201dfacbe0e5 | 36 | {LO(S7_ICON_GR7), HI(S7_ICON_GR7)}, | 
| wim | 2:532ce15ea9ec | 37 | {LO(S7_ICON_GR8), HI(S7_ICON_GR8)} | 
| wim | 0:201dfacbe0e5 | 38 | }; | 
| wim | 0:201dfacbe0e5 | 39 | |
| wim | 0:201dfacbe0e5 | 40 | // ASCII Font definition table for transmission to TM1638 | 
| wim | 0:201dfacbe0e5 | 41 | // | 
| wim | 0:201dfacbe0e5 | 42 | //#define FONT_7S_START 0x20 | 
| wim | 0:201dfacbe0e5 | 43 | //#define FONT_7S_END 0x7F | 
| wim | 0:201dfacbe0e5 | 44 | //#define FONT_7S_NR_CHARS (FONT_7_END - FONT_7S_START + 1) | 
| wim | 2:532ce15ea9ec | 45 | |
| wim | 2:532ce15ea9ec | 46 | #if (SHOW_ASCII == 1) | 
| wim | 2:532ce15ea9ec | 47 | //display all ASCII characters | 
| wim | 2:532ce15ea9ec | 48 | const short FONT_7S[] = { | 
| wim | 2:532ce15ea9ec | 49 | C7_SPC, //32 0x20, Space | 
| wim | 2:532ce15ea9ec | 50 | C7_EXC, | 
| wim | 2:532ce15ea9ec | 51 | C7_QTE, | 
| wim | 2:532ce15ea9ec | 52 | C7_HSH, | 
| wim | 2:532ce15ea9ec | 53 | C7_DLR, | 
| wim | 2:532ce15ea9ec | 54 | C7_PCT, | 
| wim | 2:532ce15ea9ec | 55 | C7_AMP, | 
| wim | 2:532ce15ea9ec | 56 | C7_ACC, | 
| wim | 2:532ce15ea9ec | 57 | C7_LBR, | 
| wim | 2:532ce15ea9ec | 58 | C7_RBR, | 
| wim | 2:532ce15ea9ec | 59 | C7_MLT, | 
| wim | 2:532ce15ea9ec | 60 | C7_PLS, | 
| wim | 2:532ce15ea9ec | 61 | C7_CMA, | 
| wim | 2:532ce15ea9ec | 62 | C7_MIN, | 
| wim | 2:532ce15ea9ec | 63 | C7_DPT, | 
| wim | 2:532ce15ea9ec | 64 | C7_RS, | 
| wim | 2:532ce15ea9ec | 65 | C7_0, //48 0x30 | 
| wim | 2:532ce15ea9ec | 66 | C7_1, | 
| wim | 2:532ce15ea9ec | 67 | C7_2, | 
| wim | 2:532ce15ea9ec | 68 | C7_3, | 
| wim | 2:532ce15ea9ec | 69 | C7_4, | 
| wim | 2:532ce15ea9ec | 70 | C7_5, | 
| wim | 2:532ce15ea9ec | 71 | C7_6, | 
| wim | 2:532ce15ea9ec | 72 | C7_7, | 
| wim | 2:532ce15ea9ec | 73 | C7_8, | 
| wim | 2:532ce15ea9ec | 74 | C7_9, | 
| wim | 2:532ce15ea9ec | 75 | C7_COL, //58 0x3A | 
| wim | 2:532ce15ea9ec | 76 | C7_SCL, | 
| wim | 2:532ce15ea9ec | 77 | C7_LT, | 
| wim | 2:532ce15ea9ec | 78 | C7_EQ, | 
| wim | 2:532ce15ea9ec | 79 | C7_GT, | 
| wim | 2:532ce15ea9ec | 80 | C7_QM, | 
| wim | 2:532ce15ea9ec | 81 | C7_AT, //64 0x40 | 
| wim | 2:532ce15ea9ec | 82 | C7_A, //65 0x41, A | 
| wim | 2:532ce15ea9ec | 83 | C7_B, | 
| wim | 2:532ce15ea9ec | 84 | C7_C, | 
| wim | 2:532ce15ea9ec | 85 | C7_D, | 
| wim | 2:532ce15ea9ec | 86 | C7_E, | 
| wim | 2:532ce15ea9ec | 87 | C7_F, | 
| wim | 2:532ce15ea9ec | 88 | C7_G, | 
| wim | 2:532ce15ea9ec | 89 | C7_H, | 
| wim | 2:532ce15ea9ec | 90 | C7_I, | 
| wim | 2:532ce15ea9ec | 91 | C7_J, | 
| wim | 2:532ce15ea9ec | 92 | C7_K, | 
| wim | 2:532ce15ea9ec | 93 | C7_L, | 
| wim | 2:532ce15ea9ec | 94 | C7_M, | 
| wim | 2:532ce15ea9ec | 95 | C7_N, | 
| wim | 2:532ce15ea9ec | 96 | C7_O, | 
| wim | 2:532ce15ea9ec | 97 | C7_P, | 
| wim | 2:532ce15ea9ec | 98 | C7_Q, | 
| wim | 2:532ce15ea9ec | 99 | C7_R, | 
| wim | 2:532ce15ea9ec | 100 | C7_S, | 
| wim | 2:532ce15ea9ec | 101 | C7_T, | 
| wim | 2:532ce15ea9ec | 102 | C7_U, | 
| wim | 2:532ce15ea9ec | 103 | C7_V, | 
| wim | 2:532ce15ea9ec | 104 | C7_W, | 
| wim | 2:532ce15ea9ec | 105 | C7_X, | 
| wim | 2:532ce15ea9ec | 106 | C7_Y, | 
| wim | 2:532ce15ea9ec | 107 | C7_Z, //90 0x5A, Z | 
| wim | 2:532ce15ea9ec | 108 | C7_SBL, //91 0x5B | 
| wim | 2:532ce15ea9ec | 109 | C7_LS, | 
| wim | 2:532ce15ea9ec | 110 | C7_SBR, | 
| wim | 2:532ce15ea9ec | 111 | C7_PWR, | 
| wim | 2:532ce15ea9ec | 112 | C7_UDS, | 
| wim | 2:532ce15ea9ec | 113 | C7_ACC, | 
| wim | 2:532ce15ea9ec | 114 | C7_A, //97 0x61, A replacing a | 
| wim | 2:532ce15ea9ec | 115 | C7_B, | 
| wim | 2:532ce15ea9ec | 116 | C7_C, | 
| wim | 2:532ce15ea9ec | 117 | C7_D, | 
| wim | 2:532ce15ea9ec | 118 | C7_E, | 
| wim | 2:532ce15ea9ec | 119 | C7_F, | 
| wim | 2:532ce15ea9ec | 120 | C7_G, | 
| wim | 2:532ce15ea9ec | 121 | C7_H, | 
| wim | 2:532ce15ea9ec | 122 | C7_I, | 
| wim | 2:532ce15ea9ec | 123 | C7_J, | 
| wim | 2:532ce15ea9ec | 124 | C7_K, | 
| wim | 2:532ce15ea9ec | 125 | C7_L, | 
| wim | 2:532ce15ea9ec | 126 | C7_M, | 
| wim | 2:532ce15ea9ec | 127 | C7_N, | 
| wim | 2:532ce15ea9ec | 128 | C7_O, | 
| wim | 2:532ce15ea9ec | 129 | C7_P, | 
| wim | 2:532ce15ea9ec | 130 | C7_Q, | 
| wim | 2:532ce15ea9ec | 131 | C7_R, | 
| wim | 2:532ce15ea9ec | 132 | C7_S, | 
| wim | 2:532ce15ea9ec | 133 | C7_T, | 
| wim | 2:532ce15ea9ec | 134 | C7_U, | 
| wim | 2:532ce15ea9ec | 135 | C7_V, | 
| wim | 2:532ce15ea9ec | 136 | C7_W, | 
| wim | 2:532ce15ea9ec | 137 | C7_X, | 
| wim | 2:532ce15ea9ec | 138 | C7_Y, | 
| wim | 2:532ce15ea9ec | 139 | C7_Z, // 122 0x7A, Z replacing z | 
| wim | 2:532ce15ea9ec | 140 | C7_CBL, // 123 0x7B | 
| wim | 2:532ce15ea9ec | 141 | C7_OR, | 
| wim | 2:532ce15ea9ec | 142 | C7_CBR, | 
| wim | 2:532ce15ea9ec | 143 | C7_TLD, | 
| wim | 2:532ce15ea9ec | 144 | C7_DEL // 127 | 
| wim | 2:532ce15ea9ec | 145 | }; | 
| wim | 0:201dfacbe0e5 | 146 | |
| wim | 2:532ce15ea9ec | 147 | #else | 
| wim | 2:532ce15ea9ec | 148 | //display only digits and hex characters | 
| wim | 2:532ce15ea9ec | 149 | const short FONT_7S[] = { | 
| wim | 2:532ce15ea9ec | 150 | C7_0, //48 0x30 | 
| wim | 2:532ce15ea9ec | 151 | C7_1, | 
| wim | 2:532ce15ea9ec | 152 | C7_2, | 
| wim | 2:532ce15ea9ec | 153 | C7_3, | 
| wim | 2:532ce15ea9ec | 154 | C7_4, | 
| wim | 2:532ce15ea9ec | 155 | C7_5, | 
| wim | 2:532ce15ea9ec | 156 | C7_6, | 
| wim | 2:532ce15ea9ec | 157 | C7_7, | 
| wim | 2:532ce15ea9ec | 158 | C7_8, | 
| wim | 2:532ce15ea9ec | 159 | C7_9, | 
| wim | 2:532ce15ea9ec | 160 | C7_A, //65 0x41, A | 
| wim | 2:532ce15ea9ec | 161 | C7_B, | 
| wim | 2:532ce15ea9ec | 162 | C7_C, | 
| wim | 2:532ce15ea9ec | 163 | C7_D, | 
| wim | 2:532ce15ea9ec | 164 | C7_E, | 
| wim | 2:532ce15ea9ec | 165 | C7_F | 
| wim | 2:532ce15ea9ec | 166 | };// 127 | 
| wim | 2:532ce15ea9ec | 167 | #endif | 
| wim | 0:201dfacbe0e5 | 168 | |
| wim | 0:201dfacbe0e5 | 169 | #endif | 
