done

Dependents:   AwesomeAlarm_BLE

Committer:
wim
Date:
Fri Oct 06 16:43:56 2017 +0000
Revision:
1:f63d87466f55
Parent:
0:dc8789a6e21f
Added RobotDyn 6 Digit module,; Added Eyewink 6 Digit + 5 Keys module,; Constructor adapted to 2 pins: dio, clk

Who changed what in which revision?

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