roo_display
API Documentation for roo_display
Loading...
Searching...
No Matches
esp32_tft_capacitive_35.h
Go to the documentation of this file.
1#pragma once
2
3// https://www.makerfabs.com/esp32-3-5-inch-tft-touch-capacitive-with-camera.html
4// Maker: MakerFabs
5// Product Code: ESPTFT35CA
6
8#if !defined(ESP_PLATFORM) || !CONFIG_IDF_TARGET_ESP32
9#warning "This driver requires ESP32 SoC."
10#else
11
16#include "roo_display/hal/i2c.h"
17#include "roo_display/hal/spi.h"
19
21
22/// Makerfabs ESP32 3.5" TFT capacitive touch device.
23class Esp32TftCapacitive35 : public ComboDevice {
24 public:
25#if defined(ARDUINO)
26 // You can use non-default I2C interface by providing a custom instance of
27 // TwoWire as the i2c parameter.
28 Esp32TftCapacitive35(
29 Orientation orientation = Orientation(),
31 : hspi_(HSPI), spi_(hspi_), i2c_(i2c), display_(spi_), touch_(i2c_) {
32 display_.setOrientation(orientation);
33 }
34#else
35 // You can use non-default I2C interface by providing a specific
36 // i2c_port_num_t as the i2c parameter.
37 Esp32TftCapacitive35(
38 Orientation orientation = Orientation(),
40 : spi_(), i2c_(i2c), display_(spi_), touch_(i2c_) {
41 display_.setOrientation(orientation);
42 }
43#endif
44
45 /// Initialize SPI/I2C transport and SD card CS pin.
46 void initTransport() {
47 spi_.init(14, 12, 13);
48 i2c_.init(26, 27);
49 // In case the SD card is unused, its CS pin should be held HIGH, so that
50 // doesn't interfere with the display.
51 DefaultGpio::setOutput(pin_sd_cs());
52 DefaultGpio::setHigh(pin_sd_cs());
53 }
54
55 /// Return display device.
56 DisplayDevice& display() override { return display_; }
57
58 /// Return touch device.
59 TouchDevice* touch() override { return &touch_; }
60
61 /// Return touch calibration.
62 TouchCalibration touch_calibration() override {
63 return TouchCalibration(0, 20, 309, 454, Orientation::RightDown());
64 }
65
66 /// SPI SCK pin.
67 constexpr int8_t pin_sck() const { return 14; }
68 /// SPI MISO pin.
69 constexpr int8_t pin_miso() const { return 12; }
70 /// SPI MOSI pin.
71 constexpr int8_t pin_mosi() const { return 13; }
72 /// I2C SDA pin.
73 constexpr int8_t pin_sda() const { return 26; }
74 /// I2C SCL pin.
75 constexpr int8_t pin_scl() const { return 27; }
76
77 /// SD card CS pin.
78 constexpr int8_t pin_sd_cs() const { return 4; }
79
80#if defined(ARDUINO)
81 decltype(SPI)& spi() { return hspi_; }
82#endif
83
84 private:
85#if defined(ARDUINO)
86 decltype(SPI) hspi_;
87#endif
88
89 roo_display::esp32::Hspi spi_;
93};
94
95} // namespace roo_display::products::makerfabs
96
97#endif // !defined(ESP_PLATFORM) || !CONFIG_IDF_TARGET_ESP32