Library to handle the X-NUCLEO-6180XA1 Proximity and ambient light sensor expansion board based on VL6180X.

Dependencies:   X_NUCLEO_COMMON ST_INTERFACES

Dependents:   HelloWorld_6180XA1 SunTracker_BLE Servo_6180XA1 BLE_HR_Light ... more

Fork of X_NUCLEO_6180XA1 by ST Expansion SW Team

X-NUCLEO-6180XA1 Proximity and Ambient Light Sensor Expansion Board Firmware Package

Introduction

This firmware package includes Components Device Drivers and Board Support Package for STMicroelectronics' X-NUCLEO-6180XA1 Proximity and ambient light sensor expansion board based on VL6180X.

Firmware Library

Class X_NUCLEO_6180XA1 is intended to represent the Proximity and ambient light sensor expansion board with the same name.

The expansion board is providing the support of the following components:

  1. on-board VL6180X proximity and ambient light sensor,
  2. up to three additional VL6180X Satellites,
  3. on-board 4-digit display

It is intentionally implemented as a singleton because only one X-NUCLEO-VL6180XA1 at a time might be deployed 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_6180XA1 *6180X_expansion_board = X_NUCLEO_6180XA1::Instance();

Arduino Connector Compatibility Warning

Using the X-NUCLEO-6180XA1 expansion board with the NUCLEO-F429ZI requires adopting the following patch:

  • to remove R46 resistor connected to A3 pin;
  • to solder R47 resistor connected to A5 pin.

Alternatively, you can route the Nucleo board’s A5 pin directly to the expansion board’s A3 pin with a wire. In case you patch your expansion board or route the pin, the interrupt signal for the front sensor will be driven on A5 pin rather than on A3 pin.


Example Applications

Committer:
nikapov
Date:
Mon Aug 21 15:44:34 2017 +0000
Revision:
58:1e9a3a46f814
Parent:
57:fa4c622b04a7
Make compatible with non-copyable version of I2C.

Who changed what in which revision?

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