Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of X_NUCLEO_6180XA1 by
Components/Display/Display_class.h@39:3cce4ba37695, 2016-01-18 (annotated)
- Committer:
- mapellil
- Date:
- Mon Jan 18 15:11:01 2016 +0000
- Revision:
- 39:3cce4ba37695
- Parent:
- 36:f6278b3e7c82
Fixed array init gcc compilation issue in Display.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 DP (1<<7) |
| gallonm | 16:0d4776564733 | 51 | #define NOT_7_NO_DP( ... ) (uint8_t) ~( __VA_ARGS__ + DP ) |
| gallonm | 16:0d4776564733 | 52 | #define S0 (1<<0) |
| gallonm | 16:0d4776564733 | 53 | #define S1 (1<<1) |
| gallonm | 16:0d4776564733 | 54 | #define S2 (1<<2) |
| gallonm | 16:0d4776564733 | 55 | #define S3 (1<<3) |
| gallonm | 16:0d4776564733 | 56 | #define S4 (1<<4) |
| gallonm | 16:0d4776564733 | 57 | #define S5 (1<<5) |
| gallonm | 16:0d4776564733 | 58 | #define S6 (1<<6) |
| gallonm | 16:0d4776564733 | 59 | |
| mapellil | 39:3cce4ba37695 | 60 | #ifndef __cpluplus |
| mapellil | 39:3cce4ba37695 | 61 | /* refer to http://www.twyman.org.uk/Fonts/ */ |
| mapellil | 39:3cce4ba37695 | 62 | static const uint8_t ascii_to_display_lut[256]={ |
| mapellil | 39:3cce4ba37695 | 63 | 0,0,0,0,0,0,0,0, |
| mapellil | 39:3cce4ba37695 | 64 | 0,0,0,0,0,0,0,0, |
| mapellil | 39:3cce4ba37695 | 65 | 0,0,0,0,0,0,0,0, |
| mapellil | 39:3cce4ba37695 | 66 | 0,0,0,0,0,0,0,0, |
| mapellil | 39:3cce4ba37695 | 67 | [32]= 0, |
| mapellil | 39:3cce4ba37695 | 68 | 0,0,0,0,0,0,0,0, |
| mapellil | 39:3cce4ba37695 | 69 | 0, |
| mapellil | 39:3cce4ba37695 | 70 | [42]= NOT_7_NO_DP(), |
| mapellil | 39:3cce4ba37695 | 71 | 0,0, |
| mapellil | 39:3cce4ba37695 | 72 | [45]= S6, |
| mapellil | 39:3cce4ba37695 | 73 | 0,0, |
| mapellil | 39:3cce4ba37695 | 74 | [48]= NOT_7_NO_DP(S6), |
| mapellil | 39:3cce4ba37695 | 75 | [49]= S1+S2, |
| mapellil | 39:3cce4ba37695 | 76 | [50]= S0+S1+S6+S4+S3, |
| mapellil | 39:3cce4ba37695 | 77 | [51]= NOT_7_NO_DP(S4+S5), |
| mapellil | 39:3cce4ba37695 | 78 | [52]= S5+S1+S6+S2, |
| mapellil | 39:3cce4ba37695 | 79 | [53]= NOT_7_NO_DP(S1+S4), |
| mapellil | 39:3cce4ba37695 | 80 | [54]= NOT_7_NO_DP(S1), |
| mapellil | 39:3cce4ba37695 | 81 | [55]= S0+S1+S2, |
| mapellil | 39:3cce4ba37695 | 82 | [56]= NOT_7_NO_DP(0), |
| mapellil | 39:3cce4ba37695 | 83 | [57]= NOT_7_NO_DP(S4), |
| mapellil | 39:3cce4ba37695 | 84 | 0,0,0, |
| mapellil | 39:3cce4ba37695 | 85 | [61]= S3+S6, |
| mapellil | 39:3cce4ba37695 | 86 | 0, |
| mapellil | 39:3cce4ba37695 | 87 | [63]= NOT_7_NO_DP(S5+S3+S2), |
| mapellil | 39:3cce4ba37695 | 88 | [64]= S0+S3, |
| mapellil | 39:3cce4ba37695 | 89 | [65]= NOT_7_NO_DP(S3), |
| mapellil | 39:3cce4ba37695 | 90 | [66]= NOT_7_NO_DP(S0+S1), /* as b */ |
| mapellil | 39:3cce4ba37695 | 91 | [67]= S0+S3+S4+S5, // same as [ |
| mapellil | 39:3cce4ba37695 | 92 | [68]= S0+S3+S4+S5, // same as [ DUMMY |
| mapellil | 39:3cce4ba37695 | 93 | [69]= NOT_7_NO_DP(S1+S2), |
| mapellil | 39:3cce4ba37695 | 94 | [70]= S6+S5+S4+S0, |
| mapellil | 39:3cce4ba37695 | 95 | [71]= NOT_7_NO_DP(S4), /* same as 9 */ |
| mapellil | 39:3cce4ba37695 | 96 | [72]= NOT_7_NO_DP(S0+S3), |
| mapellil | 39:3cce4ba37695 | 97 | [73]= S1+S2, |
| mapellil | 39:3cce4ba37695 | 98 | [74]= S1+S2+S3+S4, |
| mapellil | 39:3cce4ba37695 | 99 | [75]= NOT_7_NO_DP(S0+S3), /* same as H */ |
| mapellil | 39:3cce4ba37695 | 100 | [76]= S3+S4+S5, |
| mapellil | 39:3cce4ba37695 | 101 | [77]= S0+S4+S2, /* same as m*/ |
| mapellil | 39:3cce4ba37695 | 102 | [78]= S2+S4+S6, /* same as n*/ |
| mapellil | 39:3cce4ba37695 | 103 | [79]= NOT_7_NO_DP(S6), |
| mapellil | 39:3cce4ba37695 | 104 | [80]= S0+S1+S2+S5+S6, // sames as 'q' |
| mapellil | 39:3cce4ba37695 | 105 | [81]= NOT_7_NO_DP(S3+S2), |
| mapellil | 39:3cce4ba37695 | 106 | [82]= S4+S6, |
| mapellil | 39:3cce4ba37695 | 107 | [83]= NOT_7_NO_DP(S1+S4), /* sasme as 5 */ |
| mapellil | 39:3cce4ba37695 | 108 | [84]= NOT_7_NO_DP(S0+S1+S2), /* sasme as t */ |
| mapellil | 39:3cce4ba37695 | 109 | [85]= NOT_7_NO_DP(S6+S0), |
| mapellil | 39:3cce4ba37695 | 110 | [86]= S4+S3+S2, // is u but u use U |
| mapellil | 39:3cce4ba37695 | 111 | [87]= S1+S3+S5, |
| mapellil | 39:3cce4ba37695 | 112 | [88]= NOT_7_NO_DP(S0+S3), // similar to H |
| mapellil | 39:3cce4ba37695 | 113 | [89]= NOT_7_NO_DP(S0+S4), |
| mapellil | 39:3cce4ba37695 | 114 | [90]= S0+S1+S6+S4+S3, // same as 2 |
| mapellil | 39:3cce4ba37695 | 115 | [91]= S0+S3+S4+S5, |
| mapellil | 39:3cce4ba37695 | 116 | 0, |
| mapellil | 39:3cce4ba37695 | 117 | [93]= S0+S3+S2+S1, |
| mapellil | 39:3cce4ba37695 | 118 | [94]= S0, /* use as top bar */ |
| mapellil | 39:3cce4ba37695 | 119 | [95]= S3, |
| mapellil | 39:3cce4ba37695 | 120 | 0, |
| mapellil | 39:3cce4ba37695 | 121 | [97]= S2+ S3+ S4+ S6 , |
| mapellil | 39:3cce4ba37695 | 122 | [98]= NOT_7_NO_DP(S0+S1), |
| mapellil | 39:3cce4ba37695 | 123 | [99]= S6+S4+S3, |
| mapellil | 39:3cce4ba37695 | 124 | [100]= NOT_7_NO_DP(S0+S5), |
| mapellil | 39:3cce4ba37695 | 125 | [101]= NOT_7_NO_DP(S2), |
| mapellil | 39:3cce4ba37695 | 126 | [102]= S6+S5+S4+S0, /* same as F */ |
| mapellil | 39:3cce4ba37695 | 127 | [103]= NOT_7_NO_DP(S4), /* same as 9 */ |
| mapellil | 39:3cce4ba37695 | 128 | [104]= S6+S5+S4+S2, |
| mapellil | 39:3cce4ba37695 | 129 | [105]= S4, |
| mapellil | 39:3cce4ba37695 | 130 | [106]= S1+S2+S3+S4, |
| mapellil | 39:3cce4ba37695 | 131 | [107]= S6+S5+S4+S2, /* a h */ |
| mapellil | 39:3cce4ba37695 | 132 | [108]= S3+S4, |
| mapellil | 39:3cce4ba37695 | 133 | [109]= S0+S4+S2, /* same as */ |
| mapellil | 39:3cce4ba37695 | 134 | [110]= S2+S4+S6, |
| mapellil | 39:3cce4ba37695 | 135 | [111]= S6+S4+S3+S2, |
| mapellil | 39:3cce4ba37695 | 136 | [112]= NOT_7_NO_DP(S3+S2), // same as P |
| mapellil | 39:3cce4ba37695 | 137 | [113]= S0+S1+S2+S5+S6, |
| mapellil | 39:3cce4ba37695 | 138 | [114]= S4+S6, |
| mapellil | 39:3cce4ba37695 | 139 | [115]= NOT_7_NO_DP(S1+S4), |
| mapellil | 39:3cce4ba37695 | 140 | [116]= NOT_7_NO_DP(S0+S1+S2), |
| mapellil | 39:3cce4ba37695 | 141 | [117]= S4+S3+S2+S5+S1, // U |
| mapellil | 39:3cce4ba37695 | 142 | [118]= S4+S3+S2, // is u but u use U |
| mapellil | 39:3cce4ba37695 | 143 | [119]= S1+S3+S5, |
| mapellil | 39:3cce4ba37695 | 144 | [120]= NOT_7_NO_DP(S0+S3), // similar to H |
| mapellil | 39:3cce4ba37695 | 145 | [121]= NOT_7_NO_DP(S0+S4), |
| mapellil | 39:3cce4ba37695 | 146 | [122]= S0+S1+S6+S4+S3, // same as 2 |
| mapellil | 39:3cce4ba37695 | 147 | 0,0,0, |
| mapellil | 39:3cce4ba37695 | 148 | [126]= S0+S3+S6 /* 3 h bar */ |
| mapellil | 39:3cce4ba37695 | 149 | }; |
| mapellil | 39:3cce4ba37695 | 150 | #else |
| gallonm | 16:0d4776564733 | 151 | /* refer to http://www.twyman.org.uk/Fonts/ */ |
| gallonm | 16:0d4776564733 | 152 | static const uint8_t ascii_to_display_lut[256]={ |
| gallonm | 16:0d4776564733 | 153 | [' ']= 0, |
| gallonm | 16:0d4776564733 | 154 | ['-']= S6, |
| gallonm | 16:0d4776564733 | 155 | ['_']= S3, |
| gallonm | 16:0d4776564733 | 156 | ['=']= S3+S6, |
| gallonm | 16:0d4776564733 | 157 | ['~']= S0+S3+S6, /* 3 h bar */ |
| gallonm | 16:0d4776564733 | 158 | ['^']= S0, /* use as top bar */ |
| gallonm | 16:0d4776564733 | 159 | |
| gallonm | 16:0d4776564733 | 160 | ['?']= NOT_7_NO_DP(S5+S3+S2), |
| gallonm | 16:0d4776564733 | 161 | ['*']= NOT_7_NO_DP(), |
| gallonm | 16:0d4776564733 | 162 | ['[']= S0+S3+S4+S5, |
| gallonm | 16:0d4776564733 | 163 | [']']= S0+S3+S2+S1, |
| gallonm | 16:0d4776564733 | 164 | ['@']= S0+S3, |
| gallonm | 16:0d4776564733 | 165 | |
| gallonm | 16:0d4776564733 | 166 | ['0']= NOT_7_NO_DP(S6), |
| gallonm | 16:0d4776564733 | 167 | ['1']= S1+S2, |
| gallonm | 16:0d4776564733 | 168 | ['2']= S0+S1+S6+S4+S3, |
| gallonm | 16:0d4776564733 | 169 | ['3']= NOT_7_NO_DP(S4+S5), |
| gallonm | 16:0d4776564733 | 170 | ['4']= S5+S1+S6+S2, |
| gallonm | 16:0d4776564733 | 171 | ['5']= NOT_7_NO_DP(S1+S4), |
| gallonm | 16:0d4776564733 | 172 | ['6']= NOT_7_NO_DP(S1), |
| gallonm | 16:0d4776564733 | 173 | ['7']= S0+S1+S2, |
| gallonm | 16:0d4776564733 | 174 | ['8']= NOT_7_NO_DP(0), |
| gallonm | 16:0d4776564733 | 175 | ['9']= NOT_7_NO_DP(S4), |
| gallonm | 16:0d4776564733 | 176 | |
| gallonm | 16:0d4776564733 | 177 | ['a']= S2+ S3+ S4+ S6 , |
| gallonm | 16:0d4776564733 | 178 | ['b']= NOT_7_NO_DP(S0+S1), |
| gallonm | 16:0d4776564733 | 179 | ['c']= S6+S4+S3, |
| gallonm | 16:0d4776564733 | 180 | ['d']= NOT_7_NO_DP(S0+S5), |
| gallonm | 16:0d4776564733 | 181 | ['e']= NOT_7_NO_DP(S2), |
| gallonm | 16:0d4776564733 | 182 | ['f']= S6+S5+S4+S0, /* same as F */ |
| gallonm | 16:0d4776564733 | 183 | ['g']= NOT_7_NO_DP(S4), /* same as 9 */ |
| gallonm | 16:0d4776564733 | 184 | ['h']= S6+S5+S4+S2, |
| gallonm | 16:0d4776564733 | 185 | ['i']= S4, |
| gallonm | 16:0d4776564733 | 186 | ['j']= S1+S2+S3+S4, |
| gallonm | 16:0d4776564733 | 187 | ['k']= S6+S5+S4+S2, /* a h */ |
| gallonm | 16:0d4776564733 | 188 | ['l']= S3+S4, |
| gallonm | 16:0d4776564733 | 189 | ['m']= S0+S4+S2, /* same as */ |
| gallonm | 16:0d4776564733 | 190 | ['n']= S2+S4+S6, |
| gallonm | 16:0d4776564733 | 191 | ['o']= S6+S4+S3+S2, |
| gallonm | 16:0d4776564733 | 192 | ['p']= NOT_7_NO_DP(S3+S2), // same as P |
| gallonm | 16:0d4776564733 | 193 | ['q']= S0+S1+S2+S5+S6, |
| gallonm | 16:0d4776564733 | 194 | ['r']= S4+S6, |
| gallonm | 16:0d4776564733 | 195 | ['s']= NOT_7_NO_DP(S1+S4), |
| gallonm | 16:0d4776564733 | 196 | ['t']= NOT_7_NO_DP(S0+S1+S2), |
| gallonm | 16:0d4776564733 | 197 | ['u']= S4+S3+S2+S5+S1, // U |
| gallonm | 16:0d4776564733 | 198 | ['v']= S4+S3+S2, // is u but u use U |
| gallonm | 16:0d4776564733 | 199 | ['w']= S1+S3+S5, |
| gallonm | 16:0d4776564733 | 200 | ['x']= NOT_7_NO_DP(S0+S3), // similar to H |
| gallonm | 16:0d4776564733 | 201 | ['y']= NOT_7_NO_DP(S0+S4), |
| gallonm | 16:0d4776564733 | 202 | ['z']= S0+S1+S6+S4+S3, // same as 2 |
| gallonm | 16:0d4776564733 | 203 | |
| gallonm | 16:0d4776564733 | 204 | ['A']= NOT_7_NO_DP(S3), |
| gallonm | 16:0d4776564733 | 205 | ['B']= NOT_7_NO_DP(S0+S1), /* as b */ |
| gallonm | 16:0d4776564733 | 206 | ['C']= S0+S3+S4+S5, // same as [ |
| gallonm | 16:0d4776564733 | 207 | ['E']= NOT_7_NO_DP(S1+S2), |
| gallonm | 16:0d4776564733 | 208 | ['F']= S6+S5+S4+S0, |
| gallonm | 16:0d4776564733 | 209 | ['G']= NOT_7_NO_DP(S4), /* same as 9 */ |
| gallonm | 16:0d4776564733 | 210 | ['H']= NOT_7_NO_DP(S0+S3), |
| gallonm | 16:0d4776564733 | 211 | ['I']= S1+S2, |
| gallonm | 16:0d4776564733 | 212 | ['J']= S1+S2+S3+S4, |
| gallonm | 16:0d4776564733 | 213 | ['K']= NOT_7_NO_DP(S0+S3), /* same as H */ |
| gallonm | 16:0d4776564733 | 214 | ['L']= S3+S4+S5, |
| gallonm | 16:0d4776564733 | 215 | ['M']= S0+S4+S2, /* same as m*/ |
| gallonm | 16:0d4776564733 | 216 | ['N']= S2+S4+S6, /* same as n*/ |
| gallonm | 16:0d4776564733 | 217 | ['O']= NOT_7_NO_DP(S6), |
| gallonm | 16:0d4776564733 | 218 | ['P']= S0+S1+S2+S5+S6, // sames as 'q' |
| gallonm | 16:0d4776564733 | 219 | ['Q']= NOT_7_NO_DP(S3+S2), |
| gallonm | 16:0d4776564733 | 220 | ['R']= S4+S6, |
| gallonm | 16:0d4776564733 | 221 | ['S']= NOT_7_NO_DP(S1+S4), /* sasme as 5 */ |
| gallonm | 16:0d4776564733 | 222 | ['T']= NOT_7_NO_DP(S0+S1+S2), /* sasme as t */ |
| gallonm | 16:0d4776564733 | 223 | ['U']= NOT_7_NO_DP(S6+S0), |
| gallonm | 16:0d4776564733 | 224 | ['V']= S4+S3+S2, // is u but u use U |
| gallonm | 16:0d4776564733 | 225 | ['W']= S1+S3+S5, |
| gallonm | 16:0d4776564733 | 226 | ['X']= NOT_7_NO_DP(S0+S3), // similar to H |
| gallonm | 16:0d4776564733 | 227 | ['Y']= NOT_7_NO_DP(S0+S4), |
| mapellil | 39:3cce4ba37695 | 228 | ['Z']= S0+S1+S6+S4+S3 // same as 2 |
| gallonm | 16:0d4776564733 | 229 | }; |
| mapellil | 39:3cce4ba37695 | 230 | #endif |
| gallonm | 16:0d4776564733 | 231 | |
| gallonm | 16:0d4776564733 | 232 | #undef S0 |
| gallonm | 16:0d4776564733 | 233 | #undef S1 |
| gallonm | 16:0d4776564733 | 234 | #undef S2 |
| gallonm | 16:0d4776564733 | 235 | #undef S3 |
| gallonm | 16:0d4776564733 | 236 | #undef S4 |
| gallonm | 16:0d4776564733 | 237 | #undef S5 |
| gallonm | 16:0d4776564733 | 238 | #undef S6 |
| gallonm | 16:0d4776564733 | 239 | #undef DP |
| gallonm | 16:0d4776564733 | 240 | |
| gallonm | 16:0d4776564733 | 241 | #define DISPLAY_DELAY 1 // in mSec |
| gallonm | 7:2dc81120c917 | 242 | |
| gallonm | 7:2dc81120c917 | 243 | /* Classes -------------------------------------------------------------------*/ |
| gallonm | 16:0d4776564733 | 244 | /** Class representing Display |
| gallonm | 16:0d4776564733 | 245 | */ |
| licio.mapelli@st.com | 33:1573db91352c | 246 | |
| gallonm | 16:0d4776564733 | 247 | class Display |
| gallonm | 7:2dc81120c917 | 248 | { |
| gallonm | 7:2dc81120c917 | 249 | public: |
| mapellil | 36:f6278b3e7c82 | 250 | /** Constructor |
| mapellil | 36:f6278b3e7c82 | 251 | * @param[in] &stmpe_1600 device handler to be used for display control |
| mapellil | 36:f6278b3e7c82 | 252 | */ |
| mapellil | 36:f6278b3e7c82 | 253 | Display(STMPE1600 &stmpe_1600) : stmpe1600(stmpe_1600) { |
| mapellil | 36:f6278b3e7c82 | 254 | stmpe1600.setGPIOdir (GPIO_7, OUTPUT); // Digit1 |
| mapellil | 36:f6278b3e7c82 | 255 | stmpe1600.setGPIOdir (GPIO_8, OUTPUT); // Digit2 |
| mapellil | 36:f6278b3e7c82 | 256 | stmpe1600.setGPIOdir (GPIO_9, OUTPUT); // Digit3 |
| mapellil | 36:f6278b3e7c82 | 257 | stmpe1600.setGPIOdir (GPIO_10, OUTPUT); // Digit4 |
| licio.mapelli@st.com | 33:1573db91352c | 258 | |
| mapellil | 36:f6278b3e7c82 | 259 | stmpe1600.setGPIOdir (GPIO_0, OUTPUT); // SegmentA |
| mapellil | 36:f6278b3e7c82 | 260 | stmpe1600.setGPIOdir (GPIO_1, OUTPUT); // SegmentB |
| mapellil | 36:f6278b3e7c82 | 261 | stmpe1600.setGPIOdir (GPIO_2, OUTPUT); // SegmentC |
| mapellil | 36:f6278b3e7c82 | 262 | stmpe1600.setGPIOdir (GPIO_3, OUTPUT); // SegmentD |
| mapellil | 36:f6278b3e7c82 | 263 | stmpe1600.setGPIOdir (GPIO_4, OUTPUT); // SegmentE |
| mapellil | 36:f6278b3e7c82 | 264 | stmpe1600.setGPIOdir (GPIO_5, OUTPUT); // SegmentF |
| mapellil | 36:f6278b3e7c82 | 265 | stmpe1600.setGPIOdir (GPIO_6, OUTPUT); // SegmentG |
| mapellil | 36:f6278b3e7c82 | 266 | } |
| mapellil | 36:f6278b3e7c82 | 267 | |
| mapellil | 36:f6278b3e7c82 | 268 | /*** Interface Methods ***/ |
| mapellil | 36:f6278b3e7c82 | 269 | /** |
| mapellil | 36:f6278b3e7c82 | 270 | * @brief Print the string on display |
| mapellil | 36:f6278b3e7c82 | 271 | * @param[in] String to be printed |
| mapellil | 36:f6278b3e7c82 | 272 | * @param[in] String lenght [min 1, max 4] |
| mapellil | 36:f6278b3e7c82 | 273 | * @return void |
| mapellil | 36:f6278b3e7c82 | 274 | */ |
| licio.mapelli@st.com | 33:1573db91352c | 275 | void DisplayString (char str[4], char strlen) |
| mapellil | 36:f6278b3e7c82 | 276 | { |
| licio.mapelli@st.com | 33:1573db91352c | 277 | int i, dgt; |
| licio.mapelli@st.com | 33:1573db91352c | 278 | const char *pc; |
| licio.mapelli@st.com | 33:1573db91352c | 279 | uint8_t data[2]; |
| licio.mapelli@st.com | 33:1573db91352c | 280 | uint16_t *pdata = (uint16_t*)data; |
| licio.mapelli@st.com | 33:1573db91352c | 281 | |
| licio.mapelli@st.com | 33:1573db91352c | 282 | for(i=0, dgt=4-strlen, pc=str; i<strlen && *pc!=0; i++, pc++, dgt++) |
| licio.mapelli@st.com | 33:1573db91352c | 283 | { |
| licio.mapelli@st.com | 33:1573db91352c | 284 | _V2_Set7Segment( ascii_to_display_lut[(uint8_t)*pc], dgt); |
| licio.mapelli@st.com | 33:1573db91352c | 285 | if( *(pc+1)== '.') |
| licio.mapelli@st.com | 33:1573db91352c | 286 | { |
| licio.mapelli@st.com | 33:1573db91352c | 287 | pc++; |
| licio.mapelli@st.com | 33:1573db91352c | 288 | } |
| licio.mapelli@st.com | 33:1573db91352c | 289 | wait_ms(DISPLAY_DELAY); |
| licio.mapelli@st.com | 33:1573db91352c | 290 | stmpe1600.read16bitReg(GPSR_0_7, pdata); |
| licio.mapelli@st.com | 33:1573db91352c | 291 | *pdata = *pdata | (uint16_t)0x0780; // all digits off |
| licio.mapelli@st.com | 33:1573db91352c | 292 | stmpe1600.write16bitReg(GPSR_0_7, pdata); |
| licio.mapelli@st.com | 33:1573db91352c | 293 | } |
| licio.mapelli@st.com | 33:1573db91352c | 294 | |
| mapellil | 36:f6278b3e7c82 | 295 | } |
| mapellil | 36:f6278b3e7c82 | 296 | |
| mapellil | 36:f6278b3e7c82 | 297 | /** |
| mapellil | 36:f6278b3e7c82 | 298 | * @brief Print the digit on display |
| mapellil | 36:f6278b3e7c82 | 299 | * @param[in] Digit value to be printed |
| mapellil | 36:f6278b3e7c82 | 300 | * @param[in] Digit to be used [min 0, max 3] |
| mapellil | 36:f6278b3e7c82 | 301 | * @return void |
| mapellil | 36:f6278b3e7c82 | 302 | */ |
| mapellil | 36:f6278b3e7c82 | 303 | void DisplayDigit (char *val, char dgt) |
| mapellil | 36:f6278b3e7c82 | 304 | { |
| licio.mapelli@st.com | 34:5bcffb4c5b47 | 305 | uint8_t data[2]; |
| licio.mapelli@st.com | 34:5bcffb4c5b47 | 306 | uint16_t *pdata = (uint16_t*)data; |
| licio.mapelli@st.com | 34:5bcffb4c5b47 | 307 | |
| mapellil | 36:f6278b3e7c82 | 308 | stmpe1600.read16bitReg(GPSR_0_7, pdata); |
| licio.mapelli@st.com | 34:5bcffb4c5b47 | 309 | *pdata = *pdata | (uint16_t)0x0780; // all digits off |
| mapellil | 36:f6278b3e7c82 | 310 | stmpe1600.write16bitReg(GPSR_0_7, pdata); |
| licio.mapelli@st.com | 34:5bcffb4c5b47 | 311 | _V2_Set7Segment( ascii_to_display_lut[(uint8_t)*val], dgt); |
| mapellil | 36:f6278b3e7c82 | 312 | } |
| licio.mapelli@st.com | 34:5bcffb4c5b47 | 313 | |
| mapellil | 36:f6278b3e7c82 | 314 | private: |
| mapellil | 36:f6278b3e7c82 | 315 | void _V2_Set7Segment( int Leds, int digit ) |
| mapellil | 36:f6278b3e7c82 | 316 | { |
| licio.mapelli@st.com | 33:1573db91352c | 317 | //Digits_off(); |
| licio.mapelli@st.com | 33:1573db91352c | 318 | uint16_t dgt; |
| licio.mapelli@st.com | 33:1573db91352c | 319 | dgt = 1<<digit; |
| licio.mapelli@st.com | 33:1573db91352c | 320 | dgt = ((uint16_t)dgt)<<7; |
| licio.mapelli@st.com | 33:1573db91352c | 321 | dgt = ~dgt; |
| licio.mapelli@st.com | 33:1573db91352c | 322 | uint8_t data[2]; |
| licio.mapelli@st.com | 33:1573db91352c | 323 | uint16_t *pdata = (uint16_t*)data; |
| licio.mapelli@st.com | 33:1573db91352c | 324 | |
| licio.mapelli@st.com | 33:1573db91352c | 325 | |
| licio.mapelli@st.com | 33:1573db91352c | 326 | /* set the exppinname state to lvl */ |
| mapellil | 36:f6278b3e7c82 | 327 | stmpe1600.read16bitReg(GPSR_0_7, pdata); |
| licio.mapelli@st.com | 33:1573db91352c | 328 | *pdata = *pdata | (uint16_t)0x007F; // 7 segments off |
| mapellil | 36:f6278b3e7c82 | 329 | stmpe1600.write16bitReg(GPSR_0_7, pdata); |
| licio.mapelli@st.com | 33:1573db91352c | 330 | |
| licio.mapelli@st.com | 33:1573db91352c | 331 | int mask=1; |
| licio.mapelli@st.com | 33:1573db91352c | 332 | for (int i=0; i<7; i++) |
| licio.mapelli@st.com | 33:1573db91352c | 333 | { |
| licio.mapelli@st.com | 33:1573db91352c | 334 | if (Leds & mask) *pdata = *pdata & ~(uint16_t)mask; |
| licio.mapelli@st.com | 33:1573db91352c | 335 | mask = mask<<1; |
| licio.mapelli@st.com | 33:1573db91352c | 336 | } |
| licio.mapelli@st.com | 33:1573db91352c | 337 | *pdata = *pdata & dgt; |
| mapellil | 36:f6278b3e7c82 | 338 | stmpe1600.write16bitReg(GPSR_0_7, pdata); |
| mapellil | 36:f6278b3e7c82 | 339 | } |
| mapellil | 36:f6278b3e7c82 | 340 | STMPE1600 &stmpe1600; |
| licio.mapelli@st.com | 33:1573db91352c | 341 | }; |
| licio.mapelli@st.com | 33:1573db91352c | 342 | |
| gallonm | 16:0d4776564733 | 343 | #ifdef __cplusplus |
| gallonm | 16:0d4776564733 | 344 | } |
| gallonm | 16:0d4776564733 | 345 | #endif |
| gallonm | 17:922c88827e4d | 346 | #endif // __DISPLAY_H |
