Library for TM1650 LED controller (32 LEDs max, 28 keys max)

Dependents:   mbed_TM1650

See here for more info.

Committer:
wim
Date:
Tue Oct 10 18:38:46 2017 +0000
Revision:
0:4430a1559b4f
Library for TM1650 LED controller (32 LEDs max, 27 keys max)

Who changed what in which revision?

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