Creating a project about VL6180XA1 for TT_Mxx

Committer:
ThunderSoft
Date:
Fri Apr 26 09:34:53 2019 +0000
Revision:
3:7a97a01bad5e
Parent:
0:293917667c17
"update the mbed-os code to support TT_M4G9"

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ThunderSoft 0:293917667c17 1 /**
ThunderSoft 0:293917667c17 2 ******************************************************************************
ThunderSoft 0:293917667c17 3 * @file Display.h
ThunderSoft 0:293917667c17 4 * @author AST / EST
ThunderSoft 0:293917667c17 5 * @version V0.0.1
ThunderSoft 0:293917667c17 6 * @date 14-April-2015
ThunderSoft 0:293917667c17 7 * @brief Header file for display
ThunderSoft 0:293917667c17 8 ******************************************************************************
ThunderSoft 0:293917667c17 9 * @attention
ThunderSoft 0:293917667c17 10 *
ThunderSoft 0:293917667c17 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
ThunderSoft 0:293917667c17 12 *
ThunderSoft 0:293917667c17 13 * Redistribution and use in source and binary forms, with or without modification,
ThunderSoft 0:293917667c17 14 * are permitted provided that the following conditions are met:
ThunderSoft 0:293917667c17 15 * 1. Redistributions of source code must retain the above copyright notice,
ThunderSoft 0:293917667c17 16 * this list of conditions and the following disclaimer.
ThunderSoft 0:293917667c17 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
ThunderSoft 0:293917667c17 18 * this list of conditions and the following disclaimer in the documentation
ThunderSoft 0:293917667c17 19 * and/or other materials provided with the distribution.
ThunderSoft 0:293917667c17 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
ThunderSoft 0:293917667c17 21 * may be used to endorse or promote products derived from this software
ThunderSoft 0:293917667c17 22 * without specific prior written permission.
ThunderSoft 0:293917667c17 23 *
ThunderSoft 0:293917667c17 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
ThunderSoft 0:293917667c17 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
ThunderSoft 0:293917667c17 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
ThunderSoft 0:293917667c17 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
ThunderSoft 0:293917667c17 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
ThunderSoft 0:293917667c17 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
ThunderSoft 0:293917667c17 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
ThunderSoft 0:293917667c17 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
ThunderSoft 0:293917667c17 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
ThunderSoft 0:293917667c17 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ThunderSoft 0:293917667c17 34 *
ThunderSoft 0:293917667c17 35 ******************************************************************************
ThunderSoft 0:293917667c17 36 */
ThunderSoft 0:293917667c17 37
ThunderSoft 0:293917667c17 38
ThunderSoft 0:293917667c17 39 #ifndef __DISPLAY_H
ThunderSoft 0:293917667c17 40 #define __DISPLAY_H
ThunderSoft 0:293917667c17 41
ThunderSoft 0:293917667c17 42
ThunderSoft 0:293917667c17 43 /* Includes ------------------------------------------------------------------*/
ThunderSoft 0:293917667c17 44
ThunderSoft 0:293917667c17 45 #include "mbed.h"
ThunderSoft 0:293917667c17 46 #include "STMPE1600.h"
ThunderSoft 0:293917667c17 47
ThunderSoft 0:293917667c17 48
ThunderSoft 0:293917667c17 49 #ifdef __cplusplus
ThunderSoft 0:293917667c17 50 extern "C" {
ThunderSoft 0:293917667c17 51 #endif
ThunderSoft 0:293917667c17 52
ThunderSoft 0:293917667c17 53 #define DP (1<<7)
ThunderSoft 0:293917667c17 54 #define NOT_7_NO_DP( ... ) (uint8_t) ~( __VA_ARGS__ + DP )
ThunderSoft 0:293917667c17 55 #define S0 (1<<0)
ThunderSoft 0:293917667c17 56 #define S1 (1<<1)
ThunderSoft 0:293917667c17 57 #define S2 (1<<2)
ThunderSoft 0:293917667c17 58 #define S3 (1<<3)
ThunderSoft 0:293917667c17 59 #define S4 (1<<4)
ThunderSoft 0:293917667c17 60 #define S5 (1<<5)
ThunderSoft 0:293917667c17 61 #define S6 (1<<6)
ThunderSoft 0:293917667c17 62
ThunderSoft 0:293917667c17 63 #ifndef __cpluplus
ThunderSoft 0:293917667c17 64 /* refer to http://www.twyman.org.uk/Fonts/ */
ThunderSoft 0:293917667c17 65 static const uint8_t ascii_to_display_lut[256]={
ThunderSoft 0:293917667c17 66 0,0,0,0,0,0,0,0,
ThunderSoft 0:293917667c17 67 0,0,0,0,0,0,0,0,
ThunderSoft 0:293917667c17 68 0,0,0,0,0,0,0,0,
ThunderSoft 0:293917667c17 69 0,0,0,0,0,0,0,0,
ThunderSoft 0:293917667c17 70 [32]= 0,
ThunderSoft 0:293917667c17 71 0,0,0,0,0,0,0,0,
ThunderSoft 0:293917667c17 72 0,
ThunderSoft 0:293917667c17 73 [42]= NOT_7_NO_DP(),
ThunderSoft 0:293917667c17 74 0,0,
ThunderSoft 0:293917667c17 75 [45]= S6,
ThunderSoft 0:293917667c17 76 0,0,
ThunderSoft 0:293917667c17 77 [48]= NOT_7_NO_DP(S6),
ThunderSoft 0:293917667c17 78 [49]= S1+S2,
ThunderSoft 0:293917667c17 79 [50]= S0+S1+S6+S4+S3,
ThunderSoft 0:293917667c17 80 [51]= NOT_7_NO_DP(S4+S5),
ThunderSoft 0:293917667c17 81 [52]= S5+S1+S6+S2,
ThunderSoft 0:293917667c17 82 [53]= NOT_7_NO_DP(S1+S4),
ThunderSoft 0:293917667c17 83 [54]= NOT_7_NO_DP(S1),
ThunderSoft 0:293917667c17 84 [55]= S0+S1+S2,
ThunderSoft 0:293917667c17 85 [56]= NOT_7_NO_DP(0),
ThunderSoft 0:293917667c17 86 [57]= NOT_7_NO_DP(S4),
ThunderSoft 0:293917667c17 87 0,0,0,
ThunderSoft 0:293917667c17 88 [61]= S3+S6,
ThunderSoft 0:293917667c17 89 0,
ThunderSoft 0:293917667c17 90 [63]= NOT_7_NO_DP(S5+S3+S2),
ThunderSoft 0:293917667c17 91 [64]= S0+S3,
ThunderSoft 0:293917667c17 92 [65]= NOT_7_NO_DP(S3),
ThunderSoft 0:293917667c17 93 [66]= NOT_7_NO_DP(S0+S1), /* as b */
ThunderSoft 0:293917667c17 94 [67]= S0+S3+S4+S5, // same as [
ThunderSoft 0:293917667c17 95 [68]= S0+S3+S4+S5, // same as [ DUMMY
ThunderSoft 0:293917667c17 96 [69]= NOT_7_NO_DP(S1+S2),
ThunderSoft 0:293917667c17 97 [70]= S6+S5+S4+S0,
ThunderSoft 0:293917667c17 98 [71]= NOT_7_NO_DP(S4), /* same as 9 */
ThunderSoft 0:293917667c17 99 [72]= NOT_7_NO_DP(S0+S3),
ThunderSoft 0:293917667c17 100 [73]= S1+S2,
ThunderSoft 0:293917667c17 101 [74]= S1+S2+S3+S4,
ThunderSoft 0:293917667c17 102 [75]= NOT_7_NO_DP(S0+S3), /* same as H */
ThunderSoft 0:293917667c17 103 [76]= S3+S4+S5,
ThunderSoft 0:293917667c17 104 [77]= S0+S4+S2, /* same as m*/
ThunderSoft 0:293917667c17 105 [78]= S2+S4+S6, /* same as n*/
ThunderSoft 0:293917667c17 106 [79]= NOT_7_NO_DP(S6),
ThunderSoft 0:293917667c17 107 [80]= S0+S1+S2+S5+S6, // sames as 'q'
ThunderSoft 0:293917667c17 108 [81]= NOT_7_NO_DP(S3+S2),
ThunderSoft 0:293917667c17 109 [82]= S4+S6,
ThunderSoft 0:293917667c17 110 [83]= NOT_7_NO_DP(S1+S4), /* sasme as 5 */
ThunderSoft 0:293917667c17 111 [84]= NOT_7_NO_DP(S0+S1+S2), /* sasme as t */
ThunderSoft 0:293917667c17 112 [85]= NOT_7_NO_DP(S6+S0),
ThunderSoft 0:293917667c17 113 [86]= S4+S3+S2, // is u but u use U
ThunderSoft 0:293917667c17 114 [87]= S1+S3+S5,
ThunderSoft 0:293917667c17 115 [88]= NOT_7_NO_DP(S0+S3), // similar to H
ThunderSoft 0:293917667c17 116 [89]= NOT_7_NO_DP(S0+S4),
ThunderSoft 0:293917667c17 117 [90]= S0+S1+S6+S4+S3, // same as 2
ThunderSoft 0:293917667c17 118 [91]= S0+S3+S4+S5,
ThunderSoft 0:293917667c17 119 0,
ThunderSoft 0:293917667c17 120 [93]= S0+S3+S2+S1,
ThunderSoft 0:293917667c17 121 [94]= S0, /* use as top bar */
ThunderSoft 0:293917667c17 122 [95]= S3,
ThunderSoft 0:293917667c17 123 0,
ThunderSoft 0:293917667c17 124 [97]= S2+ S3+ S4+ S6 ,
ThunderSoft 0:293917667c17 125 [98]= NOT_7_NO_DP(S0+S1),
ThunderSoft 0:293917667c17 126 [99]= S6+S4+S3,
ThunderSoft 0:293917667c17 127 [100]= NOT_7_NO_DP(S0+S5),
ThunderSoft 0:293917667c17 128 [101]= NOT_7_NO_DP(S2),
ThunderSoft 0:293917667c17 129 [102]= S6+S5+S4+S0, /* same as F */
ThunderSoft 0:293917667c17 130 [103]= NOT_7_NO_DP(S4), /* same as 9 */
ThunderSoft 0:293917667c17 131 [104]= S6+S5+S4+S2,
ThunderSoft 0:293917667c17 132 [105]= S4,
ThunderSoft 0:293917667c17 133 [106]= S1+S2+S3+S4,
ThunderSoft 0:293917667c17 134 [107]= S6+S5+S4+S2, /* a h */
ThunderSoft 0:293917667c17 135 [108]= S3+S4,
ThunderSoft 0:293917667c17 136 [109]= S0+S4+S2, /* same as */
ThunderSoft 0:293917667c17 137 [110]= S2+S4+S6,
ThunderSoft 0:293917667c17 138 [111]= S6+S4+S3+S2,
ThunderSoft 0:293917667c17 139 [112]= NOT_7_NO_DP(S3+S2), // same as P
ThunderSoft 0:293917667c17 140 [113]= S0+S1+S2+S5+S6,
ThunderSoft 0:293917667c17 141 [114]= S4+S6,
ThunderSoft 0:293917667c17 142 [115]= NOT_7_NO_DP(S1+S4),
ThunderSoft 0:293917667c17 143 [116]= NOT_7_NO_DP(S0+S1+S2),
ThunderSoft 0:293917667c17 144 [117]= S4+S3+S2+S5+S1, // U
ThunderSoft 0:293917667c17 145 [118]= S4+S3+S2, // is u but u use U
ThunderSoft 0:293917667c17 146 [119]= S1+S3+S5,
ThunderSoft 0:293917667c17 147 [120]= NOT_7_NO_DP(S0+S3), // similar to H
ThunderSoft 0:293917667c17 148 [121]= NOT_7_NO_DP(S0+S4),
ThunderSoft 0:293917667c17 149 [122]= S0+S1+S6+S4+S3, // same as 2
ThunderSoft 0:293917667c17 150 0,0,0,
ThunderSoft 0:293917667c17 151 [126]= S0+S3+S6 /* 3 h bar */
ThunderSoft 0:293917667c17 152 };
ThunderSoft 0:293917667c17 153 #else
ThunderSoft 0:293917667c17 154 /* refer to http://www.twyman.org.uk/Fonts/ */
ThunderSoft 0:293917667c17 155 static const uint8_t ascii_to_display_lut[256]={
ThunderSoft 0:293917667c17 156 [' ']= 0,
ThunderSoft 0:293917667c17 157 ['-']= S6,
ThunderSoft 0:293917667c17 158 ['_']= S3,
ThunderSoft 0:293917667c17 159 ['=']= S3+S6,
ThunderSoft 0:293917667c17 160 ['~']= S0+S3+S6, /* 3 h bar */
ThunderSoft 0:293917667c17 161 ['^']= S0, /* use as top bar */
ThunderSoft 0:293917667c17 162
ThunderSoft 0:293917667c17 163 ['?']= NOT_7_NO_DP(S5+S3+S2),
ThunderSoft 0:293917667c17 164 ['*']= NOT_7_NO_DP(),
ThunderSoft 0:293917667c17 165 ['[']= S0+S3+S4+S5,
ThunderSoft 0:293917667c17 166 [']']= S0+S3+S2+S1,
ThunderSoft 0:293917667c17 167 ['@']= S0+S3,
ThunderSoft 0:293917667c17 168
ThunderSoft 0:293917667c17 169 ['0']= NOT_7_NO_DP(S6),
ThunderSoft 0:293917667c17 170 ['1']= S1+S2,
ThunderSoft 0:293917667c17 171 ['2']= S0+S1+S6+S4+S3,
ThunderSoft 0:293917667c17 172 ['3']= NOT_7_NO_DP(S4+S5),
ThunderSoft 0:293917667c17 173 ['4']= S5+S1+S6+S2,
ThunderSoft 0:293917667c17 174 ['5']= NOT_7_NO_DP(S1+S4),
ThunderSoft 0:293917667c17 175 ['6']= NOT_7_NO_DP(S1),
ThunderSoft 0:293917667c17 176 ['7']= S0+S1+S2,
ThunderSoft 0:293917667c17 177 ['8']= NOT_7_NO_DP(0),
ThunderSoft 0:293917667c17 178 ['9']= NOT_7_NO_DP(S4),
ThunderSoft 0:293917667c17 179
ThunderSoft 0:293917667c17 180 ['a']= S2+ S3+ S4+ S6 ,
ThunderSoft 0:293917667c17 181 ['b']= NOT_7_NO_DP(S0+S1),
ThunderSoft 0:293917667c17 182 ['c']= S6+S4+S3,
ThunderSoft 0:293917667c17 183 ['d']= NOT_7_NO_DP(S0+S5),
ThunderSoft 0:293917667c17 184 ['e']= NOT_7_NO_DP(S2),
ThunderSoft 0:293917667c17 185 ['f']= S6+S5+S4+S0, /* same as F */
ThunderSoft 0:293917667c17 186 ['g']= NOT_7_NO_DP(S4), /* same as 9 */
ThunderSoft 0:293917667c17 187 ['h']= S6+S5+S4+S2,
ThunderSoft 0:293917667c17 188 ['i']= S4,
ThunderSoft 0:293917667c17 189 ['j']= S1+S2+S3+S4,
ThunderSoft 0:293917667c17 190 ['k']= S6+S5+S4+S2, /* a h */
ThunderSoft 0:293917667c17 191 ['l']= S3+S4,
ThunderSoft 0:293917667c17 192 ['m']= S0+S4+S2, /* same as */
ThunderSoft 0:293917667c17 193 ['n']= S2+S4+S6,
ThunderSoft 0:293917667c17 194 ['o']= S6+S4+S3+S2,
ThunderSoft 0:293917667c17 195 ['p']= NOT_7_NO_DP(S3+S2), // same as P
ThunderSoft 0:293917667c17 196 ['q']= S0+S1+S2+S5+S6,
ThunderSoft 0:293917667c17 197 ['r']= S4+S6,
ThunderSoft 0:293917667c17 198 ['s']= NOT_7_NO_DP(S1+S4),
ThunderSoft 0:293917667c17 199 ['t']= NOT_7_NO_DP(S0+S1+S2),
ThunderSoft 0:293917667c17 200 ['u']= S4+S3+S2+S5+S1, // U
ThunderSoft 0:293917667c17 201 ['v']= S4+S3+S2, // is u but u use U
ThunderSoft 0:293917667c17 202 ['w']= S1+S3+S5,
ThunderSoft 0:293917667c17 203 ['x']= NOT_7_NO_DP(S0+S3), // similar to H
ThunderSoft 0:293917667c17 204 ['y']= NOT_7_NO_DP(S0+S4),
ThunderSoft 0:293917667c17 205 ['z']= S0+S1+S6+S4+S3, // same as 2
ThunderSoft 0:293917667c17 206
ThunderSoft 0:293917667c17 207 ['A']= NOT_7_NO_DP(S3),
ThunderSoft 0:293917667c17 208 ['B']= NOT_7_NO_DP(S0+S1), /* as b */
ThunderSoft 0:293917667c17 209 ['C']= S0+S3+S4+S5, // same as [
ThunderSoft 0:293917667c17 210 ['E']= NOT_7_NO_DP(S1+S2),
ThunderSoft 0:293917667c17 211 ['F']= S6+S5+S4+S0,
ThunderSoft 0:293917667c17 212 ['G']= NOT_7_NO_DP(S4), /* same as 9 */
ThunderSoft 0:293917667c17 213 ['H']= NOT_7_NO_DP(S0+S3),
ThunderSoft 0:293917667c17 214 ['I']= S1+S2,
ThunderSoft 0:293917667c17 215 ['J']= S1+S2+S3+S4,
ThunderSoft 0:293917667c17 216 ['K']= NOT_7_NO_DP(S0+S3), /* same as H */
ThunderSoft 0:293917667c17 217 ['L']= S3+S4+S5,
ThunderSoft 0:293917667c17 218 ['M']= S0+S4+S2, /* same as m*/
ThunderSoft 0:293917667c17 219 ['N']= S2+S4+S6, /* same as n*/
ThunderSoft 0:293917667c17 220 ['O']= NOT_7_NO_DP(S6),
ThunderSoft 0:293917667c17 221 ['P']= S0+S1+S2+S5+S6, // sames as 'q'
ThunderSoft 0:293917667c17 222 ['Q']= NOT_7_NO_DP(S3+S2),
ThunderSoft 0:293917667c17 223 ['R']= S4+S6,
ThunderSoft 0:293917667c17 224 ['S']= NOT_7_NO_DP(S1+S4), /* sasme as 5 */
ThunderSoft 0:293917667c17 225 ['T']= NOT_7_NO_DP(S0+S1+S2), /* sasme as t */
ThunderSoft 0:293917667c17 226 ['U']= NOT_7_NO_DP(S6+S0),
ThunderSoft 0:293917667c17 227 ['V']= S4+S3+S2, // is u but u use U
ThunderSoft 0:293917667c17 228 ['W']= S1+S3+S5,
ThunderSoft 0:293917667c17 229 ['X']= NOT_7_NO_DP(S0+S3), // similar to H
ThunderSoft 0:293917667c17 230 ['Y']= NOT_7_NO_DP(S0+S4),
ThunderSoft 0:293917667c17 231 ['Z']= S0+S1+S6+S4+S3 // same as 2
ThunderSoft 0:293917667c17 232 };
ThunderSoft 0:293917667c17 233 #endif
ThunderSoft 0:293917667c17 234
ThunderSoft 0:293917667c17 235 #undef S0
ThunderSoft 0:293917667c17 236 #undef S1
ThunderSoft 0:293917667c17 237 #undef S2
ThunderSoft 0:293917667c17 238 #undef S3
ThunderSoft 0:293917667c17 239 #undef S4
ThunderSoft 0:293917667c17 240 #undef S5
ThunderSoft 0:293917667c17 241 #undef S6
ThunderSoft 0:293917667c17 242 #undef DP
ThunderSoft 0:293917667c17 243
ThunderSoft 0:293917667c17 244 #define DISPLAY_DELAY 1000 // in mSec
ThunderSoft 0:293917667c17 245
ThunderSoft 0:293917667c17 246 /* Classes -------------------------------------------------------------------*/
ThunderSoft 0:293917667c17 247 /** Class representing Display
ThunderSoft 0:293917667c17 248 */
ThunderSoft 0:293917667c17 249
ThunderSoft 0:293917667c17 250 class Display
ThunderSoft 0:293917667c17 251 {
ThunderSoft 0:293917667c17 252 public:
ThunderSoft 0:293917667c17 253 /** Constructor
ThunderSoft 0:293917667c17 254 * @param[in] &stmpe_1600 device handler to be used for display control
ThunderSoft 0:293917667c17 255 */
ThunderSoft 0:293917667c17 256 Display(STMPE1600 &stmpe_1600) : stmpe1600(stmpe_1600) {
ThunderSoft 0:293917667c17 257 stmpe1600.set_gpio_dir (GPIO_7, OUTPUT); // Digit1
ThunderSoft 0:293917667c17 258 stmpe1600.set_gpio_dir (GPIO_8, OUTPUT); // Digit2
ThunderSoft 0:293917667c17 259 stmpe1600.set_gpio_dir (GPIO_9, OUTPUT); // Digit3
ThunderSoft 0:293917667c17 260 stmpe1600.set_gpio_dir (GPIO_10, OUTPUT); // Digit4
ThunderSoft 0:293917667c17 261
ThunderSoft 0:293917667c17 262 stmpe1600.set_gpio_dir (GPIO_0, OUTPUT); // SegmentA
ThunderSoft 0:293917667c17 263 stmpe1600.set_gpio_dir (GPIO_1, OUTPUT); // SegmentB
ThunderSoft 0:293917667c17 264 stmpe1600.set_gpio_dir (GPIO_2, OUTPUT); // SegmentC
ThunderSoft 0:293917667c17 265 stmpe1600.set_gpio_dir (GPIO_3, OUTPUT); // SegmentD
ThunderSoft 0:293917667c17 266 stmpe1600.set_gpio_dir (GPIO_4, OUTPUT); // SegmentE
ThunderSoft 0:293917667c17 267 stmpe1600.set_gpio_dir (GPIO_5, OUTPUT); // SegmentF
ThunderSoft 0:293917667c17 268 stmpe1600.set_gpio_dir (GPIO_6, OUTPUT); // SegmentG
ThunderSoft 0:293917667c17 269
ThunderSoft 0:293917667c17 270 }
ThunderSoft 0:293917667c17 271
ThunderSoft 0:293917667c17 272 /*** Interface Methods ***/
ThunderSoft 0:293917667c17 273 /**
ThunderSoft 0:293917667c17 274 * @brief Print the string on display
ThunderSoft 0:293917667c17 275 * @param[in] String to be printed
ThunderSoft 0:293917667c17 276 * @param[in] String lenght [min 1, max 4]
ThunderSoft 0:293917667c17 277 * @return void
ThunderSoft 0:293917667c17 278 */
ThunderSoft 0:293917667c17 279 void display_string (char str[4], char strlen)
ThunderSoft 0:293917667c17 280 {
ThunderSoft 0:293917667c17 281 int i, dgt;
ThunderSoft 0:293917667c17 282 const char *pc;
ThunderSoft 0:293917667c17 283 uint8_t data[2];
ThunderSoft 0:293917667c17 284 uint16_t *pdata = (uint16_t*)data;
ThunderSoft 0:293917667c17 285
ThunderSoft 0:293917667c17 286 for (i=0, dgt=4-strlen, pc=str; i<strlen && *pc!=0; i++, pc++, dgt++) {
ThunderSoft 0:293917667c17 287 _V2_Set7Segment( ascii_to_display_lut[(uint8_t)*pc], dgt);
ThunderSoft 0:293917667c17 288 if ( *(pc+1)== '.') {
ThunderSoft 0:293917667c17 289 pc++;
ThunderSoft 0:293917667c17 290 }
ThunderSoft 0:293917667c17 291 wait_ms(DISPLAY_DELAY);
ThunderSoft 0:293917667c17 292 stmpe1600.read_16_bit_reg(GPSR_0_7, pdata);
ThunderSoft 0:293917667c17 293 *pdata = *pdata | (uint16_t)0x0780; // all digits off
ThunderSoft 0:293917667c17 294 stmpe1600.write_16_bit_reg(GPSR_0_7, pdata);
ThunderSoft 0:293917667c17 295 }
ThunderSoft 0:293917667c17 296 }
ThunderSoft 0:293917667c17 297
ThunderSoft 0:293917667c17 298 /**
ThunderSoft 0:293917667c17 299 * @brief Print the digit on display
ThunderSoft 0:293917667c17 300 * @param[in] Digit value to be printed
ThunderSoft 0:293917667c17 301 * @param[in] Digit to be used [min 0, max 3]
ThunderSoft 0:293917667c17 302 * @return void
ThunderSoft 0:293917667c17 303 */
ThunderSoft 0:293917667c17 304 void DisplayDigit (char val, char dgt)
ThunderSoft 0:293917667c17 305 {
ThunderSoft 0:293917667c17 306 uint8_t data[2];
ThunderSoft 0:293917667c17 307 uint16_t *pdata = (uint16_t*)data;
ThunderSoft 0:293917667c17 308
ThunderSoft 0:293917667c17 309 stmpe1600.read_16_bit_reg(GPSR_0_7, pdata);
ThunderSoft 0:293917667c17 310 *pdata = *pdata | (uint16_t)0x0780; // all digits off
ThunderSoft 0:293917667c17 311 stmpe1600.write_16_bit_reg(GPSR_0_7, pdata);
ThunderSoft 0:293917667c17 312 _V2_Set7Segment( ascii_to_display_lut[(uint8_t)val], dgt);
ThunderSoft 0:293917667c17 313 }
ThunderSoft 0:293917667c17 314
ThunderSoft 0:293917667c17 315 private:
ThunderSoft 0:293917667c17 316 void _V2_Set7Segment( int Leds, int digit )
ThunderSoft 0:293917667c17 317 {
ThunderSoft 0:293917667c17 318 //Digits_off();
ThunderSoft 0:293917667c17 319 uint16_t dgt;
ThunderSoft 0:293917667c17 320 dgt = 1<<digit;
ThunderSoft 0:293917667c17 321 dgt = ((uint16_t)dgt)<<7;
ThunderSoft 0:293917667c17 322 dgt = ~dgt;
ThunderSoft 0:293917667c17 323 uint8_t data[2];
ThunderSoft 0:293917667c17 324 uint16_t *pdata = (uint16_t*)data;
ThunderSoft 0:293917667c17 325
ThunderSoft 0:293917667c17 326
ThunderSoft 0:293917667c17 327 /* set the exppinname state to lvl */
ThunderSoft 0:293917667c17 328 stmpe1600.read_16_bit_reg(GPSR_0_7, pdata);
ThunderSoft 0:293917667c17 329 *pdata = *pdata | (uint16_t)0x007F; // 7 segments off
ThunderSoft 0:293917667c17 330 stmpe1600.write_16_bit_reg(GPSR_0_7, pdata);
ThunderSoft 0:293917667c17 331
ThunderSoft 0:293917667c17 332 int mask=1;
ThunderSoft 0:293917667c17 333 for (int i=0; i<7; i++) {
ThunderSoft 0:293917667c17 334 if (Leds & mask) *pdata = *pdata & ~(uint16_t)mask;
ThunderSoft 0:293917667c17 335 mask = mask<<1;
ThunderSoft 0:293917667c17 336 }
ThunderSoft 0:293917667c17 337 *pdata = *pdata & dgt;
ThunderSoft 0:293917667c17 338 stmpe1600.write_16_bit_reg(GPSR_0_7, pdata);
ThunderSoft 0:293917667c17 339 }
ThunderSoft 0:293917667c17 340 STMPE1600 &stmpe1600;
ThunderSoft 0:293917667c17 341 };
ThunderSoft 0:293917667c17 342
ThunderSoft 0:293917667c17 343 #ifdef __cplusplus
ThunderSoft 0:293917667c17 344 }
ThunderSoft 0:293917667c17 345 #endif
ThunderSoft 0:293917667c17 346 #endif // __DISPLAY_H
ThunderSoft 0:293917667c17 347