![oddWires IoT-Bus Documentation Download Page 72](http://html1.mh-extra.com/html/oddwires/iot-bus/iot-bus_documentation_3330893072.webp)
iot-bus Documentation, Release latest
use. We also define the CS_PIN as required for the touchscreen to be GPIO 16.
There is no need to define the rest of the pins as that has been done for you in User_Setup.h which is part of the
TFT_eSPI library.
// touchscreen
calibration values
#define X_MIN 256
#define X_MAX 3632
#define Y_MIN 274
#define Y_MAX 3579
These calibration values will vary from display to display. You can use the draw-corners example to find out the values
for each corner and change them for your displays. The values here are likely to be OK for initial testing but you will
get more accurate results by performing your own calibration.
pinMode(
33
, OUTPUT);
digitalWrite(
33
, HIGH);
These lines are critical as GPIO 33 is used to power on the back-light. The back-light is driven through a transistor to
avoid drawing too much current from the GPIO.
ts.begin();
ts.setCalibration(X_MIN, X_MAX, Y_MIN, Y_MAX);
tft.init();
These lines initialize and calibrate the touchscreen and display.
// Set the TFT and touch screen to landscape orientation
tft.setRotation(
1
);
ts.setRotation(
1
);
Rotation 0 and 2 are portrait and 1 and 3 are landscape. This example will work in any of the rotations so you can
change them and see the effect. Remember to keep them in sync or you will get strange effects.
tft.setTextSize(
1
);
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_GREEN);
This sets the default font-seize, sets the background to black and sets the current text color. Note that much better
smooth fonts are easily usable - take a look at the TFT_eSPI library documentation.
swatchWidth
=
ts.getWidth()
/
10
;
swatchHeight
=
34
;
This example dynamically determines the display width so that it works in any orientation.
tft.fillRect(i
*
swatchWidth,
0
, swatchWidth, swatchHeight, colors[i]);
This fills a rectangle with a color.
tft.setCursor(ts.getWidth()
-
swatchWidth
*
1.5
,
3
,
2
);
// x,y,font
tft.setTextColor(TFT_WHITE);
tft.print(
"Clear"
);
These lines position the cursor, set the text color and write some text at the cursor position.
68
Chapter 22. IoT-Bus Touch Draw Example
Summary of Contents for IoT-Bus
Page 1: ...iot bus Documentation Release latest oddWires Mar 05 2019...
Page 2: ......
Page 5: ...iot bus Documentation Release latest IoT Bus Introduction 1...
Page 6: ...iot bus Documentation Release latest 2 IoT Bus Introduction...
Page 16: ...iot bus Documentation Release latest 12 Chapter 1 IoT Bus Overview...
Page 17: ...CHAPTER 2 IoT Bus Pinout 13...
Page 18: ...iot bus Documentation Release latest Fig 1 IoT Bus Pinout 14 Chapter 2 IoT Bus Pinout...
Page 22: ...iot bus Documentation Release latest 18 Chapter 4 Getting Started with PlatformIO...
Page 24: ...iot bus Documentation Release latest 20 Chapter 5 Getting Started with Arduino...
Page 26: ...iot bus Documentation Release latest 22 Chapter 6 Getting Started with esp idf...
Page 32: ...iot bus Documentation Release latest 28 Chapter 7 Getting Started with Mozilla IoT...
Page 34: ...iot bus Documentation Release latest 30 Chapter 8 Getting Started with Micro Python...
Page 36: ...iot bus Documentation Release latest 32 Chapter 9 Getting Started with Moddable...
Page 38: ...iot bus Documentation Release latest 34 Chapter 10 Getting Started with MicroBlocks...
Page 50: ...iot bus Documentation Release latest 46 Chapter 13 JTAG...
Page 54: ...iot bus Documentation Release latest 50 Chapter 14 2 4 QVGA Touch Display...
Page 66: ...iot bus Documentation Release latest 62 Chapter 19 IoT Bus Examples Index...
Page 76: ...iot bus Documentation Release latest 72 Chapter 22 IoT Bus Touch Draw Example...
Page 78: ...iot bus Documentation Release latest 74 Chapter 23 IoT Bus Relay Example...
Page 94: ...iot bus Documentation Release latest 90 Chapter 27 IoT Bus SD_MMC Card Example...
Page 98: ...iot bus Documentation Release latest 94 Chapter 28 IoT Bus Mozilla IoT Examples...
Page 106: ...iot bus Documentation Release latest 102 Chapter 31 IoT Bus LED Lamp Thing...
Page 114: ...iot bus Documentation Release latest 110 Chapter 33 IoT Bus Relay Display Touch Thing...
Page 117: ...CHAPTER 35 IoT Bus DHT11 Thing include arduino h continues on next page 113...
Page 122: ...iot bus Documentation Release latest 118 Chapter 35 IoT Bus DHT11 Thing...
Page 130: ...iot bus Documentation Release latest 126 Chapter 37 IoT Bus HC SR501 PIR Thing...
Page 138: ...iot bus Documentation Release latest 134 Chapter 38 IoT Bus Calculator Thing...
Page 140: ...iot bus Documentation Release latest 136 Chapter 39 IoT Bus Mozilla IoT Tutorials...
Page 146: ...iot bus Documentation Release latest 142 Chapter 40 LED Thing Tutorial...
Page 152: ...iot bus Documentation Release latest 148 Chapter 41 Touch Switch Thing Tutorial...
Page 158: ...iot bus Documentation Release latest 154 Chapter 42 Mozilla Rules Engine...
Page 160: ...iot bus Documentation Release latest 156 Chapter 43 Frameworks...
Page 161: ...CHAPTER 44 Platforms 44 1 Espressif32 ESP WROOM32 WiFi Bluetooth Combo Module 157...