Now you can use NC as InterruptIn
Fork of X_NUCLEO_6180XA1 by
Components/Display/Display_class.h@23:dfb5ccc7b780, 2015-10-30 (annotated)
- Committer:
- gallonm
- Date:
- Fri Oct 30 11:35:36 2015 +0100
- Revision:
- 23:dfb5ccc7b780
- Parent:
- 20:dd8390d615bf
- Child:
- 28:7c9031e96c22
Updated Display_class.h
Updated stmpe1600_class.h
Updated vl6180x_class.cpp
Introduced comments on vl6180x_class.h and vl6180x_class.cpp
Updated x_nucleo_6180xa1.h
Who changed what in which revision?
User | Revision | Line number | New 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>© 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 | 23:dfb5ccc7b780 | 166 | STMPE1600DigiOut &D_A, STMPE1600DigiOut &D_B, STMPE1600DigiOut &D_C, STMPE1600DigiOut &D_D, |
gallonm | 23:dfb5ccc7b780 | 167 | STMPE1600DigiOut &D_E, STMPE1600DigiOut &D_F, STMPE1600DigiOut &D_G) |
gallonm | 23:dfb5ccc7b780 | 168 | : Display_D1(D1), Display_D2(D2), Display_D3(D3), Display_D4(D4), Display_A(D_A), Display_B(D_B), |
gallonm | 23:dfb5ccc7b780 | 169 | Display_C(D_C), Display_D(D_D), Display_E(D_E), Display_F(D_F), Display_G(D_G), dev_i2c(i2c) |
gallonm | 23:dfb5ccc7b780 | 170 | { |
gallonm | 23:dfb5ccc7b780 | 171 | pDisplay_DGT[0] = &Display_D1; |
gallonm | 23:dfb5ccc7b780 | 172 | pDisplay_DGT[1] = &Display_D2; |
gallonm | 23:dfb5ccc7b780 | 173 | pDisplay_DGT[2] = &Display_D3; |
gallonm | 23:dfb5ccc7b780 | 174 | pDisplay_DGT[3] = &Display_D4; |
gallonm | 23:dfb5ccc7b780 | 175 | pDisplay_SEG[0] = &Display_A; |
gallonm | 23:dfb5ccc7b780 | 176 | pDisplay_SEG[1] = &Display_B; |
gallonm | 23:dfb5ccc7b780 | 177 | pDisplay_SEG[2] = &Display_C; |
gallonm | 23:dfb5ccc7b780 | 178 | pDisplay_SEG[3] = &Display_D; |
gallonm | 23:dfb5ccc7b780 | 179 | pDisplay_SEG[4] = &Display_E; |
gallonm | 23:dfb5ccc7b780 | 180 | pDisplay_SEG[5] = &Display_F; |
gallonm | 23:dfb5ccc7b780 | 181 | pDisplay_SEG[6] = &Display_G; |
gallonm | 16:0d4776564733 | 182 | |
gallonm | 23:dfb5ccc7b780 | 183 | for (int i=0; i<4; i++) { *pDisplay_DGT[i]=1; } |
gallonm | 23:dfb5ccc7b780 | 184 | for (int i=0; i<7; i++) { *pDisplay_SEG[i]=1; } |
gallonm | 23:dfb5ccc7b780 | 185 | } |
gallonm | 16:0d4776564733 | 186 | #else |
gallonm | 16:0d4776564733 | 187 | Display(DevI2C &i2c) : dev_i2c(i2c) {} |
gallonm | 16:0d4776564733 | 188 | #endif |
gallonm | 16:0d4776564733 | 189 | |
gallonm | 16:0d4776564733 | 190 | #ifndef FAST_DISPLAY |
gallonm | 20:dd8390d615bf | 191 | void Digits_off (void) // all 4 digits off |
gallonm | 20:dd8390d615bf | 192 | { |
gallonm | 20:dd8390d615bf | 193 | Display_D1=1; |
gallonm | 20:dd8390d615bf | 194 | Display_D2=1; |
gallonm | 20:dd8390d615bf | 195 | Display_D3=1; |
gallonm | 20:dd8390d615bf | 196 | Display_D4=1; |
gallonm | 20:dd8390d615bf | 197 | } |
gallonm | 16:0d4776564733 | 198 | |
gallonm | 20:dd8390d615bf | 199 | void Digits_on (void) // all 4 digits on |
gallonm | 20:dd8390d615bf | 200 | { |
gallonm | 20:dd8390d615bf | 201 | Display_D1=0; |
gallonm | 20:dd8390d615bf | 202 | Display_D2=0; |
gallonm | 20:dd8390d615bf | 203 | Display_D3=0; |
gallonm | 20:dd8390d615bf | 204 | Display_D4=0; |
gallonm | 20:dd8390d615bf | 205 | } |
gallonm | 16:0d4776564733 | 206 | |
gallonm | 20:dd8390d615bf | 207 | void Digit_on (int digit) // digits on |
gallonm | 20:dd8390d615bf | 208 | { |
gallonm | 20:dd8390d615bf | 209 | *pDisplay_DGT[digit] = 0; |
gallonm | 20:dd8390d615bf | 210 | } |
gallonm | 16:0d4776564733 | 211 | |
gallonm | 20:dd8390d615bf | 212 | void Digit_off (int digit) // digits on |
gallonm | 20:dd8390d615bf | 213 | { |
gallonm | 20:dd8390d615bf | 214 | *pDisplay_DGT[digit] = 1; |
gallonm | 20:dd8390d615bf | 215 | } |
gallonm | 16:0d4776564733 | 216 | |
gallonm | 20:dd8390d615bf | 217 | void Segments_off () // all 7 segments off |
gallonm | 20:dd8390d615bf | 218 | { |
gallonm | 20:dd8390d615bf | 219 | Display_A=1; |
gallonm | 20:dd8390d615bf | 220 | Display_B=1; |
gallonm | 20:dd8390d615bf | 221 | Display_C=1; |
gallonm | 20:dd8390d615bf | 222 | Display_D=1; |
gallonm | 20:dd8390d615bf | 223 | Display_E=1; |
gallonm | 20:dd8390d615bf | 224 | Display_F=1; |
gallonm | 20:dd8390d615bf | 225 | Display_G=1; |
gallonm | 20:dd8390d615bf | 226 | } |
gallonm | 16:0d4776564733 | 227 | |
gallonm | 20:dd8390d615bf | 228 | void Segment_off (int seg) // segment off |
gallonm | 20:dd8390d615bf | 229 | { |
gallonm | 20:dd8390d615bf | 230 | *pDisplay_SEG[seg] = 1; |
gallonm | 20:dd8390d615bf | 231 | } |
gallonm | 16:0d4776564733 | 232 | |
gallonm | 20:dd8390d615bf | 233 | void Segment_on (int seg) // segment on |
gallonm | 20:dd8390d615bf | 234 | { |
gallonm | 20:dd8390d615bf | 235 | *pDisplay_SEG[seg] = 0; |
gallonm | 20:dd8390d615bf | 236 | } |
gallonm | 16:0d4776564733 | 237 | |
gallonm | 16:0d4776564733 | 238 | |
gallonm | 20:dd8390d615bf | 239 | void DisplayString (char str[4]) |
gallonm | 20:dd8390d615bf | 240 | { |
gallonm | 20:dd8390d615bf | 241 | int i; |
gallonm | 20:dd8390d615bf | 242 | const char *pc; |
gallonm | 16:0d4776564733 | 243 | |
gallonm | 23:dfb5ccc7b780 | 244 | for( i=0, pc=str; i<4 && *pc!=0 ; i++, pc++) |
gallonm | 23:dfb5ccc7b780 | 245 | { |
gallonm | 20:dd8390d615bf | 246 | _V2_Set7Segment( ascii_to_display_lut[(uint8_t)*pc], i); |
gallonm | 23:dfb5ccc7b780 | 247 | if( *(pc+1)== '.') |
gallonm | 23:dfb5ccc7b780 | 248 | { |
gallonm | 23:dfb5ccc7b780 | 249 | pc++; |
gallonm | 20:dd8390d615bf | 250 | } |
gallonm | 20:dd8390d615bf | 251 | wait_ms(DISPLAY_DELAY); |
gallonm | 20:dd8390d615bf | 252 | Digits_off(); |
gallonm | 20:dd8390d615bf | 253 | } |
gallonm | 20:dd8390d615bf | 254 | } |
gallonm | 16:0d4776564733 | 255 | |
gallonm | 16:0d4776564733 | 256 | |
gallonm | 23:dfb5ccc7b780 | 257 | void _V2_Set7Segment( int Leds, int digit ) |
gallonm | 23:dfb5ccc7b780 | 258 | { |
gallonm | 20:dd8390d615bf | 259 | //Digits_off(); |
gallonm | 23:dfb5ccc7b780 | 260 | Segments_off(); // 7 seg off */ |
gallonm | 20:dd8390d615bf | 261 | int mask=1; |
gallonm | 23:dfb5ccc7b780 | 262 | for (int i=0; i<7; i++) |
gallonm | 23:dfb5ccc7b780 | 263 | { |
gallonm | 20:dd8390d615bf | 264 | if (Leds & mask) Segment_on(i); |
gallonm | 20:dd8390d615bf | 265 | mask = mask<<1; |
gallonm | 20:dd8390d615bf | 266 | } |
gallonm | 20:dd8390d615bf | 267 | Digit_on(digit); |
gallonm | 20:dd8390d615bf | 268 | } |
gallonm | 16:0d4776564733 | 269 | |
gallonm | 16:0d4776564733 | 270 | |
gallonm | 16:0d4776564733 | 271 | #else |
gallonm | 16:0d4776564733 | 272 | |
gallonm | 20:dd8390d615bf | 273 | void DisplayDigit (char *val, char dgt) |
gallonm | 20:dd8390d615bf | 274 | { |
gallonm | 20:dd8390d615bf | 275 | uint8_t data[2]; |
gallonm | 20:dd8390d615bf | 276 | uint16_t *pdata = (uint16_t*)data; |
gallonm | 23:dfb5ccc7b780 | 277 | dev_i2c.i2c_read(data, (uint8_t)STMPE1600_DEF_DEVICE_ADDRESS, (uint8_t)GPSR_0_7, 2); // GPSR_0_7 |
gallonm | 23:dfb5ccc7b780 | 278 | *pdata = *pdata | (uint16_t)0x0780; // all digits off |
gallonm | 23:dfb5ccc7b780 | 279 | dev_i2c.i2c_write(data, (uint8_t)STMPE1600_DEF_DEVICE_ADDRESS, (uint8_t)GPSR_0_7, 2); // GPSR_0_7 |
gallonm | 16:0d4776564733 | 280 | |
gallonm | 20:dd8390d615bf | 281 | _V2_Set7Segment( ascii_to_display_lut[(uint8_t)*val], dgt); |
gallonm | 20:dd8390d615bf | 282 | } |
gallonm | 16:0d4776564733 | 283 | |
gallonm | 20:dd8390d615bf | 284 | void DisplayString (char str[4], char strlen) |
gallonm | 20:dd8390d615bf | 285 | { |
gallonm | 20:dd8390d615bf | 286 | int i, dgt; |
gallonm | 20:dd8390d615bf | 287 | const char *pc; |
gallonm | 20:dd8390d615bf | 288 | uint8_t data[2]; |
gallonm | 20:dd8390d615bf | 289 | uint16_t *pdata = (uint16_t*)data; |
gallonm | 16:0d4776564733 | 290 | |
gallonm | 23:dfb5ccc7b780 | 291 | //dev_i2c.i2c_read(data, (uint8_t)STMPE1600_DEF_DEVICE_ADDRESS, (uint8_t)GPSR_0_7, 2); // GPSR_0_7 |
gallonm | 23:dfb5ccc7b780 | 292 | //*pdata = *pdata | (uint16_t)0x0780; // all digits off |
gallonm | 23:dfb5ccc7b780 | 293 | //dev_i2c.i2c_write(data, (uint8_t)STMPE1600_DEF_DEVICE_ADDRESS, (uint8_t)GPSR_0_7, 2); // GPSR_0_7 |
gallonm | 16:0d4776564733 | 294 | |
gallonm | 23:dfb5ccc7b780 | 295 | for(i=0, dgt=4-strlen, pc=str; i<strlen && *pc!=0; i++, pc++, dgt++) |
gallonm | 23:dfb5ccc7b780 | 296 | { |
gallonm | 23:dfb5ccc7b780 | 297 | _V2_Set7Segment( ascii_to_display_lut[(uint8_t)*pc], dgt); |
gallonm | 23:dfb5ccc7b780 | 298 | if( *(pc+1)== '.') |
gallonm | 23:dfb5ccc7b780 | 299 | { |
gallonm | 23:dfb5ccc7b780 | 300 | pc++; |
gallonm | 23:dfb5ccc7b780 | 301 | } |
gallonm | 23:dfb5ccc7b780 | 302 | wait_ms(DISPLAY_DELAY); |
gallonm | 23:dfb5ccc7b780 | 303 | dev_i2c.i2c_read(data, (uint8_t)STMPE1600_DEF_DEVICE_ADDRESS, (uint8_t)GPSR_0_7, 2); // GPSR_0_7 |
gallonm | 23:dfb5ccc7b780 | 304 | *pdata = *pdata | (uint16_t)0x0780; // all digits off |
gallonm | 23:dfb5ccc7b780 | 305 | dev_i2c.i2c_write(data, (uint8_t)STMPE1600_DEF_DEVICE_ADDRESS, (uint8_t)GPSR_0_7, 2); // GPSR_0_7 |
gallonm | 20:dd8390d615bf | 306 | } |
gallonm | 20:dd8390d615bf | 307 | } |
gallonm | 16:0d4776564733 | 308 | |
gallonm | 16:0d4776564733 | 309 | |
gallonm | 23:dfb5ccc7b780 | 310 | void _V2_Set7Segment( int Leds, int digit ) |
gallonm | 23:dfb5ccc7b780 | 311 | { |
gallonm | 20:dd8390d615bf | 312 | //Digits_off(); |
gallonm | 20:dd8390d615bf | 313 | uint16_t dgt; |
gallonm | 20:dd8390d615bf | 314 | dgt = 1<<digit; |
gallonm | 20:dd8390d615bf | 315 | dgt = ((uint16_t)dgt)<<7; |
gallonm | 20:dd8390d615bf | 316 | dgt = ~dgt; |
gallonm | 20:dd8390d615bf | 317 | uint8_t data[2]; |
gallonm | 20:dd8390d615bf | 318 | uint16_t *pdata = (uint16_t*)data; |
gallonm | 16:0d4776564733 | 319 | |
gallonm | 16:0d4776564733 | 320 | |
gallonm | 20:dd8390d615bf | 321 | /* set the exppinname state to lvl */ |
gallonm | 20:dd8390d615bf | 322 | dev_i2c.i2c_read(data, (uint8_t)STMPE1600_DEF_DEVICE_ADDRESS, (uint8_t)GPSR_0_7, 2); // GPSR_0_7 |
gallonm | 20:dd8390d615bf | 323 | *pdata = *pdata | (uint16_t)0x007F; // 7 segments off |
gallonm | 20:dd8390d615bf | 324 | dev_i2c.i2c_write(data, (uint8_t)STMPE1600_DEF_DEVICE_ADDRESS, (uint8_t)GPSR_0_7, 2); // GPSR_0_7 |
gallonm | 16:0d4776564733 | 325 | |
gallonm | 20:dd8390d615bf | 326 | int mask=1; |
gallonm | 23:dfb5ccc7b780 | 327 | for (int i=0; i<7; i++) |
gallonm | 23:dfb5ccc7b780 | 328 | { |
gallonm | 20:dd8390d615bf | 329 | if (Leds & mask) *pdata = *pdata & ~(uint16_t)mask; |
gallonm | 20:dd8390d615bf | 330 | mask = mask<<1; |
gallonm | 20:dd8390d615bf | 331 | } |
gallonm | 20:dd8390d615bf | 332 | *pdata = *pdata & dgt; |
gallonm | 20:dd8390d615bf | 333 | dev_i2c.i2c_write(data, (uint8_t)STMPE1600_DEF_DEVICE_ADDRESS, (uint8_t)GPSR_0_7, 2); // GPSR_0_7 |
gallonm | 23:dfb5ccc7b780 | 334 | } |
gallonm | 16:0d4776564733 | 335 | #endif |
gallonm | 16:0d4776564733 | 336 | |
gallonm | 16:0d4776564733 | 337 | |
gallonm | 16:0d4776564733 | 338 | private: |
gallonm | 16:0d4776564733 | 339 | |
gallonm | 16:0d4776564733 | 340 | #ifndef FAST_DISPLAY |
gallonm | 23:dfb5ccc7b780 | 341 | STMPE1600DigiOut &Display_D1; |
gallonm | 23:dfb5ccc7b780 | 342 | STMPE1600DigiOut &Display_D2; |
gallonm | 23:dfb5ccc7b780 | 343 | STMPE1600DigiOut &Display_D3; |
gallonm | 23:dfb5ccc7b780 | 344 | STMPE1600DigiOut &Display_D4; |
gallonm | 23:dfb5ccc7b780 | 345 | STMPE1600DigiOut *pDisplay_DGT[4]; // the 4 display digits |
gallonm | 16:0d4776564733 | 346 | |
gallonm | 23:dfb5ccc7b780 | 347 | STMPE1600DigiOut &Display_A; |
gallonm | 23:dfb5ccc7b780 | 348 | STMPE1600DigiOut &Display_B; |
gallonm | 23:dfb5ccc7b780 | 349 | STMPE1600DigiOut &Display_C; |
gallonm | 23:dfb5ccc7b780 | 350 | STMPE1600DigiOut &Display_D; |
gallonm | 23:dfb5ccc7b780 | 351 | STMPE1600DigiOut &Display_E; |
gallonm | 23:dfb5ccc7b780 | 352 | STMPE1600DigiOut &Display_F; |
gallonm | 23:dfb5ccc7b780 | 353 | STMPE1600DigiOut &Display_G; |
gallonm | 23:dfb5ccc7b780 | 354 | STMPE1600DigiOut *pDisplay_SEG[7]; // the 7 digit segmments |
gallonm | 16:0d4776564733 | 355 | #endif |
gallonm | 23:dfb5ccc7b780 | 356 | DevI2C &dev_i2c; |
gallonm | 7:2dc81120c917 | 357 | }; |
gallonm | 7:2dc81120c917 | 358 | |
gallonm | 16:0d4776564733 | 359 | #ifdef __cplusplus |
gallonm | 16:0d4776564733 | 360 | } |
gallonm | 16:0d4776564733 | 361 | #endif |
gallonm | 17:922c88827e4d | 362 | #endif // __DISPLAY_H |