Now you can use NC as InterruptIn

Dependencies:   X_NUCLEO_COMMON

Fork of X_NUCLEO_6180XA1 by ST

Committer:
gallonm
Date:
Wed Oct 28 13:07:59 2015 +0000
Revision:
20:dd8390d615bf
Parent:
17:922c88827e4d
Child:
23:dfb5ccc7b780
Removed PollDelay and introduced simply wait_ms function.; Updated file platform.h.; Fixed all FIXME.; Fixed error printing.; Updated x_nucleo_6180xa1.cpp file.

Who changed what in which revision?

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