TM1638 LED controller. Max 80 LEDs, Max 24 Key scan. Supports LED&KEY, QYF-TM1638 and JY-LKM1638 module.

Dependents:   mbed_TM1638 Otjimaniya

See here for more information.

Committer:
wim
Date:
Sun Jan 31 12:11:06 2016 +0000
Revision:
4:b2bbdc58967e
Parent:
2:532ce15ea9ec
Added QYF-TM1638 and LKM1638, refactoring of writeData()

Who changed what in which revision?

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