Library for use with VL53L0X, cut 1.1, based on mass-market API v1.1.
Dependencies: ST_INTERFACES X_NUCLEO_COMMON
Dependents: ConcorsoFinal HelloWorld_IHM01A1 m3pi_BT m3pi_LIDAR ... more
Fork of X_NUCLEO_53L0A1 by
X-NUCLEO-53L0A1 Proximity Sensor Expansion Board Firmware Package
Introduction
This firmware package includes Component Device Drivers and the Board Support Package for STMicroelectronics' X-NUCLEO-53L0A1 Proximity sensor expansion board based on VL53L0X.
Firmware Library
Class X_NUCLEO_53L0A1 is intended to represent the Proximity sensor expansion board with the same name.
The expansion board provides support for the following components:
- on-board VL53L0X proximity sensor,
- up to two additional VL53L0X Satellites,
- on-board 4-digit display
It is intentionally implemented as a singleton because only one X-NUCLEO-VL53L0A1 may be deployed at a time in a HW component stack. In order to get the singleton instance you have to call class method `Instance()`, e.g.:
// Sensors expansion board singleton instance static X_NUCLEO_53L0A1 *board = X_NUCLEO_53L0A1::Instance(device_i2c, A2, D8, D2);
Example Applications
- Hello World 53L0
- Display 53L0A1
- Display 53L0A1 Interrupts
- Display 53L0A1 with satellites
- 53L0A1 Satellites with Interrupts
- 53L0A1_HandGestureRecognition
The library and sample application code were tested against mbed revision 143, dated 26th May 2017.
Components/Display/Display_class.h@0:c523920bcc09, 2016-11-28 (annotated)
- Committer:
- johnAlexander
- Date:
- Mon Nov 28 11:25:33 2016 +0000
- Revision:
- 0:c523920bcc09
- Child:
- 9:367d1f390cb2
Singleshot, polled ranging example using central VL53L0X sensor.; Compatible with mass-market v1.1 C API.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
johnAlexander | 0:c523920bcc09 | 1 | /** |
johnAlexander | 0:c523920bcc09 | 2 | ****************************************************************************** |
johnAlexander | 0:c523920bcc09 | 3 | * @file Display.h |
johnAlexander | 0:c523920bcc09 | 4 | * @author AST / EST |
johnAlexander | 0:c523920bcc09 | 5 | * @version V0.0.1 |
johnAlexander | 0:c523920bcc09 | 6 | * @date 14-April-2015 |
johnAlexander | 0:c523920bcc09 | 7 | * @brief Header file for display |
johnAlexander | 0:c523920bcc09 | 8 | ****************************************************************************** |
johnAlexander | 0:c523920bcc09 | 9 | * @attention |
johnAlexander | 0:c523920bcc09 | 10 | * |
johnAlexander | 0:c523920bcc09 | 11 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
johnAlexander | 0:c523920bcc09 | 12 | * |
johnAlexander | 0:c523920bcc09 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
johnAlexander | 0:c523920bcc09 | 14 | * are permitted provided that the following conditions are met: |
johnAlexander | 0:c523920bcc09 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
johnAlexander | 0:c523920bcc09 | 16 | * this list of conditions and the following disclaimer. |
johnAlexander | 0:c523920bcc09 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
johnAlexander | 0:c523920bcc09 | 18 | * this list of conditions and the following disclaimer in the documentation |
johnAlexander | 0:c523920bcc09 | 19 | * and/or other materials provided with the distribution. |
johnAlexander | 0:c523920bcc09 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
johnAlexander | 0:c523920bcc09 | 21 | * may be used to endorse or promote products derived from this software |
johnAlexander | 0:c523920bcc09 | 22 | * without specific prior written permission. |
johnAlexander | 0:c523920bcc09 | 23 | * |
johnAlexander | 0:c523920bcc09 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
johnAlexander | 0:c523920bcc09 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
johnAlexander | 0:c523920bcc09 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
johnAlexander | 0:c523920bcc09 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
johnAlexander | 0:c523920bcc09 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
johnAlexander | 0:c523920bcc09 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
johnAlexander | 0:c523920bcc09 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
johnAlexander | 0:c523920bcc09 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
johnAlexander | 0:c523920bcc09 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
johnAlexander | 0:c523920bcc09 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
johnAlexander | 0:c523920bcc09 | 34 | * |
johnAlexander | 0:c523920bcc09 | 35 | ****************************************************************************** |
johnAlexander | 0:c523920bcc09 | 36 | */ |
johnAlexander | 0:c523920bcc09 | 37 | |
johnAlexander | 0:c523920bcc09 | 38 | #ifndef __DISPLAY_H |
johnAlexander | 0:c523920bcc09 | 39 | #define __DISPLAY_H |
johnAlexander | 0:c523920bcc09 | 40 | |
johnAlexander | 0:c523920bcc09 | 41 | /* Includes ------------------------------------------------------------------*/ |
johnAlexander | 0:c523920bcc09 | 42 | #include "mbed.h" |
johnAlexander | 0:c523920bcc09 | 43 | #include "stmpe1600_class.h" |
johnAlexander | 0:c523920bcc09 | 44 | #include "DevI2C.h" |
johnAlexander | 0:c523920bcc09 | 45 | |
johnAlexander | 0:c523920bcc09 | 46 | #ifdef __cplusplus |
johnAlexander | 0:c523920bcc09 | 47 | extern "C" { |
johnAlexander | 0:c523920bcc09 | 48 | #endif |
johnAlexander | 0:c523920bcc09 | 49 | |
johnAlexander | 0:c523920bcc09 | 50 | /** |
johnAlexander | 0:c523920bcc09 | 51 | * GPIO monitor pin state register |
johnAlexander | 0:c523920bcc09 | 52 | * 16 bit register LSB at lowest offset (little endian) |
johnAlexander | 0:c523920bcc09 | 53 | */ |
johnAlexander | 0:c523920bcc09 | 54 | #define GPMR 0x10 |
johnAlexander | 0:c523920bcc09 | 55 | /** |
johnAlexander | 0:c523920bcc09 | 56 | * STMPE1600 GPIO set pin state register |
johnAlexander | 0:c523920bcc09 | 57 | * 16 bit register LSB at lowest offset (little endian) |
johnAlexander | 0:c523920bcc09 | 58 | */ |
johnAlexander | 0:c523920bcc09 | 59 | #define GPSR 0x12 |
johnAlexander | 0:c523920bcc09 | 60 | /** |
johnAlexander | 0:c523920bcc09 | 61 | * STMPE1600 GPIO set pin direction register |
johnAlexander | 0:c523920bcc09 | 62 | * 16 bit register LSB at lowest offset |
johnAlexander | 0:c523920bcc09 | 63 | */ |
johnAlexander | 0:c523920bcc09 | 64 | #define GPDR 0x14 |
johnAlexander | 0:c523920bcc09 | 65 | |
johnAlexander | 0:c523920bcc09 | 66 | |
johnAlexander | 0:c523920bcc09 | 67 | /** |
johnAlexander | 0:c523920bcc09 | 68 | * cache the full set of expanded GPIO values to avoid i2c reading |
johnAlexander | 0:c523920bcc09 | 69 | */ |
johnAlexander | 0:c523920bcc09 | 70 | static union CurIOVal_u { |
johnAlexander | 0:c523920bcc09 | 71 | uint8_t bytes[4]; /*!< 4 bytes array i/o view */ |
johnAlexander | 0:c523920bcc09 | 72 | uint32_t u32; /*!< single dword i/o view */ |
johnAlexander | 0:c523920bcc09 | 73 | } |
johnAlexander | 0:c523920bcc09 | 74 | /** cache the extended IO values */ |
johnAlexander | 0:c523920bcc09 | 75 | CurIOVal; |
johnAlexander | 0:c523920bcc09 | 76 | |
johnAlexander | 0:c523920bcc09 | 77 | /** |
johnAlexander | 0:c523920bcc09 | 78 | * lookup table for digit to bit position |
johnAlexander | 0:c523920bcc09 | 79 | */ |
johnAlexander | 0:c523920bcc09 | 80 | static int DisplayBitPos[4]={0, 7, 16, 16+7}; |
johnAlexander | 0:c523920bcc09 | 81 | |
johnAlexander | 0:c523920bcc09 | 82 | /** |
johnAlexander | 0:c523920bcc09 | 83 | * @defgroup XNUCLEO53L0A1_7Segment 7 segment display |
johnAlexander | 0:c523920bcc09 | 84 | * |
johnAlexander | 0:c523920bcc09 | 85 | * macro use for human readable segment building |
johnAlexander | 0:c523920bcc09 | 86 | * @code |
johnAlexander | 0:c523920bcc09 | 87 | * --s0-- |
johnAlexander | 0:c523920bcc09 | 88 | * s s |
johnAlexander | 0:c523920bcc09 | 89 | * 5 1 |
johnAlexander | 0:c523920bcc09 | 90 | * --s6-- |
johnAlexander | 0:c523920bcc09 | 91 | * s s |
johnAlexander | 0:c523920bcc09 | 92 | * 4 2 |
johnAlexander | 0:c523920bcc09 | 93 | * --s3-- . s7 (dp) |
johnAlexander | 0:c523920bcc09 | 94 | * @endcode |
johnAlexander | 0:c523920bcc09 | 95 | * |
johnAlexander | 0:c523920bcc09 | 96 | * @{ |
johnAlexander | 0:c523920bcc09 | 97 | */ |
johnAlexander | 0:c523920bcc09 | 98 | /** decimal point bit mapping* */ |
johnAlexander | 0:c523920bcc09 | 99 | #define DP (1<<7) |
johnAlexander | 0:c523920bcc09 | 100 | |
johnAlexander | 0:c523920bcc09 | 101 | /** sgement s0 bit mapping*/ |
johnAlexander | 0:c523920bcc09 | 102 | #define S0 (1<<3) |
johnAlexander | 0:c523920bcc09 | 103 | /** sgement s1 bit mapping*/ |
johnAlexander | 0:c523920bcc09 | 104 | #define S1 (1<<5) |
johnAlexander | 0:c523920bcc09 | 105 | /** sgement s2 bit mapping*/ |
johnAlexander | 0:c523920bcc09 | 106 | #define S2 (1<<6) |
johnAlexander | 0:c523920bcc09 | 107 | /** sgement s3 bit mapping*/ |
johnAlexander | 0:c523920bcc09 | 108 | #define S3 (1<<4) |
johnAlexander | 0:c523920bcc09 | 109 | /** sgement s4 bit mapping*/ |
johnAlexander | 0:c523920bcc09 | 110 | #define S4 (1<<0) |
johnAlexander | 0:c523920bcc09 | 111 | /** sgement s5 bit mapping*/ |
johnAlexander | 0:c523920bcc09 | 112 | #define S5 (1<<1) |
johnAlexander | 0:c523920bcc09 | 113 | /** sgement s6 bit mapping*/ |
johnAlexander | 0:c523920bcc09 | 114 | #define S6 (1<<2) |
johnAlexander | 0:c523920bcc09 | 115 | |
johnAlexander | 0:c523920bcc09 | 116 | /** |
johnAlexander | 0:c523920bcc09 | 117 | * build a character by defining the non lighted segment (not one and no DP) |
johnAlexander | 0:c523920bcc09 | 118 | * |
johnAlexander | 0:c523920bcc09 | 119 | * @param ... literal sum and or combine of any macro to define any segment #S0 .. #S6 |
johnAlexander | 0:c523920bcc09 | 120 | * |
johnAlexander | 0:c523920bcc09 | 121 | * example '9' is all segment on but S4 |
johnAlexander | 0:c523920bcc09 | 122 | * @code |
johnAlexander | 0:c523920bcc09 | 123 | * ['9']= NOT_7_NO_DP(S4), |
johnAlexander | 0:c523920bcc09 | 124 | * @endcode |
johnAlexander | 0:c523920bcc09 | 125 | */ |
johnAlexander | 0:c523920bcc09 | 126 | #define NOT_7_NO_DP( ... ) (uint8_t) ~( __VA_ARGS__ + DP ) |
johnAlexander | 0:c523920bcc09 | 127 | |
johnAlexander | 0:c523920bcc09 | 128 | /** |
johnAlexander | 0:c523920bcc09 | 129 | * Ascii to 7 segment lookup table |
johnAlexander | 0:c523920bcc09 | 130 | * |
johnAlexander | 0:c523920bcc09 | 131 | * Most common character are supported and follow http://www.twyman.org.uk/Fonts/ |
johnAlexander | 0:c523920bcc09 | 132 | * few extra special \@ ^~ ... etc are present for specific demo purpose |
johnAlexander | 0:c523920bcc09 | 133 | */ |
johnAlexander | 0:c523920bcc09 | 134 | #ifndef __cpluplus |
johnAlexander | 0:c523920bcc09 | 135 | /* refer to http://www.twyman.org.uk/Fonts/ */ |
johnAlexander | 0:c523920bcc09 | 136 | static const uint8_t ascii_to_display_lut[256]={ |
johnAlexander | 0:c523920bcc09 | 137 | 0,0,0,0,0,0,0,0, |
johnAlexander | 0:c523920bcc09 | 138 | 0,0,0,0,0,0,0,0, |
johnAlexander | 0:c523920bcc09 | 139 | 0,0,0,0,0,0,0,0, |
johnAlexander | 0:c523920bcc09 | 140 | 0,0,0,0,0,0,0,0, |
johnAlexander | 0:c523920bcc09 | 141 | [32]= 0, |
johnAlexander | 0:c523920bcc09 | 142 | 0,0,0,0,0,0,0,0, |
johnAlexander | 0:c523920bcc09 | 143 | 0, |
johnAlexander | 0:c523920bcc09 | 144 | [42]= NOT_7_NO_DP(), |
johnAlexander | 0:c523920bcc09 | 145 | 0,0, |
johnAlexander | 0:c523920bcc09 | 146 | [45]= S6, |
johnAlexander | 0:c523920bcc09 | 147 | 0,0, |
johnAlexander | 0:c523920bcc09 | 148 | [48]= NOT_7_NO_DP(S6), |
johnAlexander | 0:c523920bcc09 | 149 | [49]= S1+S2, |
johnAlexander | 0:c523920bcc09 | 150 | [50]= S0+S1+S6+S4+S3, |
johnAlexander | 0:c523920bcc09 | 151 | [51]= NOT_7_NO_DP(S4+S5), |
johnAlexander | 0:c523920bcc09 | 152 | [52]= S5+S1+S6+S2, |
johnAlexander | 0:c523920bcc09 | 153 | [53]= NOT_7_NO_DP(S1+S4), |
johnAlexander | 0:c523920bcc09 | 154 | [54]= NOT_7_NO_DP(S1), |
johnAlexander | 0:c523920bcc09 | 155 | [55]= S0+S1+S2, |
johnAlexander | 0:c523920bcc09 | 156 | [56]= NOT_7_NO_DP(0), |
johnAlexander | 0:c523920bcc09 | 157 | [57]= NOT_7_NO_DP(S4), |
johnAlexander | 0:c523920bcc09 | 158 | 0,0,0, |
johnAlexander | 0:c523920bcc09 | 159 | [61]= S3+S6, |
johnAlexander | 0:c523920bcc09 | 160 | 0, |
johnAlexander | 0:c523920bcc09 | 161 | [63]= NOT_7_NO_DP(S5+S3+S2), |
johnAlexander | 0:c523920bcc09 | 162 | [64]= S0+S3, |
johnAlexander | 0:c523920bcc09 | 163 | [65]= NOT_7_NO_DP(S3), |
johnAlexander | 0:c523920bcc09 | 164 | [66]= NOT_7_NO_DP(S0+S1), /* as b */ |
johnAlexander | 0:c523920bcc09 | 165 | [67]= S0+S3+S4+S5, // same as [ |
johnAlexander | 0:c523920bcc09 | 166 | [68]= S0+S3+S4+S5, // same as [ DUMMY |
johnAlexander | 0:c523920bcc09 | 167 | [69]= NOT_7_NO_DP(S1+S2), |
johnAlexander | 0:c523920bcc09 | 168 | [70]= S6+S5+S4+S0, |
johnAlexander | 0:c523920bcc09 | 169 | [71]= NOT_7_NO_DP(S4), /* same as 9 */ |
johnAlexander | 0:c523920bcc09 | 170 | [72]= NOT_7_NO_DP(S0+S3), |
johnAlexander | 0:c523920bcc09 | 171 | [73]= S1+S2, |
johnAlexander | 0:c523920bcc09 | 172 | [74]= S1+S2+S3+S4, |
johnAlexander | 0:c523920bcc09 | 173 | [75]= NOT_7_NO_DP(S0+S3), /* same as H */ |
johnAlexander | 0:c523920bcc09 | 174 | [76]= S3+S4+S5, |
johnAlexander | 0:c523920bcc09 | 175 | [77]= S0+S4+S2, /* same as m*/ |
johnAlexander | 0:c523920bcc09 | 176 | [78]= S2+S4+S6, /* same as n*/ |
johnAlexander | 0:c523920bcc09 | 177 | [79]= NOT_7_NO_DP(S6), |
johnAlexander | 0:c523920bcc09 | 178 | [80]= S0+S1+S2+S5+S6, // sames as 'q' |
johnAlexander | 0:c523920bcc09 | 179 | [81]= NOT_7_NO_DP(S3+S2), |
johnAlexander | 0:c523920bcc09 | 180 | [82]= S4+S6, |
johnAlexander | 0:c523920bcc09 | 181 | [83]= NOT_7_NO_DP(S1+S4), /* sasme as 5 */ |
johnAlexander | 0:c523920bcc09 | 182 | [84]= NOT_7_NO_DP(S0+S1+S2), /* sasme as t */ |
johnAlexander | 0:c523920bcc09 | 183 | [85]= NOT_7_NO_DP(S6+S0), |
johnAlexander | 0:c523920bcc09 | 184 | [86]= S4+S3+S2, // is u but u use U |
johnAlexander | 0:c523920bcc09 | 185 | [87]= S1+S3+S5, |
johnAlexander | 0:c523920bcc09 | 186 | [88]= NOT_7_NO_DP(S0+S3), // similar to H |
johnAlexander | 0:c523920bcc09 | 187 | [89]= NOT_7_NO_DP(S0+S4), |
johnAlexander | 0:c523920bcc09 | 188 | [90]= S0+S1+S6+S4+S3, // same as 2 |
johnAlexander | 0:c523920bcc09 | 189 | [91]= S0+S3+S4+S5, |
johnAlexander | 0:c523920bcc09 | 190 | 0, |
johnAlexander | 0:c523920bcc09 | 191 | [93]= S0+S3+S2+S1, |
johnAlexander | 0:c523920bcc09 | 192 | [94]= S0, /* use as top bar */ |
johnAlexander | 0:c523920bcc09 | 193 | [95]= S3, |
johnAlexander | 0:c523920bcc09 | 194 | 0, |
johnAlexander | 0:c523920bcc09 | 195 | [97]= S2+ S3+ S4+ S6 , |
johnAlexander | 0:c523920bcc09 | 196 | [98]= NOT_7_NO_DP(S0+S1), |
johnAlexander | 0:c523920bcc09 | 197 | [99]= S6+S4+S3, |
johnAlexander | 0:c523920bcc09 | 198 | [100]= NOT_7_NO_DP(S0+S5), |
johnAlexander | 0:c523920bcc09 | 199 | [101]= NOT_7_NO_DP(S2), |
johnAlexander | 0:c523920bcc09 | 200 | [102]= S6+S5+S4+S0, /* same as F */ |
johnAlexander | 0:c523920bcc09 | 201 | [103]= NOT_7_NO_DP(S4), /* same as 9 */ |
johnAlexander | 0:c523920bcc09 | 202 | [104]= S6+S5+S4+S2, |
johnAlexander | 0:c523920bcc09 | 203 | [105]= S4, |
johnAlexander | 0:c523920bcc09 | 204 | [106]= S1+S2+S3+S4, |
johnAlexander | 0:c523920bcc09 | 205 | [107]= S6+S5+S4+S2, /* a h */ |
johnAlexander | 0:c523920bcc09 | 206 | [108]= S3+S4, |
johnAlexander | 0:c523920bcc09 | 207 | [109]= S0+S4+S2, /* same as */ |
johnAlexander | 0:c523920bcc09 | 208 | [110]= S2+S4+S6, |
johnAlexander | 0:c523920bcc09 | 209 | [111]= S6+S4+S3+S2, |
johnAlexander | 0:c523920bcc09 | 210 | [112]= NOT_7_NO_DP(S3+S2), // same as P |
johnAlexander | 0:c523920bcc09 | 211 | [113]= S0+S1+S2+S5+S6, |
johnAlexander | 0:c523920bcc09 | 212 | [114]= S4+S6, |
johnAlexander | 0:c523920bcc09 | 213 | [115]= NOT_7_NO_DP(S1+S4), |
johnAlexander | 0:c523920bcc09 | 214 | [116]= NOT_7_NO_DP(S0+S1+S2), |
johnAlexander | 0:c523920bcc09 | 215 | [117]= S4+S3+S2+S5+S1, // U |
johnAlexander | 0:c523920bcc09 | 216 | [118]= S4+S3+S2, // is u but u use U |
johnAlexander | 0:c523920bcc09 | 217 | [119]= S1+S3+S5, |
johnAlexander | 0:c523920bcc09 | 218 | [120]= NOT_7_NO_DP(S0+S3), // similar to H |
johnAlexander | 0:c523920bcc09 | 219 | [121]= NOT_7_NO_DP(S0+S4), |
johnAlexander | 0:c523920bcc09 | 220 | [122]= S0+S1+S6+S4+S3, // same as 2 |
johnAlexander | 0:c523920bcc09 | 221 | 0,0,0, |
johnAlexander | 0:c523920bcc09 | 222 | [126]= S0+S3+S6 /* 3 h bar */ |
johnAlexander | 0:c523920bcc09 | 223 | }; |
johnAlexander | 0:c523920bcc09 | 224 | #else |
johnAlexander | 0:c523920bcc09 | 225 | /* refer to http://www.twyman.org.uk/Fonts/ */ |
johnAlexander | 0:c523920bcc09 | 226 | static const uint8_t ascii_to_display_lut[256]={ |
johnAlexander | 0:c523920bcc09 | 227 | [' ']= 0, |
johnAlexander | 0:c523920bcc09 | 228 | ['-']= S6, |
johnAlexander | 0:c523920bcc09 | 229 | ['_']= S3, |
johnAlexander | 0:c523920bcc09 | 230 | ['=']= S3+S6, |
johnAlexander | 0:c523920bcc09 | 231 | ['~']= S0+S3+S6, /* 3 h bar */ |
johnAlexander | 0:c523920bcc09 | 232 | ['^']= S0, /* use as top bar */ |
johnAlexander | 0:c523920bcc09 | 233 | |
johnAlexander | 0:c523920bcc09 | 234 | ['?']= NOT_7_NO_DP(S5+S3+S2), |
johnAlexander | 0:c523920bcc09 | 235 | ['*']= NOT_7_NO_DP(), |
johnAlexander | 0:c523920bcc09 | 236 | ['[']= S0+S3+S4+S5, |
johnAlexander | 0:c523920bcc09 | 237 | [']']= S0+S3+S2+S1, |
johnAlexander | 0:c523920bcc09 | 238 | ['@']= S0+S3, |
johnAlexander | 0:c523920bcc09 | 239 | |
johnAlexander | 0:c523920bcc09 | 240 | ['0']= NOT_7_NO_DP(S6), |
johnAlexander | 0:c523920bcc09 | 241 | ['1']= S1+S2, |
johnAlexander | 0:c523920bcc09 | 242 | ['2']= S0+S1+S6+S4+S3, |
johnAlexander | 0:c523920bcc09 | 243 | ['3']= NOT_7_NO_DP(S4+S5), |
johnAlexander | 0:c523920bcc09 | 244 | ['4']= S5+S1+S6+S2, |
johnAlexander | 0:c523920bcc09 | 245 | ['5']= NOT_7_NO_DP(S1+S4), |
johnAlexander | 0:c523920bcc09 | 246 | ['6']= NOT_7_NO_DP(S1), |
johnAlexander | 0:c523920bcc09 | 247 | ['7']= S0+S1+S2, |
johnAlexander | 0:c523920bcc09 | 248 | ['8']= NOT_7_NO_DP(0), |
johnAlexander | 0:c523920bcc09 | 249 | ['9']= NOT_7_NO_DP(S4), |
johnAlexander | 0:c523920bcc09 | 250 | |
johnAlexander | 0:c523920bcc09 | 251 | ['a']= S2+ S3+ S4+ S6 , |
johnAlexander | 0:c523920bcc09 | 252 | ['b']= NOT_7_NO_DP(S0+S1), |
johnAlexander | 0:c523920bcc09 | 253 | ['c']= S6+S4+S3, |
johnAlexander | 0:c523920bcc09 | 254 | ['d']= NOT_7_NO_DP(S0+S5), |
johnAlexander | 0:c523920bcc09 | 255 | ['e']= NOT_7_NO_DP(S2), |
johnAlexander | 0:c523920bcc09 | 256 | ['f']= S6+S5+S4+S0, /* same as F */ |
johnAlexander | 0:c523920bcc09 | 257 | ['g']= NOT_7_NO_DP(S4), /* same as 9 */ |
johnAlexander | 0:c523920bcc09 | 258 | ['h']= S6+S5+S4+S2, |
johnAlexander | 0:c523920bcc09 | 259 | ['i']= S4, |
johnAlexander | 0:c523920bcc09 | 260 | ['j']= S1+S2+S3+S4, |
johnAlexander | 0:c523920bcc09 | 261 | ['k']= S6+S5+S4+S2, /* a h */ |
johnAlexander | 0:c523920bcc09 | 262 | ['l']= S3+S4, |
johnAlexander | 0:c523920bcc09 | 263 | ['m']= S0+S4+S2, /* same as */ |
johnAlexander | 0:c523920bcc09 | 264 | ['n']= S2+S4+S6, |
johnAlexander | 0:c523920bcc09 | 265 | ['o']= S6+S4+S3+S2, |
johnAlexander | 0:c523920bcc09 | 266 | ['p']= NOT_7_NO_DP(S3+S2), // same as P |
johnAlexander | 0:c523920bcc09 | 267 | ['q']= S0+S1+S2+S5+S6, |
johnAlexander | 0:c523920bcc09 | 268 | ['r']= S4+S6, |
johnAlexander | 0:c523920bcc09 | 269 | ['s']= NOT_7_NO_DP(S1+S4), |
johnAlexander | 0:c523920bcc09 | 270 | ['t']= NOT_7_NO_DP(S0+S1+S2), |
johnAlexander | 0:c523920bcc09 | 271 | ['u']= S4+S3+S2+S5+S1, // U |
johnAlexander | 0:c523920bcc09 | 272 | ['v']= S4+S3+S2, // is u but u use U |
johnAlexander | 0:c523920bcc09 | 273 | ['w']= S1+S3+S5, |
johnAlexander | 0:c523920bcc09 | 274 | ['x']= NOT_7_NO_DP(S0+S3), // similar to H |
johnAlexander | 0:c523920bcc09 | 275 | ['y']= NOT_7_NO_DP(S0+S4), |
johnAlexander | 0:c523920bcc09 | 276 | ['z']= S0+S1+S6+S4+S3, // same as 2 |
johnAlexander | 0:c523920bcc09 | 277 | |
johnAlexander | 0:c523920bcc09 | 278 | ['A']= NOT_7_NO_DP(S3), |
johnAlexander | 0:c523920bcc09 | 279 | ['B']= NOT_7_NO_DP(S0+S1), /* as b */ |
johnAlexander | 0:c523920bcc09 | 280 | ['C']= S0+S3+S4+S5, // same as [ |
johnAlexander | 0:c523920bcc09 | 281 | ['E']= NOT_7_NO_DP(S1+S2), |
johnAlexander | 0:c523920bcc09 | 282 | ['F']= S6+S5+S4+S0, |
johnAlexander | 0:c523920bcc09 | 283 | ['G']= NOT_7_NO_DP(S4), /* same as 9 */ |
johnAlexander | 0:c523920bcc09 | 284 | ['H']= NOT_7_NO_DP(S0+S3), |
johnAlexander | 0:c523920bcc09 | 285 | ['I']= S1+S2, |
johnAlexander | 0:c523920bcc09 | 286 | ['J']= S1+S2+S3+S4, |
johnAlexander | 0:c523920bcc09 | 287 | ['K']= NOT_7_NO_DP(S0+S3), /* same as H */ |
johnAlexander | 0:c523920bcc09 | 288 | ['L']= S3+S4+S5, |
johnAlexander | 0:c523920bcc09 | 289 | ['M']= S0+S4+S2, /* same as m*/ |
johnAlexander | 0:c523920bcc09 | 290 | ['N']= S2+S4+S6, /* same as n*/ |
johnAlexander | 0:c523920bcc09 | 291 | ['O']= NOT_7_NO_DP(S6), |
johnAlexander | 0:c523920bcc09 | 292 | ['P']= S0+S1+S2+S5+S6, // sames as 'q' |
johnAlexander | 0:c523920bcc09 | 293 | ['Q']= NOT_7_NO_DP(S3+S2), |
johnAlexander | 0:c523920bcc09 | 294 | ['R']= S4+S6, |
johnAlexander | 0:c523920bcc09 | 295 | ['S']= NOT_7_NO_DP(S1+S4), /* sasme as 5 */ |
johnAlexander | 0:c523920bcc09 | 296 | ['T']= NOT_7_NO_DP(S0+S1+S2), /* sasme as t */ |
johnAlexander | 0:c523920bcc09 | 297 | ['U']= NOT_7_NO_DP(S6+S0), |
johnAlexander | 0:c523920bcc09 | 298 | ['V']= S4+S3+S2, // is u but u use U |
johnAlexander | 0:c523920bcc09 | 299 | ['W']= S1+S3+S5, |
johnAlexander | 0:c523920bcc09 | 300 | ['X']= NOT_7_NO_DP(S0+S3), // similar to H |
johnAlexander | 0:c523920bcc09 | 301 | ['Y']= NOT_7_NO_DP(S0+S4), |
johnAlexander | 0:c523920bcc09 | 302 | ['Z']= S0+S1+S6+S4+S3 // same as 2 |
johnAlexander | 0:c523920bcc09 | 303 | }; |
johnAlexander | 0:c523920bcc09 | 304 | #endif |
johnAlexander | 0:c523920bcc09 | 305 | |
johnAlexander | 0:c523920bcc09 | 306 | |
johnAlexander | 0:c523920bcc09 | 307 | #undef S0 |
johnAlexander | 0:c523920bcc09 | 308 | #undef S1 |
johnAlexander | 0:c523920bcc09 | 309 | #undef S2 |
johnAlexander | 0:c523920bcc09 | 310 | #undef S3 |
johnAlexander | 0:c523920bcc09 | 311 | #undef S4 |
johnAlexander | 0:c523920bcc09 | 312 | #undef S5 |
johnAlexander | 0:c523920bcc09 | 313 | #undef S6 |
johnAlexander | 0:c523920bcc09 | 314 | #undef DP |
johnAlexander | 0:c523920bcc09 | 315 | |
johnAlexander | 0:c523920bcc09 | 316 | /** @} */ |
johnAlexander | 0:c523920bcc09 | 317 | |
johnAlexander | 0:c523920bcc09 | 318 | //#define DISPLAY_DELAY 1 // in mSec |
johnAlexander | 0:c523920bcc09 | 319 | |
johnAlexander | 0:c523920bcc09 | 320 | /* Classes -------------------------------------------------------------------*/ |
johnAlexander | 0:c523920bcc09 | 321 | /** Class representing Display |
johnAlexander | 0:c523920bcc09 | 322 | */ |
johnAlexander | 0:c523920bcc09 | 323 | |
johnAlexander | 0:c523920bcc09 | 324 | class Display |
johnAlexander | 0:c523920bcc09 | 325 | { |
johnAlexander | 0:c523920bcc09 | 326 | private: |
johnAlexander | 0:c523920bcc09 | 327 | STMPE1600 &stmpe1600_exp0; |
johnAlexander | 0:c523920bcc09 | 328 | STMPE1600 &stmpe1600_exp1; |
johnAlexander | 0:c523920bcc09 | 329 | public: |
johnAlexander | 0:c523920bcc09 | 330 | /** Constructor |
johnAlexander | 0:c523920bcc09 | 331 | * @param[in] &stmpe_1600 device handler to be used for display control |
johnAlexander | 0:c523920bcc09 | 332 | */ |
johnAlexander | 0:c523920bcc09 | 333 | Display (STMPE1600 &stmpe_1600_exp0, STMPE1600 &stmpe_1600_exp1) : stmpe1600_exp0(stmpe_1600_exp0), stmpe1600_exp1(stmpe_1600_exp1) { |
johnAlexander | 0:c523920bcc09 | 334 | uint16_t ExpanderData; |
johnAlexander | 0:c523920bcc09 | 335 | |
johnAlexander | 0:c523920bcc09 | 336 | // detect the extenders |
johnAlexander | 0:c523920bcc09 | 337 | stmpe1600_exp0.read16bitReg(0x00, &ExpanderData); |
johnAlexander | 0:c523920bcc09 | 338 | // if (ExpanderData != 0x1600) {/* log - failed to find expander exp0 */ } |
johnAlexander | 0:c523920bcc09 | 339 | stmpe1600_exp1.read16bitReg(0x00, &ExpanderData); |
johnAlexander | 0:c523920bcc09 | 340 | // if (ExpanderData != 0x1600) {/* log - failed to find expander exp1 */ } |
johnAlexander | 0:c523920bcc09 | 341 | |
johnAlexander | 0:c523920bcc09 | 342 | // configure all necessary GPIO pins as outputs |
johnAlexander | 0:c523920bcc09 | 343 | ExpanderData = 0xFFFF; |
johnAlexander | 0:c523920bcc09 | 344 | stmpe1600_exp0.write16bitReg(GPDR, &ExpanderData); |
johnAlexander | 0:c523920bcc09 | 345 | ExpanderData = 0xBFFF; // leave bit 14 as an input, for the pushbutton, PB1. |
johnAlexander | 0:c523920bcc09 | 346 | stmpe1600_exp1.write16bitReg(GPDR, &ExpanderData); |
johnAlexander | 0:c523920bcc09 | 347 | |
johnAlexander | 0:c523920bcc09 | 348 | // shut down all segment and all device |
johnAlexander | 0:c523920bcc09 | 349 | ExpanderData = 0x7F + (0x7F << 7); |
johnAlexander | 0:c523920bcc09 | 350 | stmpe1600_exp0.write16bitReg(GPSR, &ExpanderData); |
johnAlexander | 0:c523920bcc09 | 351 | stmpe1600_exp1.write16bitReg(GPSR, &ExpanderData); |
johnAlexander | 0:c523920bcc09 | 352 | } |
johnAlexander | 0:c523920bcc09 | 353 | |
johnAlexander | 0:c523920bcc09 | 354 | /*** Interface Methods ***/ |
johnAlexander | 0:c523920bcc09 | 355 | /** |
johnAlexander | 0:c523920bcc09 | 356 | * @brief Print the string on display |
johnAlexander | 0:c523920bcc09 | 357 | * @param[in] String to be printed |
johnAlexander | 0:c523920bcc09 | 358 | * @param[in] String lenght [min 1, max 4] |
johnAlexander | 0:c523920bcc09 | 359 | * @return void |
johnAlexander | 0:c523920bcc09 | 360 | */ |
johnAlexander | 0:c523920bcc09 | 361 | void DisplayString (const char *str) |
johnAlexander | 0:c523920bcc09 | 362 | { |
johnAlexander | 0:c523920bcc09 | 363 | uint16_t ExpanderData; |
johnAlexander | 0:c523920bcc09 | 364 | uint32_t Segments; |
johnAlexander | 0:c523920bcc09 | 365 | int BitPos; |
johnAlexander | 0:c523920bcc09 | 366 | int i; |
johnAlexander | 0:c523920bcc09 | 367 | |
johnAlexander | 0:c523920bcc09 | 368 | for( i=0; i<4 && str[i]!=0; i++){ |
johnAlexander | 0:c523920bcc09 | 369 | Segments = (uint32_t)ascii_to_display_lut[(uint8_t)str[i]]; |
johnAlexander | 0:c523920bcc09 | 370 | Segments =(~Segments)&0x7F; |
johnAlexander | 0:c523920bcc09 | 371 | BitPos=DisplayBitPos[i]; |
johnAlexander | 0:c523920bcc09 | 372 | CurIOVal.u32 &=~(0x7F<<BitPos); |
johnAlexander | 0:c523920bcc09 | 373 | CurIOVal.u32 |= Segments<<BitPos; |
johnAlexander | 0:c523920bcc09 | 374 | } |
johnAlexander | 0:c523920bcc09 | 375 | /* clear unused digit */ |
johnAlexander | 0:c523920bcc09 | 376 | for( ; i<4;i++){ |
johnAlexander | 0:c523920bcc09 | 377 | BitPos=DisplayBitPos[i]; |
johnAlexander | 0:c523920bcc09 | 378 | CurIOVal.u32 |=0x7F<<BitPos; |
johnAlexander | 0:c523920bcc09 | 379 | } |
johnAlexander | 0:c523920bcc09 | 380 | |
johnAlexander | 0:c523920bcc09 | 381 | // stmpe1600_exp0.write16bitReg(GPSR, (uint16_t *)&CurIOVal.bytes[0]); |
johnAlexander | 0:c523920bcc09 | 382 | // stmpe1600_exp1.write16bitReg(GPSR, (uint16_t *)&CurIOVal.bytes[2]); |
johnAlexander | 0:c523920bcc09 | 383 | |
johnAlexander | 0:c523920bcc09 | 384 | // ordered low-byte/high-byte! |
johnAlexander | 0:c523920bcc09 | 385 | ExpanderData = (CurIOVal.bytes[1] << 8) + CurIOVal.bytes[0]; |
johnAlexander | 0:c523920bcc09 | 386 | stmpe1600_exp0.write16bitReg(GPSR, &ExpanderData); |
johnAlexander | 0:c523920bcc09 | 387 | CurIOVal.bytes[3] |= 0x80; // ensure highest bit is high, as this is xshutdown pin on central sensor! |
johnAlexander | 0:c523920bcc09 | 388 | ExpanderData = (CurIOVal.bytes[3] << 8) + CurIOVal.bytes[2]; |
johnAlexander | 0:c523920bcc09 | 389 | stmpe1600_exp1.write16bitReg(GPSR, &ExpanderData); |
johnAlexander | 0:c523920bcc09 | 390 | |
johnAlexander | 0:c523920bcc09 | 391 | } |
johnAlexander | 0:c523920bcc09 | 392 | |
johnAlexander | 0:c523920bcc09 | 393 | void ClearDisplay(void) |
johnAlexander | 0:c523920bcc09 | 394 | { |
johnAlexander | 0:c523920bcc09 | 395 | uint16_t ExpanderData; |
johnAlexander | 0:c523920bcc09 | 396 | |
johnAlexander | 0:c523920bcc09 | 397 | ExpanderData = 0x7F + (0x7F << 7); |
johnAlexander | 0:c523920bcc09 | 398 | stmpe1600_exp0.write16bitReg(GPSR, &ExpanderData); |
johnAlexander | 0:c523920bcc09 | 399 | stmpe1600_exp1.write16bitReg(GPSR, &ExpanderData); |
johnAlexander | 0:c523920bcc09 | 400 | } |
johnAlexander | 0:c523920bcc09 | 401 | |
johnAlexander | 0:c523920bcc09 | 402 | }; |
johnAlexander | 0:c523920bcc09 | 403 | |
johnAlexander | 0:c523920bcc09 | 404 | #ifdef __cplusplus |
johnAlexander | 0:c523920bcc09 | 405 | } |
johnAlexander | 0:c523920bcc09 | 406 | #endif |
johnAlexander | 0:c523920bcc09 | 407 | #endif // __DISPLAY_H |
johnAlexander | 0:c523920bcc09 | 408 |