Wim Huiskamp / TM1650

Dependents:   mbed_TM1650

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Font_7Seg.h Source File

Font_7Seg.h

00001 /* mbed LED Font Library, for TM1650 LED Controller
00002  * Copyright (c) 2017, v01: WH, Initial version, Test in MEIBAI
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a copy
00005  * of this software and associated documentation files (the "Software"), to deal
00006  * in the Software without restriction, including without limitation the rights
00007  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00008  * copies of the Software, and to permit persons to whom the Software is
00009  * furnished to do so, subject to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice shall be included in
00012  * all copies or substantial portions of the Software.
00013  *
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00017  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00018  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00019  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00020  * THE SOFTWARE.
00021  */
00022 #ifndef MBED_FONT_7SEG_H
00023 #define MBED_FONT_7SEG_H
00024 
00025 // Select one of the testboards for TM1650 controller
00026 #include "TM1650_Config.h"
00027 
00028 #if ((MEIBAI_TEST == 1) || (TM1650_TEST == 1))
00029 // Segment bit positions for 7 Segment display using the MEIBAI and ROBOTDYN mapping for TM1650
00030 // Modify this table for different 'bit-to-segment' mappings. The ASCII character defines and the FONT_7S const table below 
00031 // will be adapted automatically according to the bit-to-segment mapping. Obviously this will only work when the segment
00032 // mapping is identical for every digit position. This will be the case unless the hardware designer really hates software developers.
00033 //
00034 //            A
00035 //          -----
00036 //         |     |     
00037 //       F |     | B    
00038 //         |  G  |     
00039 //          -----
00040 //         |     |     
00041 //       E |     | C    
00042 //         |     |     
00043 //          -----   * DP
00044 //            D  
00045 //
00046 #define S7_A    0x0001
00047 #define S7_B    0x0002
00048 #define S7_C    0x0004
00049 #define S7_D    0x0008
00050 #define S7_E    0x0010
00051 #define S7_F    0x0020
00052 #define S7_G    0x0040 
00053 #define S7_DP   0x0080 
00054 
00055 //Mask for blending out and setting 7 segments digits
00056 #define MASK_7S_ALL = (S7_A | S7_B | S7_C | S7_D | S7_E | S7_F | S7_G}
00057 
00058 //The CATALAX mapping between Digit positions or Columns (Left to Right) and Grids (ie memory address) are:
00059 //The column numbers are:
00060 //   0   1   2   3
00061 //The Grids are:
00062 //  GR1 GR2 GR3 GR4
00063 //The memory addresses are:
00064 //   0   1   2   3
00065 
00066 
00067 //The ROBOTDYN mapping between Digit positions or columns (Left to Right) and Grids (ie memory address) are:
00068 //The column numbers are:
00069 //   0   1   2   3   4   5
00070 //The Grids are:
00071 //  GR3 GR2 GR1 GR6 GR5 GR4
00072 //The memory addresses are:
00073 //   2   1   0   5   4   3
00074 
00075 
00076 //The EYEWINK mapping between Digit positions or columns (Left to Right) and Grids (ie memory address) are:
00077 //The column numbers are:
00078 //   0   1   2   3   4   5
00079 //The Grids are:
00080 //  GR1 GR2 GR3 GR4 GR5 GR6
00081 //The memory addresses are:
00082 //   0   1   2   3   4   5
00083 
00084 
00085 //Icons Grid 1
00086 #define S7_DP1  0x0080
00087 #define S7_ICON_GR1 (0x0000)
00088 //#define S7_ICON_GR1 (S7_DP1)
00089 
00090 //Icons Grid 2
00091 #define S7_DP2  0x0080
00092 #define S7_COL2 0x0080
00093 #define S7_ICON_GR2 (0x0000)
00094 //#define S7_ICON_GR2 (S7_DP2)
00095 
00096 //Icons Grid 3
00097 #define S7_DP3  0x0080
00098 #define S7_ICON_GR3 (0x0000)
00099 //#define S7_ICON_GR3 (S7_DP3)
00100 
00101 //Icons Grid 4
00102 #define S7_DP4  0x0080
00103 #define S7_ICON_GR4 (0x0000)
00104 //#define S7_ICON_GR4 (S7_DP4)
00105 
00106 //Icons Grid 5
00107 #define S7_DP5  0x0080
00108 #define S7_ICON_GR5 (0x0000)
00109 //#define S7_ICON_GR5 (S7_DP5)
00110 
00111 //Icons Grid 6
00112 #define S7_DP6  0x0080
00113 #define S7_ICON_GR6 (0x0000)
00114 //#define S7_ICON_GR6 (S7_DP6)
00115 
00116 
00117 //Mask for blending out and restoring Icons
00118 extern const char MASK_ICON_GRID[]; 
00119 #endif
00120 
00121 
00122 // ASCII Font definitions for segments in each character
00123 //
00124 //32 0x20  Symbols
00125 #define C7_SPC  (0x0000)
00126 #define C7_EXC  (S7_B | S7_C) //!
00127 #define C7_QTE  (S7_B | S7_F) //"
00128 #define C7_HSH  (S7_C | S7_D | S7_E | S7_G) //#
00129 #define C7_DLR  (S7_A | S7_C | S7_D | S7_F | S7_G) //$
00130 #define C7_PCT  (S7_C | S7_F) //%
00131 #define C7_AMP  (S7_A | S7_C | S7_D | S7_E | S7_F | S7_G) //&
00132 #define C7_ACC  (S7_B) //'
00133 #define C7_LBR  (S7_A | S7_D | S7_E | S7_F) //(
00134 #define C7_RBR  (S7_A | S7_B | S7_C | S7_D) //)
00135 #define C7_MLT  (S7_B | S7_C | S7_E | S7_F | S7_G)  //*
00136 #define C7_PLS  (S7_B | S7_C | S7_G) //+
00137 #define C7_CMA  (S7_DP)
00138 #define C7_MIN  (S7_G)
00139 #define C7_DPT  (S7_DP)
00140 #define C7_RS   (S7_B | S7_E  | S7_G)  // /
00141 
00142 //48 0x30  Digits
00143 #define C7_0    (S7_A | S7_B | S7_C | S7_D | S7_E | S7_F)
00144 #define C7_1    (S7_B | S7_C)
00145 #define C7_2    (S7_A | S7_B | S7_D | S7_E | S7_G)
00146 #define C7_3    (S7_A | S7_B | S7_C | S7_D | S7_G)
00147 #define C7_4    (S7_B | S7_C | S7_F | S7_G)
00148 #define C7_5    (S7_A | S7_C | S7_D | S7_F | S7_G)
00149 #define C7_6    (S7_A | S7_C | S7_D | S7_E | S7_F | S7_G)
00150 #define C7_7    (S7_A | S7_B | S7_C)
00151 #define C7_8    (S7_A | S7_B | S7_C | S7_D | S7_E | S7_F | S7_G)
00152 #define C7_9    (S7_A | S7_B | S7_C | S7_D | S7_F | S7_G)
00153 
00154 //58 0x3A
00155 #define C7_COL  (S7_D | S7_G) // :
00156 #define C7_SCL  (S7_D | S7_G) // ;
00157 #define C7_LT   (S7_D | S7_E | S7_G)             // <
00158 #define C7_EQ   (S7_D | S7_G)                    // =
00159 #define C7_GT   (S7_C | S7_D | S7_G)             // >   
00160 #define C7_QM   (S7_A | S7_B | S7_E | S7_G)      // ?
00161 #define C7_AT   (S7_A | S7_B | S7_C | S7_D | S7_E  | S7_G)  // @
00162 
00163 //65 0x41  Upper case alphabet
00164 #define C7_A    (S7_A | S7_B | S7_C | S7_E | S7_F | S7_G )
00165 #define C7_B    (S7_C | S7_D | S7_E | S7_F | S7_G)
00166 #define C7_C    (S7_A | S7_D | S7_E | S7_F)
00167 #define C7_D    (S7_B | S7_C | S7_D | S7_E | S7_G)
00168 #define C7_E    (S7_A | S7_D | S7_E | S7_F | S7_G)
00169 #define C7_F    (S7_A | S7_E | S7_F | S7_G)
00170 
00171 #define C7_G    (S7_A | S7_C | S7_D | S7_E | S7_F)
00172 #define C7_H    (S7_B | S7_C | S7_E | S7_F | S7_G)
00173 #define C7_I    (S7_B | S7_C)
00174 #define C7_J    (S7_B | S7_C | S7_D | S7_E)
00175 #define C7_K    (S7_B | S7_C | S7_E | S7_F | S7_G)
00176 #define C7_L    (S7_D | S7_E | S7_F)
00177 #define C7_M    (S7_A | S7_C | S7_E)
00178 #define C7_N    (S7_A | S7_B | S7_C | S7_E | S7_F)
00179 #define C7_O    (S7_A | S7_B | S7_C | S7_D | S7_E | S7_F)
00180 #define C7_P    (S7_A | S7_B | S7_E | S7_F | S7_G)
00181 #define C7_Q    (S7_A | S7_B | S7_C | S7_F | S7_G)
00182 #define C7_R    (S7_E | S7_G )
00183 #define C7_S    (S7_A | S7_C | S7_D | S7_F | S7_G)
00184 #define C7_T    (S7_D | S7_E | S7_F | S7_G)
00185 #define C7_U    (S7_B | S7_C | S7_D | S7_E | S7_F)
00186 #define C7_V    (S7_B | S7_C | S7_D | S7_E | S7_F)
00187 #define C7_W    (S7_B | S7_D | S7_F)
00188 #define C7_X    (S7_B | S7_C | S7_E | S7_F | S7_G)
00189 #define C7_Y    (S7_B | S7_C | S7_D | S7_F | S7_G)
00190 #define C7_Z    (S7_A | S7_B | S7_D | S7_E | S7_G)
00191 
00192 //91 0x5B
00193 #define C7_SBL  (S7_A | S7_D | S7_E | S7_F) // [
00194 #define C7_LS   (S7_C | S7_F | S7_G)        // left slash
00195 #define C7_SBR  (S7_A | S7_B | S7_C | S7_D) // ]
00196 #define C7_PWR  (S7_A | S7_B | S7_F)        // ^
00197 #define C7_UDS  (S7_D)                      // _
00198 #define C7_DSH  (S7_F)                      // `  
00199 
00200 //97 0x61  Lower case alphabet
00201 #define C7_a     C7_A
00202 #define C7_b     C7_B
00203 #define C7_c     C7_C
00204 #define C7_d     C7_D
00205 #define C7_e     C7_E
00206 #define C7_f     C7_H
00207 
00208 #define C7_g     C7_G
00209 #define C7_h     C7_H
00210 #define C7_i     C7_I
00211 #define C7_j     C7_J
00212 #define C7_k     C7_K
00213 #define C7_l     C7_L
00214 #define C7_m     C7_M
00215 //#define C7_n     C7_N
00216 #define C7_n    (S7_C | S7_E | S7_G)
00217 //#define C7_o     C7_O
00218 #define C7_o    (S7_C | S7_D | S7_E | S7_G)
00219 #define C7_p     C7_P
00220 #define C7_q     C7_Q
00221 //#define C7_r     C7_R
00222 #define C7_r    (S7_E | S7_G)
00223 #define C7_s     C7_S
00224 #define C7_t     C7_T
00225 #define C7_u     C7_U
00226 #define C7_v     C7_V
00227 #define C7_w     C7_W
00228 #define C7_x     C7_X
00229 #define C7_y     C7_Y
00230 #define C7_z     C7_Z
00231 
00232 //123 0x7B
00233 #define C7_CBL  (S7_A | S7_D | S7_E | S7_F)        // {
00234 #define C7_OR   (S7_B | S7_C)                      // |
00235 #define C7_CBR  (S7_A | S7_B | S7_C | S7_D)        // }
00236 #define C7_TLD  (S7_B | S7_E | S7_G )              // ~
00237 #define C7_DEL  (0x0000)
00238 
00239 
00240 //User Defined Characters (some examples)
00241 #define C7_DGR   (S7_A | S7_B | S7_F | S7_G)  //Degrees
00242                                                                          
00243 // Font data selection for transmission to TM1650 memory
00244 #define LO(x)  ( x & 0xFF)
00245 #define HI(x)  ((x >> 8) & 0xFF)
00246 
00247 
00248 // ASCII Font definition table
00249 //
00250 #define FONT_7S_START     0x20
00251 #define FONT_7S_END       0x7F
00252 //#define FONT_7S_NR_CHARS (FONT_7S_END - FONT_7S_START + 1)
00253 extern const short FONT_7S[]; 
00254 
00255 #endif