done
Font_7Seg.h@0:dc8789a6e21f, 2016-01-30 (annotated)
- Committer:
- wim
- Date:
- Sat Jan 30 20:35:25 2016 +0000
- Revision:
- 0:dc8789a6e21f
- Child:
- 1:f63d87466f55
TM1637 Library, for TM1637 LEDcontroller
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wim | 0:dc8789a6e21f | 1 | /* mbed LED Font Library, for TM1637 LED Controller |
wim | 0:dc8789a6e21f | 2 | * Copyright (c) 2016, v01: WH, Initial version, Test in CATALEX |
wim | 0:dc8789a6e21f | 3 | * |
wim | 0:dc8789a6e21f | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
wim | 0:dc8789a6e21f | 5 | * of this software and associated documentation files (the "Software"), to deal |
wim | 0:dc8789a6e21f | 6 | * in the Software without restriction, including without limitation the rights |
wim | 0:dc8789a6e21f | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
wim | 0:dc8789a6e21f | 8 | * copies of the Software, and to permit persons to whom the Software is |
wim | 0:dc8789a6e21f | 9 | * furnished to do so, subject to the following conditions: |
wim | 0:dc8789a6e21f | 10 | * |
wim | 0:dc8789a6e21f | 11 | * The above copyright notice and this permission notice shall be included in |
wim | 0:dc8789a6e21f | 12 | * all copies or substantial portions of the Software. |
wim | 0:dc8789a6e21f | 13 | * |
wim | 0:dc8789a6e21f | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
wim | 0:dc8789a6e21f | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
wim | 0:dc8789a6e21f | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
wim | 0:dc8789a6e21f | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
wim | 0:dc8789a6e21f | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
wim | 0:dc8789a6e21f | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
wim | 0:dc8789a6e21f | 20 | * THE SOFTWARE. |
wim | 0:dc8789a6e21f | 21 | */ |
wim | 0:dc8789a6e21f | 22 | #ifndef MBED_FONT_7SEG_H |
wim | 0:dc8789a6e21f | 23 | #define MBED_FONT_7SEG_H |
wim | 0:dc8789a6e21f | 24 | |
wim | 0:dc8789a6e21f | 25 | // Select one of the testboards for TM1637 controller |
wim | 0:dc8789a6e21f | 26 | #include "TM1637_Config.h" |
wim | 0:dc8789a6e21f | 27 | |
wim | 0:dc8789a6e21f | 28 | #if ((CATALEX_TEST == 1) || (TM1637_TEST == 1)) |
wim | 0:dc8789a6e21f | 29 | // Segment bit positions for 7 Segment display using the CATALEX mapping for TM1637 |
wim | 0:dc8789a6e21f | 30 | // Modify this table for different 'bit-to-segment' mappings. The ASCII character defines and the FONT_7S const table below |
wim | 0:dc8789a6e21f | 31 | // will be adapted automatically according to the bit-to-segment mapping. Obviously this will only work when the segment |
wim | 0:dc8789a6e21f | 32 | // mapping is identical for every digit position. This will be the case unless the hardware designer really hates software developers. |
wim | 0:dc8789a6e21f | 33 | // |
wim | 0:dc8789a6e21f | 34 | // A |
wim | 0:dc8789a6e21f | 35 | // ----- |
wim | 0:dc8789a6e21f | 36 | // | | |
wim | 0:dc8789a6e21f | 37 | // F | | B |
wim | 0:dc8789a6e21f | 38 | // | G | |
wim | 0:dc8789a6e21f | 39 | // ----- |
wim | 0:dc8789a6e21f | 40 | // | | |
wim | 0:dc8789a6e21f | 41 | // E | | C |
wim | 0:dc8789a6e21f | 42 | // | | |
wim | 0:dc8789a6e21f | 43 | // ----- * DP |
wim | 0:dc8789a6e21f | 44 | // D |
wim | 0:dc8789a6e21f | 45 | // |
wim | 0:dc8789a6e21f | 46 | #define S7_A 0x0001 |
wim | 0:dc8789a6e21f | 47 | #define S7_B 0x0002 |
wim | 0:dc8789a6e21f | 48 | #define S7_C 0x0004 |
wim | 0:dc8789a6e21f | 49 | #define S7_D 0x0008 |
wim | 0:dc8789a6e21f | 50 | #define S7_E 0x0010 |
wim | 0:dc8789a6e21f | 51 | #define S7_F 0x0020 |
wim | 0:dc8789a6e21f | 52 | #define S7_G 0x0040 |
wim | 0:dc8789a6e21f | 53 | #define S7_DP 0x0080 |
wim | 0:dc8789a6e21f | 54 | |
wim | 0:dc8789a6e21f | 55 | //Mask for blending out and setting 7 segments digits |
wim | 0:dc8789a6e21f | 56 | #define MASK_7S_ALL = (S7_A | S7_B | S7_C | S7_D | S7_E | S7_F | S7_G} |
wim | 0:dc8789a6e21f | 57 | |
wim | 0:dc8789a6e21f | 58 | //Icons Grid 1 |
wim | 0:dc8789a6e21f | 59 | #define S7_DP1 0x0080 |
wim | 0:dc8789a6e21f | 60 | #define S7_ICON_GR1 (0x0000) |
wim | 0:dc8789a6e21f | 61 | //#define S7_ICON_GR1 (S7_DP1) |
wim | 0:dc8789a6e21f | 62 | |
wim | 0:dc8789a6e21f | 63 | //Icons Grid 2 |
wim | 0:dc8789a6e21f | 64 | #define S7_DP2 0x0080 |
wim | 0:dc8789a6e21f | 65 | #define S7_COL2 0x0080 |
wim | 0:dc8789a6e21f | 66 | #define S7_ICON_GR2 (0x0000) |
wim | 0:dc8789a6e21f | 67 | //#define S7_ICON_GR2 (S7_DP2) |
wim | 0:dc8789a6e21f | 68 | |
wim | 0:dc8789a6e21f | 69 | //Icons Grid 3 |
wim | 0:dc8789a6e21f | 70 | #define S7_DP3 0x0080 |
wim | 0:dc8789a6e21f | 71 | #define S7_ICON_GR3 (0x0000) |
wim | 0:dc8789a6e21f | 72 | //#define S7_ICON_GR3 (S7_LD3 | S7_DP3) |
wim | 0:dc8789a6e21f | 73 | |
wim | 0:dc8789a6e21f | 74 | //Icons Grid 4 |
wim | 0:dc8789a6e21f | 75 | #define S7_DP4 0x0080 |
wim | 0:dc8789a6e21f | 76 | #define S7_ICON_GR4 (0x0000) |
wim | 0:dc8789a6e21f | 77 | //#define S7_ICON_GR4 (S7_DP4) |
wim | 0:dc8789a6e21f | 78 | |
wim | 0:dc8789a6e21f | 79 | |
wim | 0:dc8789a6e21f | 80 | //Mask for blending out and restoring Icons |
wim | 0:dc8789a6e21f | 81 | extern const char MASK_ICON_GRID[]; |
wim | 0:dc8789a6e21f | 82 | #endif |
wim | 0:dc8789a6e21f | 83 | |
wim | 0:dc8789a6e21f | 84 | |
wim | 0:dc8789a6e21f | 85 | // ASCII Font definitions for segments in each character |
wim | 0:dc8789a6e21f | 86 | // |
wim | 0:dc8789a6e21f | 87 | //32 0x20 Symbols |
wim | 0:dc8789a6e21f | 88 | #define C7_SPC (0x0000) |
wim | 0:dc8789a6e21f | 89 | #define C7_EXC (S7_B | S7_C) //! |
wim | 0:dc8789a6e21f | 90 | #define C7_QTE (S7_B | S7_F) //" |
wim | 0:dc8789a6e21f | 91 | #define C7_HSH (S7_C | S7_D | S7_E | S7_G) //# |
wim | 0:dc8789a6e21f | 92 | #define C7_DLR (S7_A | S7_C | S7_D | S7_F | S7_G) //$ |
wim | 0:dc8789a6e21f | 93 | #define C7_PCT (S7_C | S7_F) //% |
wim | 0:dc8789a6e21f | 94 | #define C7_AMP (S7_A | S7_C | S7_D | S7_E | S7_F | S7_G) //& |
wim | 0:dc8789a6e21f | 95 | #define C7_ACC (S7_B) //' |
wim | 0:dc8789a6e21f | 96 | #define C7_LBR (S7_A | S7_D | S7_E | S7_F) //( |
wim | 0:dc8789a6e21f | 97 | #define C7_RBR (S7_A | S7_B | S7_C | S7_D) //) |
wim | 0:dc8789a6e21f | 98 | #define C7_MLT (S7_B | S7_C | S7_E | S7_F | S7_G) //* |
wim | 0:dc8789a6e21f | 99 | #define C7_PLS (S7_B | S7_C | S7_G) //+ |
wim | 0:dc8789a6e21f | 100 | #define C7_CMA (S7_DP) |
wim | 0:dc8789a6e21f | 101 | #define C7_MIN (S7_G) |
wim | 0:dc8789a6e21f | 102 | #define C7_DPT (S7_DP) |
wim | 0:dc8789a6e21f | 103 | #define C7_RS (S7_B | S7_E | S7_G) // / |
wim | 0:dc8789a6e21f | 104 | |
wim | 0:dc8789a6e21f | 105 | //48 0x30 Digits |
wim | 0:dc8789a6e21f | 106 | #define C7_0 (S7_A | S7_B | S7_C | S7_D | S7_E | S7_F) |
wim | 0:dc8789a6e21f | 107 | #define C7_1 (S7_B | S7_C) |
wim | 0:dc8789a6e21f | 108 | #define C7_2 (S7_A | S7_B | S7_D | S7_E | S7_G) |
wim | 0:dc8789a6e21f | 109 | #define C7_3 (S7_A | S7_B | S7_C | S7_D | S7_G) |
wim | 0:dc8789a6e21f | 110 | #define C7_4 (S7_B | S7_C | S7_F | S7_G) |
wim | 0:dc8789a6e21f | 111 | #define C7_5 (S7_A | S7_C | S7_D | S7_F | S7_G) |
wim | 0:dc8789a6e21f | 112 | #define C7_6 (S7_A | S7_C | S7_D | S7_E | S7_F | S7_G) |
wim | 0:dc8789a6e21f | 113 | #define C7_7 (S7_A | S7_B | S7_C) |
wim | 0:dc8789a6e21f | 114 | #define C7_8 (S7_A | S7_B | S7_C | S7_D | S7_E | S7_F | S7_G) |
wim | 0:dc8789a6e21f | 115 | #define C7_9 (S7_A | S7_B | S7_C | S7_D | S7_F | S7_G) |
wim | 0:dc8789a6e21f | 116 | |
wim | 0:dc8789a6e21f | 117 | //58 0x3A |
wim | 0:dc8789a6e21f | 118 | #define C7_COL (S7_D | S7_G) // : |
wim | 0:dc8789a6e21f | 119 | #define C7_SCL (S7_D | S7_G) // ; |
wim | 0:dc8789a6e21f | 120 | #define C7_LT (S7_D | S7_E | S7_G) // < |
wim | 0:dc8789a6e21f | 121 | #define C7_EQ (S7_D | S7_G) // = |
wim | 0:dc8789a6e21f | 122 | #define C7_GT (S7_C | S7_D | S7_G) // > |
wim | 0:dc8789a6e21f | 123 | #define C7_QM (S7_A | S7_B | S7_E | S7_G) // ? |
wim | 0:dc8789a6e21f | 124 | #define C7_AT (S7_A | S7_B | S7_C | S7_D | S7_E | S7_G) // @ |
wim | 0:dc8789a6e21f | 125 | |
wim | 0:dc8789a6e21f | 126 | //65 0x41 Upper case alphabet |
wim | 0:dc8789a6e21f | 127 | #define C7_A (S7_A | S7_B | S7_C | S7_E | S7_F | S7_G ) |
wim | 0:dc8789a6e21f | 128 | #define C7_B (S7_C | S7_D | S7_E | S7_F | S7_G) |
wim | 0:dc8789a6e21f | 129 | #define C7_C (S7_A | S7_D | S7_E | S7_F) |
wim | 0:dc8789a6e21f | 130 | #define C7_D (S7_B | S7_C | S7_D | S7_E | S7_G) |
wim | 0:dc8789a6e21f | 131 | #define C7_E (S7_A | S7_D | S7_E | S7_F | S7_G) |
wim | 0:dc8789a6e21f | 132 | #define C7_F (S7_A | S7_E | S7_F | S7_G) |
wim | 0:dc8789a6e21f | 133 | |
wim | 0:dc8789a6e21f | 134 | #define C7_G (S7_A | S7_C | S7_D | S7_E | S7_F) |
wim | 0:dc8789a6e21f | 135 | #define C7_H (S7_B | S7_C | S7_E | S7_F | S7_G) |
wim | 0:dc8789a6e21f | 136 | #define C7_I (S7_B | S7_C) |
wim | 0:dc8789a6e21f | 137 | #define C7_J (S7_B | S7_C | S7_D | S7_E) |
wim | 0:dc8789a6e21f | 138 | #define C7_K (S7_B | S7_C | S7_E | S7_F | S7_G) |
wim | 0:dc8789a6e21f | 139 | #define C7_L (S7_D | S7_E | S7_F) |
wim | 0:dc8789a6e21f | 140 | #define C7_M (S7_A | S7_C | S7_E) |
wim | 0:dc8789a6e21f | 141 | #define C7_N (S7_A | S7_B | S7_C | S7_E | S7_F) |
wim | 0:dc8789a6e21f | 142 | #define C7_O (S7_A | S7_B | S7_C | S7_D | S7_E | S7_F) |
wim | 0:dc8789a6e21f | 143 | #define C7_P (S7_A | S7_B | S7_E | S7_F | S7_G) |
wim | 0:dc8789a6e21f | 144 | #define C7_Q (S7_A | S7_B | S7_C | S7_F | S7_G) |
wim | 0:dc8789a6e21f | 145 | #define C7_R (S7_E | S7_G ) |
wim | 0:dc8789a6e21f | 146 | #define C7_S (S7_A | S7_C | S7_D | S7_F | S7_G) |
wim | 0:dc8789a6e21f | 147 | #define C7_T (S7_D | S7_E | S7_F | S7_G) |
wim | 0:dc8789a6e21f | 148 | #define C7_U (S7_B | S7_C | S7_D | S7_E | S7_F) |
wim | 0:dc8789a6e21f | 149 | #define C7_V (S7_B | S7_C | S7_D | S7_E | S7_F) |
wim | 0:dc8789a6e21f | 150 | #define C7_W (S7_B | S7_D | S7_F) |
wim | 0:dc8789a6e21f | 151 | #define C7_X (S7_B | S7_C | S7_E | S7_F | S7_G) |
wim | 0:dc8789a6e21f | 152 | #define C7_Y (S7_B | S7_C | S7_D | S7_F | S7_G) |
wim | 0:dc8789a6e21f | 153 | #define C7_Z (S7_A | S7_B | S7_D | S7_E | S7_G) |
wim | 0:dc8789a6e21f | 154 | |
wim | 0:dc8789a6e21f | 155 | //91 0x5B |
wim | 0:dc8789a6e21f | 156 | #define C7_SBL (S7_A | S7_D | S7_E | S7_F) // [ |
wim | 0:dc8789a6e21f | 157 | #define C7_LS (S7_C | S7_F | S7_G) // left slash |
wim | 0:dc8789a6e21f | 158 | #define C7_SBR (S7_A | S7_B | S7_C | S7_D) // ] |
wim | 0:dc8789a6e21f | 159 | #define C7_PWR (S7_A | S7_B | S7_F) // ^ |
wim | 0:dc8789a6e21f | 160 | #define C7_UDS (S7_D) // _ |
wim | 0:dc8789a6e21f | 161 | #define C7_DSH (S7_F) // ` |
wim | 0:dc8789a6e21f | 162 | |
wim | 0:dc8789a6e21f | 163 | //97 0x61 Lower case alphabet |
wim | 0:dc8789a6e21f | 164 | #define C7_a C7_A |
wim | 0:dc8789a6e21f | 165 | #define C7_b C7_B |
wim | 0:dc8789a6e21f | 166 | #define C7_c C7_C |
wim | 0:dc8789a6e21f | 167 | #define C7_d C7_D |
wim | 0:dc8789a6e21f | 168 | #define C7_e C7_E |
wim | 0:dc8789a6e21f | 169 | #define C7_f C7_H |
wim | 0:dc8789a6e21f | 170 | |
wim | 0:dc8789a6e21f | 171 | #define C7_g C7_G |
wim | 0:dc8789a6e21f | 172 | #define C7_h C7_H |
wim | 0:dc8789a6e21f | 173 | #define C7_i C7_I |
wim | 0:dc8789a6e21f | 174 | #define C7_j C7_J |
wim | 0:dc8789a6e21f | 175 | #define C7_k C7_K |
wim | 0:dc8789a6e21f | 176 | #define C7_l C7_L |
wim | 0:dc8789a6e21f | 177 | #define C7_m C7_M |
wim | 0:dc8789a6e21f | 178 | //#define C7_n C7_N |
wim | 0:dc8789a6e21f | 179 | #define C7_n (S7_C | S7_E | S7_G) |
wim | 0:dc8789a6e21f | 180 | //#define C7_o C7_O |
wim | 0:dc8789a6e21f | 181 | #define C7_o (S7_C | S7_D | S7_E | S7_G) |
wim | 0:dc8789a6e21f | 182 | #define C7_p C7_P |
wim | 0:dc8789a6e21f | 183 | #define C7_q C7_Q |
wim | 0:dc8789a6e21f | 184 | //#define C7_r C7_R |
wim | 0:dc8789a6e21f | 185 | #define C7_r (S7_E | S7_G) |
wim | 0:dc8789a6e21f | 186 | #define C7_s C7_S |
wim | 0:dc8789a6e21f | 187 | #define C7_t C7_T |
wim | 0:dc8789a6e21f | 188 | #define C7_u C7_U |
wim | 0:dc8789a6e21f | 189 | #define C7_v C7_V |
wim | 0:dc8789a6e21f | 190 | #define C7_w C7_W |
wim | 0:dc8789a6e21f | 191 | #define C7_x C7_X |
wim | 0:dc8789a6e21f | 192 | #define C7_y C7_Y |
wim | 0:dc8789a6e21f | 193 | #define C7_z C7_Z |
wim | 0:dc8789a6e21f | 194 | |
wim | 0:dc8789a6e21f | 195 | //123 0x7B |
wim | 0:dc8789a6e21f | 196 | #define C7_CBL (S7_A | S7_D | S7_E | S7_F) // { |
wim | 0:dc8789a6e21f | 197 | #define C7_OR (S7_B | S7_C) // | |
wim | 0:dc8789a6e21f | 198 | #define C7_CBR (S7_A | S7_B | S7_C | S7_D) // } |
wim | 0:dc8789a6e21f | 199 | #define C7_TLD (S7_B | S7_E | S7_G ) // ~ |
wim | 0:dc8789a6e21f | 200 | #define C7_DEL (0x0000) |
wim | 0:dc8789a6e21f | 201 | |
wim | 0:dc8789a6e21f | 202 | |
wim | 0:dc8789a6e21f | 203 | //User Defined Characters (some examples) |
wim | 0:dc8789a6e21f | 204 | #define C7_DGR (S7_A | S7_B | S7_F | S7_G) //Degrees |
wim | 0:dc8789a6e21f | 205 | |
wim | 0:dc8789a6e21f | 206 | // Font data selection for transmission to TM1637 memory |
wim | 0:dc8789a6e21f | 207 | #define LO(x) ( x & 0xFF) |
wim | 0:dc8789a6e21f | 208 | #define HI(x) ((x >> 8) & 0xFF) |
wim | 0:dc8789a6e21f | 209 | |
wim | 0:dc8789a6e21f | 210 | |
wim | 0:dc8789a6e21f | 211 | // ASCII Font definition table |
wim | 0:dc8789a6e21f | 212 | // |
wim | 0:dc8789a6e21f | 213 | #define FONT_7S_START 0x20 |
wim | 0:dc8789a6e21f | 214 | #define FONT_7S_END 0x7F |
wim | 0:dc8789a6e21f | 215 | //#define FONT_7S_NR_CHARS (FONT_7S_END - FONT_7S_START + 1) |
wim | 0:dc8789a6e21f | 216 | extern const short FONT_7S[]; |
wim | 0:dc8789a6e21f | 217 | |
wim | 0:dc8789a6e21f | 218 | #endif |