| Linduino 1.3.0 Linear Technology Arduino-Compatible Demonstration Board

EasySMU_IOpanel.h
Go to the documentation of this file.
1 /*!
2 Header File for EasySMU_IOpanel Library That Enables Touchscreen Control of EasySMU
3
4 [User Guide](http://www.linear.com/docs/58670 "EasySMU User Guide") \n
5 [Schematic](http://www.linear.com/docs/58671 "Schematic") \n
6 [Top-Level Linduino Firmware for EasySMU](file:EasySMU__Run_8ino.html "Top-Level Linduino Firmware for EasySMU") \n
7 [EasySMU Class Reference](file:classEasySMU.html "EasySMU Class Reference") \n
8 [EasySMU_IOpanel Class Reference](file:classEasySMU__IOpanel.html "EasySMU_IOpanel Class Reference") \n
9 [EasySMU Webpage](http://www.linear.com/solutions/7943 "EasySMU Webpage") \n
10
11 @verbatim
12 LTC4316: Single I2C/SMBus Address Translator
13 LT1970A: Power Op Amp with Adjustable Precision Current Limit
14 LT5400: Quad Matched Resistor Network
15 LTC2655: Quad I2C 16-/12-Bit Rail-to-Rail DACs with 10ppm/°C Max Reference
16 LTC3265: Low Noise Dual Supply with Boost and Inverting Charge Pumps
17 LTC2051: Dual Zero-Drift Operational Amplifier
18 LT3010: 50mA, 3V to 80V Low Dropout Micropower Linear Regulator
19 LT1991: Precision, 100µA Gain Selectable Amplifier
20 LTC6655: 0.25ppm Noise, Low Drift Precision Reference
21 LTC2485: 24-Bit ΔΣ ADC with Easy Drive Input Current Cancellation and I2C Interface
22
23 EasySMU is a single-channel ±12V/40mA programmable-voltage/programmable-current
24 source with accurate voltage/current measurement capability. The LTC4316 I2C
25 Address Translator enables up to eight independent EasySMUs to be controlled
26 by a single I2C master.
27
28 In this demonstration, each EasySMU board contains four I2C slaves and the
29 associated components to implement a single-channel ±12V/40mA programmable-
30 voltage/programmable-current source. The LTC4316 translates the I2C addresses
31 of each EasySMU to a unique set of addresses, enabling up to eight EasySMU
32 boards to be stacked on a single Linduino (I2C master). In this form, it
33 resembles a multi-channel automated test system. Alternatively, an optional
34 touchscreen allows the user to interactively control up to four channels,
35 forming a compact multi-channel programmable-voltage/programmable-current
36 bench source for lab testing, powered from a single 12V AC wall adapter.
37
38 The primary purpose of the EasySMU is to demonstrate the LTC4316 I2C Address
39 Translator. The programmable-voltage/programmable-current source and meter
40 also provide a convenient demonstration of the associated components: LT1970A,
41 LT5400-3, LTC2655-H, LTC3265, LTC2051, LT3010, LT1991, LTC6655, and LTC2485.
42 While the EasySMU is not designed to demonstrate the ultimate performance that
43 can be obtained from each of those components, the EasySMU does provide
44 impressive results from a reasonably simple circuit.
45
46 @endverbatim
47
48
49 Copyright 2018(c) Analog Devices, Inc.
50
51 All rights reserved.
52
53 Redistribution and use in source and binary forms, with or without
54 modification, are permitted provided that the following conditions are met:
55 - Redistributions of source code must retain the above copyright
56 notice, this list of conditions and the following disclaimer.
57 - Redistributions in binary form must reproduce the above copyright
58 notice, this list of conditions and the following disclaimer in
59 the documentation and/or other materials provided with the
60 distribution.
61 - Neither the name of Analog Devices, Inc. nor the names of its
62 contributors may be used to endorse or promote products derived
63 from this software without specific prior written permission.
64 - The use of this software may or may not infringe the patent rights
65 of one or more patent holders. This license does not release you
66 from the requirement that you obtain separate licenses from these
67 patent holders to use this software.
68 - Use of the software either in source or binary form, must be run
69 on or directly connected to an Analog Devices Inc. component.
70
71 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
72 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
73 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
74 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
75 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
76 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
77 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
78 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
79 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
80 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
81 */
82
83 /*! @file
84 @ingroup EasySMU
85 Header File for EasySMU_IOpanel Library That Enables Touchscreen Control of EasySMU
86 */
87 #ifndef Dan_Touch_IOpanel_h
88 #define Dan_Touch_IOpanel_h
89
90 #include "Arduino.h"
91 #include "EasySMU.h"
92 #include <Adafruit_ILI9341.h>
93
94 #define ADAFRUIT_TFT_TOUCHSHIELD_1947
95 //#define SEEEDSTUDIO_TFT_TOUCHSHIELD_V2
96
97 #ifdef ADAFRUIT_TFT_TOUCHSHIELD_1947
98 #include <Adafruit_FT6206.h>
99 // The Adafruit touch sensing is implemented with an FT6206 and communicates using I2C (SCL/SDA)
100 // The Adafruit display uses hardware SPI, plus #9 & #10
101 #define TFT_CS 10
102 #define TFT_DC 9
103 #endif // ADAFRUIT_TFT_TOUCHSHIELD_1947
104
105 #ifdef SEEEDSTUDIO_TFT_TOUCHSHIELD_V2
106 // The SeeedStudio display uses hardware SPI, plus #5 & #6
107 #define TFT_CS 5
108 #define TFT_DC 6
109
110 #define YP A2 // must be an analog pin, use "An" notation!
111 #define XM A1 // must be an analog pin, use "An" notation!
112 #define YM 14 // can be a digital pin, this is A0
113 #define XP 17 // can be a digital pin, this is A3
114
115 #include <SeeedTouchScreen.h>
116 #endif // SEEEDSTUDIO_TFT_TOUCHSHIELD_V2
117
118 #include <Adafruit_GFX.h>
119
120
121 //! used to indicate which button is pressed by the user
122 enum { _SMU0=_CH0, _SMU1=_CH1, _SMU2=_CH2, _SMU3=_CH3, _VPLUS, _VMINUS, _VPLUSPLUS, _VMINUSMINUS, _IPLUS, _IMINUS, _IPLUSPLUS, _IMINUSMINUS, _NONE };
123
124 //! width of Adafruit TFT display in pixels
125 #define _LCD_WIDTH 320
126 //! height of Adafruit TFT display in pixels
127 #define _LCD_HEIGHT 240
128
129 //The results are in pixel dimensions.
130 //! @name Define dimensions of buttons and text on EasySMU_IOpanel
131 //! @{
132 #define _SMU_SPACE 5
133 #define _SMU_WIDTH (_LCD_WIDTH-3*_SMU_SPACE)/2
134 #define _SMU_HEIGHT ((_LCD_HEIGHT/4)-_SMU_SPACE)
135
136 #define _SMU0_TOP _SMU_SPACE
137 #define _SMU0_LEFT _SMU_SPACE
138 #define _SMU0_RIGHT (_SMU0_LEFT + _SMU_WIDTH)
139 #define _SMU0_BOTTOM (_SMU0_TOP + _SMU_HEIGHT)
140
141 #define _SMU1_TOP (_SMU0_BOTTOM +_SMU_SPACE)
142 #define _SMU1_LEFT _SMU0_LEFT
143 #define _SMU1_RIGHT _SMU0_RIGHT
144 #define _SMU1_BOTTOM (_SMU1_TOP + _SMU_HEIGHT)
145
146 #define _SMU2_TOP _SMU0_TOP
147 #define _SMU2_LEFT _SMU0_RIGHT+_SMU_SPACE
148 #define _SMU2_RIGHT _SMU2_LEFT + _SMU_WIDTH
149 #define _SMU2_BOTTOM _SMU0_BOTTOM
150
151 #define _SMU3_TOP _SMU1_TOP
152 #define _SMU3_LEFT _SMU2_LEFT
153 #define _SMU3_RIGHT _SMU2_RIGHT
154 #define _SMU3_BOTTOM _SMU1_BOTTOM
155
156 #define _BUTTON_WIDTH (_LCD_WIDTH-5*_SMU_SPACE)/4
157 #define _BUTTON_HEIGHT ((_LCD_HEIGHT-5*_SMU_SPACE)/4)
158 #define _BUTTON_RADIUS (_BUTTON_HEIGHT/12)
159
160 #define _VPLUS_TOP (_VPLUS_BOTTOM-_BUTTON_HEIGHT)
161 #define _VPLUS_LEFT _SMU_SPACE
162 #define _VPLUS_RIGHT (_VPLUS_LEFT+_BUTTON_WIDTH)
163 #define _VPLUS_BOTTOM (_VMINUS_TOP-_SMU_SPACE)
164
165 #define _VMINUS_TOP (_VMINUS_BOTTOM-_BUTTON_HEIGHT)
166 #define _VMINUS_LEFT _SMU_SPACE
167 #define _VMINUS_RIGHT (_VMINUS_LEFT+_BUTTON_WIDTH)
168 #define _VMINUS_BOTTOM (_LCD_HEIGHT-_SMU_SPACE)
169
170 #define _VPLUSPLUS_TOP _VPLUS_TOP
171 #define _VPLUSPLUS_LEFT (_VPLUS_RIGHT+_SMU_SPACE)
172 #define _VPLUSPLUS_RIGHT _SMU1_RIGHT
173 #define _VPLUSPLUS_BOTTOM _VPLUS_BOTTOM
174
175 #define _VMINUSMINUS_LEFT _VPLUSPLUS_LEFT
176 #define _VMINUSMINUS_RIGHT _VPLUSPLUS_RIGHT
177 #define _VMINUSMINUS_TOP _VMINUS_TOP
178 #define _VMINUSMINUS_BOTTOM _VMINUS_BOTTOM
179
180 #define _IPLUS_TOP _VPLUS_TOP
181 #define _IPLUS_LEFT _SMU3_LEFT
182 #define _IPLUS_RIGHT (_IPLUS_LEFT+_BUTTON_WIDTH)
183 #define _IPLUS_BOTTOM _VPLUS_BOTTOM
184
185 #define _IMINUSMINUS_TOP _IMINUS_TOP
186 #define _IMINUSMINUS_LEFT _IPLUSPLUS_LEFT
187 #define _IMINUSMINUS_RIGHT _IPLUSPLUS_RIGHT
188 #define _IMINUSMINUS_BOTTOM _IMINUS_BOTTOM
189
190 #define _IMINUS_LEFT _IPLUS_LEFT
191 #define _IMINUS_RIGHT _IPLUS_RIGHT
192 #define _IMINUS_TOP _VMINUS_TOP
193 #define _IMINUS_BOTTOM _VMINUS_BOTTOM
194
195 #define _IPLUSPLUS_TOP _VPLUSPLUS_TOP
196 #define _IPLUSPLUS_LEFT (_IPLUS_RIGHT + _SMU_SPACE)
197 #define _IPLUSPLUS_RIGHT _SMU3_RIGHT
198 #define _IPLUSPLUS_BOTTOM _VPLUSPLUS_BOTTOM
199
200 #define _TEXT_LEFT 5
201 #define _TEXT_LEFT_MID 75
202 #define _BUTTON_TEXT_TOP 35
203 #define _BUTTON_TEXT_LEFT 25
204 #define _BUTTON_TEXT_TOP 35
205 #define _BUTTON_TEXT_PLUSPLUS_LEFT 15
206 #define _SMU_TEXT_TOP 15
207 #define _SMU_TEXT_LEFT 65
208 #define _TEXT_TOP 32
209 #define _TEXT_TOP_MID 48
210 //! @}
211
212 /*!The EasySMU_IOpanel class provides an interface between the EasySMU and a touchscreen.
213
214 [User Guide](http://www.linear.com/docs/58670 "EasySMU User Guide") \n
215 [Schematic](http://www.linear.com/docs/58671 "Schematic") \n
216 [Top-Level Linduino Firmware for EasySMU](file:EasySMU__Run_8ino.html "Top-Level Linduino Firmware for EasySMU") \n
217 [EasySMU Class Reference](file:classEasySMU.html "EasySMU Class Reference") \n
218 [EasySMU_IOpanel Class Reference](file:classEasySMU__IOpanel.html "EasySMU_IOpanel Class Reference") \n
219 [EasySMU Webpage](http://www.linear.com/solutions/7943 "EasySMU Webpage") \n
220 */
221 class EasySMU_IOpanel
222 {
223 private:
224 uint16_t text_width_;
225 uint16_t text_height_;
226 int16_t text_x_offset_;
227 int16_t text_y_offset_;
228 //! Draw text at the x and y pixel location
229 void DrawText( int16_t x, //!< horizontal location in pixels
230 int16_t y, //!< vertical location in pixels
231 const char *sDisplay //!< string to display
232 );
233 //! Clear old text and write new text. The Adafruit library does not contain a fast way to clear an area of the screen, so this overwrites old characters with the background color.
234 //! To reduce the flashing of clearing the entire string before writing the new string, this function clears and writes a single character at a time.
235 void OverwriteOldString(uint16_t fg_color, //!< foreground color
236 uint16_t bg_color, //!< background color
237 char *old_string, //!< the *old_string to be cleared
238 const char *new_string //!< the *new_string to be written
239 );
240 //! Used to put a '+' or '-' in front of a number (at the correct location)
241 void AddLeadingSign(char chrSign, //!< '+' or '-'
242 char *string, //!< *string contains a text form of the number that will have leading sign character placed in front
243 int8_t strlen //!< length of text in *string
244 );
245
246 public:
247 Adafruit_ILI9341 lcd = Adafruit_ILI9341(TFT_CS, TFT_DC);
248
249 #ifdef ADAFRUIT_TFT_TOUCHSHIELD_1947
250 Adafruit_FT6206 touchp = Adafruit_FT6206();
251 #endif // ADAFRUIT_TFT_TOUCHSHIELD_1947
252
253 #ifdef SEEEDSTUDIO_TFT_TOUCHSHIELD_V2
254 TouchScreen touchp = TouchScreen(XP, YP, XM, YM); //init TouchScreen port pins
255 #endif // SEEEDSTUDIO_TFT_TOUCHSHIELD_V2
256
257 //! Initialize the IO panel, including drawing buttons, etc.
258 void Init();
259
260 uint32_t start_button_pressed_; //!< keep track of when the button was pressed to later calculate the duration it has been held
261 uint32_t duration_button_pressed_; //!< stores a value corresponding to how long the button has been pressed
262 //! check if a button is pressed
263 //! @return the button pressed, based on enum
264 int CheckButton();
265 int button_pressed_; //!< stores the value of the button pressed (from enum)
266 int SMUselected_; //!< stores which SMU channel is selected on the TFT display
267 uint8_t enabled_; //!< indicates if the TFT is enabled. 1=enabled, 0=disabled. (TFT may be disabled to reduce noise in the SMU output caused by SPI communication.)
268
269 //! Draw the SMU labels. The selected channel will be green.
270 void DisplaySMULabel() ;
271 //! Draw the voltage source setting for a single channel.
272 void DisplayVoltageSourceSetting(int16_t channel, //!< channel to draw
273 float flt_old, //!< the old value to be overwitten in the background color
274 float flt_new //!< the new value to be drawn in the foreground color
275 ) ;
276 //! Draw the measured voltage for a single channel.
277 void DisplayMeasuredVoltage(int16_t channel,
278 float flt_old, //!< the old value to be overwitten in the background color
279 float flt_new //!< the new value to be drawn in the foreground color
280 ) ;
281 //! Draw the current source setting for a single channel.
282 void DisplayCurrentSourceSetting(int16_t channel,
283 float flt_old, //!< the old value to be overwitten in the background color
284 float flt_new, //!< the new value to be drawn in the foreground color
285 int8_t source_both_sink //!< If source only mode is set, a '+' will be drawn in front. If sink only mode is set, a '-' will be drawn in front.
286 );
287 //! Draw the measured current for a single channel.
288 void DisplayMeasuredCurrent(int16_t channel,
289 float flt_old, //!< the old value to be overwitten in the background color
290 float flt_new //!< the new value to be drawn in the foreground color
291 ) ;
292 //! Draw the measured temperature from the current ADC. Presently, not used as it clutters up the screen.
293 void DisplayTemperatureOfIadc(int16_t channel,
294 float flt_old, //!< the old value to be overwitten in the background color
295 float flt_new //!< the new value to be drawn in the foreground color
296 ) ;
297 //! Draw the measured temperature from the voltage ADC. Presently, not used as it clutters up the screen.
298 void DisplayTemperatureOfVadc(int16_t channel,
299 float flt_old, //!< the old value to be overwitten in the background color
300 float flt_new //!< the new value to be drawn in the foreground color
301 ) ;
302
303 };
304
305 #endif
EasySMU_IOpanel::DisplayTemperatureOfVadc
void DisplayTemperatureOfVadc(int16_t channel, float flt_old, float flt_new)
Draw the measured temperature from the voltage ADC. Presently, not used as it clutters up the screen...
Definition: EasySMU_IOpanel.cpp:403
_IPLUS
Definition: EasySMU_IOpanel.h:122
EasySMU_IOpanel::SMUselected_
int SMUselected_
stores which SMU channel is selected on the TFT display
Definition: EasySMU_IOpanel.h:266
_SMU2
Definition: EasySMU_IOpanel.h:122
TFT_CS
#define TFT_CS
Definition: EasySMU_IOpanel.h:101
EasySMU_IOpanel::DisplayMeasuredVoltage
void DisplayMeasuredVoltage(int16_t channel, float flt_old, float flt_new)
Draw the measured voltage for a single channel.
Definition: EasySMU_IOpanel.cpp:348
channel
static uint8_t channel
LTC2305 Channel selection.
Definition: DC1444A.ino:127
EasySMU_IOpanel::CheckButton
int CheckButton()
check if a button is pressed
Definition: EasySMU_IOpanel.cpp:177
_VMINUSMINUS
Definition: EasySMU_IOpanel.h:122
YM
#define YM
Definition: breakouttouchpaint.ino:26
EasySMU_IOpanel::start_button_pressed_
uint32_t start_button_pressed_
keep track of when the button was pressed to later calculate the duration it has been held ...
Definition: EasySMU_IOpanel.h:260
EasySMU_IOpanel::DisplayMeasuredCurrent
void DisplayMeasuredCurrent(int16_t channel, float flt_old, float flt_new)
Draw the measured current for a single channel.
Definition: EasySMU_IOpanel.cpp:475
_SMU3
Definition: EasySMU_IOpanel.h:122
EasySMU.h
Class Library Header File for EasySMU: I2C Address Translator Demonstration and a Simple Multi-Channe...
_IMINUSMINUS
Definition: EasySMU_IOpanel.h:122
EasySMU_IOpanel::DisplaySMULabel
void DisplaySMULabel()
Draw the SMU labels. The selected channel will be green.
Definition: EasySMU_IOpanel.cpp:280
EasySMU_IOpanel
The EasySMU_IOpanel class provides an interface between the EasySMU and a touchscreen.
Definition: EasySMU_IOpanel.h:221
_CH0
#define _CH0
Definition: EasySMU.h:72
EasySMU_IOpanel::DisplayVoltageSourceSetting
void DisplayVoltageSourceSetting(int16_t channel, float flt_old, float flt_new)
Draw the voltage source setting for a single channel.
Definition: EasySMU_IOpanel.cpp:318
Adafruit_GFX.h
_IPLUSPLUS
Definition: EasySMU_IOpanel.h:122
XM
#define XM
Definition: breakouttouchpaint.ino:25
_IMINUS
Definition: EasySMU_IOpanel.h:122
_SMU0
Definition: EasySMU_IOpanel.h:122
TFT_DC
#define TFT_DC
Definition: EasySMU_IOpanel.h:102
_VMINUS
Definition: EasySMU_IOpanel.h:122
EasySMU_IOpanel::DisplayTemperatureOfIadc
void DisplayTemperatureOfIadc(int16_t channel, float flt_old, float flt_new)
Draw the measured temperature from the current ADC. Presently, not used as it clutters up the screen...
Definition: EasySMU_IOpanel.cpp:376
XP
#define XP
Definition: breakouttouchpaint.ino:27
EasySMU_IOpanel::touchp
Adafruit_FT6206 touchp
Definition: EasySMU_IOpanel.h:250
_VPLUS
Definition: EasySMU_IOpanel.h:122
EasySMU_IOpanel::enabled_
uint8_t enabled_
indicates if the TFT is enabled.
Definition: EasySMU_IOpanel.h:267
_CH1
#define _CH1
Definition: EasySMU.h:73
EasySMU_IOpanel::Init
void Init()
Initialize the IO panel, including drawing buttons, etc.
Definition: EasySMU_IOpanel.cpp:106
x
int32_t x
Definition: LTC2492_Thermocouple_Meter.ino:119
EasySMU_IOpanel::duration_button_pressed_
uint32_t duration_button_pressed_
stores a value corresponding to how long the button has been pressed
Definition: EasySMU_IOpanel.h:261
TouchScreen
Definition: SeeedTouchScreen.h:21
Adafruit_FT6206
Definition: Adafruit_FT6206.h:61
_SMU1
Definition: EasySMU_IOpanel.h:122
EasySMU_IOpanel::button_pressed_
int button_pressed_
stores the value of the button pressed (from enum)
Definition: EasySMU_IOpanel.h:265
EasySMU_IOpanel::DisplayCurrentSourceSetting
void DisplayCurrentSourceSetting(int16_t channel, float flt_old, float flt_new, int8_t source_both_sink)
Draw the current source setting for a single channel.
Definition: EasySMU_IOpanel.cpp:440
Adafruit_FT6206.h
SeeedTouchScreen.h
Adafruit_ILI9341.h
EasySMU_IOpanel::lcd
Adafruit_ILI9341 lcd
Definition: EasySMU_IOpanel.h:247
_VPLUSPLUS
Definition: EasySMU_IOpanel.h:122
_CH2
#define _CH2
Definition: EasySMU.h:74
Adafruit_ILI9341
Definition: Adafruit_ILI9341.h:118
YP
#define YP
NOT FOR USE WITH THE TOUCH SHIELD, ONLY FOR THE BREAKOUT!
Definition: breakouttouchpaint.ino:24
_CH3
#define _CH3
Definition: EasySMU.h:75
_NONE
Definition: EasySMU_IOpanel.h:122