Skip to content

Commit

Permalink
Merge pull request #5 from esp-cpp/feature/hardawre-support
Browse files Browse the repository at this point in the history
Feature: HAL for support of ESP32-S3-BOX, ESP32-S3-BOX-3, and LilyGo T-Deck
  • Loading branch information
finger563 authored Nov 14, 2023
2 parents 9a1565b + 60fb80e commit 93ea4f8
Show file tree
Hide file tree
Showing 10 changed files with 319 additions and 77 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ add_compile_definitions(BOARD_HAS_PSRAM)

set(
COMPONENTS
"main esptool_py esp_psram jpegdec task format monitor display_drivers wifi socket rtsp mdns"
"main esptool_py esp_psram jpegdec task format monitor i2c display_drivers input_drivers gt911 tt21100 wifi socket rtsp mdns"
CACHE STRING
"List of components to include"
)
Expand Down
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
# camera-display

Example for [ESP32-S3-BOX](https://www.adafruit.com/product/5290)
([docs](https://github.com/espressif/esp-box)) which receives an MJPEG camera stream
from the [camera-streamer app](https://github.com/esp-cpp/camera-streamer) over
WiFi and displays them on the screen.
([docs](https://github.com/espressif/esp-box)),
[ESP32-S3-BOX-3](https://www.espressif.com/en/news/ESP32-S3-BOX-3)([mouser](https://www.mouser.com/ProductDetail/Espressif-Systems/ESP32-S3-BOX-3?qs=HoCaDK9Nz5chOY9AUo%2F%2FvA%3D%3D)),
and [LilyGo T-Deck](https://www.lilygo.cc/products/t-deck) which receives an
MJPEG camera stream from the [camera-streamer
app](https://github.com/esp-cpp/camera-streamer) over WiFi and displays them on
the screen.

To facilitate discovery, this sample uses mDNS to find the camera-streamer app
(or any RTSP server that advertises itself as `_rtsp._tcp.local`).

https://user-images.githubusercontent.com/213467/236601479-fcd982f5-80b1-4ce5-aef6-ab2b90f3d0b8.mp4

![image](https://github.com/esp-cpp/camera-display/assets/213467/3b08febf-433b-42e1-b139-132d64e35a07)
![image](https://github.com/esp-cpp/camera-display/assets/213467/cc179d89-6083-4324-af5e-05003beeda72)

## Hardware

This sample is designed to run on the ESP32-S3-BOX which has a 320x240 LCD (over
SPI) running on a ESP32-S3.
This sample is designed to run on the ESP32-S3-BOX, ESP32-S3-BOX-3, and LilyGo
T-Deck all of which have a 320x240 LCD (over SPI) running on a ESP32-S3.

## Software

Expand Down
2 changes: 1 addition & 1 deletion components/espp
Submodule espp updated 234 files
13 changes: 13 additions & 0 deletions main/Kconfig.projbuild
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
menu "Camera Display Configuration"

choice
prompt "Hardware Configuration"
default HARDWARE_BOX
help
Select the dev-kit / hardware you're using.
config HARDWARE_BOX
bool "ESP BOX"
config HARDWARE_BOX_3
bool "ESP BOX 3"
config HARDWARE_TDECK
bool "LILYGO T DECK"
endchoice

config ESP_WIFI_SSID
string "WiFi SSID"
default "myssid"
Expand Down
75 changes: 75 additions & 0 deletions main/box.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#pragma once

#include "hal/spi_types.h"
#include "driver/gpio.h"
#include "driver/i2s_std.h"
#include "driver/spi_master.h"

#include "i2c.hpp"
#include "st7789.hpp"
#include "touchpad_input.hpp"
#include "tt21100.hpp"

namespace hal {

static constexpr std::string_view dev_kit = "ESP32-S3-BOX";

// internal i2c (touchscreen, audio codec)
static constexpr auto internal_i2c_port = I2C_NUM_0;
static constexpr auto internal_i2c_clock_speed = 400 * 1000;
static constexpr gpio_num_t internal_i2c_sda = GPIO_NUM_8;
static constexpr gpio_num_t internal_i2c_scl = GPIO_NUM_18;

// external I2c (peripherals)
static constexpr auto external_i2c_port = I2C_NUM_1;
static constexpr auto external_i2c_clock_speed = 400 * 1000;
static constexpr gpio_num_t external_i2c_sda = GPIO_NUM_41;
static constexpr gpio_num_t external_i2c_scl = GPIO_NUM_40;

// LCD
static constexpr int lcd_clock_speed = 60 * 1000 * 1000;
static constexpr auto lcd_spi_num = SPI2_HOST;
static constexpr gpio_num_t lcd_cs = GPIO_NUM_5;
static constexpr gpio_num_t lcd_mosi = GPIO_NUM_6;
static constexpr gpio_num_t lcd_sclk = GPIO_NUM_7;
static constexpr gpio_num_t lcd_reset = GPIO_NUM_48;
static constexpr gpio_num_t lcd_dc = GPIO_NUM_4;
static constexpr gpio_num_t backlight = GPIO_NUM_45;
static constexpr size_t display_width = 320;
static constexpr size_t display_height = 240;
static constexpr bool backlight_value = true;
static constexpr bool reset_value = false;
static constexpr bool invert_colors = true;
static constexpr auto rotation = espp::Display::Rotation::LANDSCAPE;
static constexpr bool mirror_x = true;
static constexpr bool mirror_y = true;
using DisplayDriver = espp::St7789;

// touch
static constexpr bool touch_swap_xy = false;
static constexpr bool touch_invert_x = true;
static constexpr bool touch_invert_y = false;
static constexpr gpio_num_t touch_interrupt = GPIO_NUM_3;
using TouchDriver = espp::Tt21100;
#define TOUCH_DRIVER_USE_WRITE 0
#define TOUCH_DRIVER_USE_READ 1
#define TOUCH_DRIVER_USE_WRITE_READ 0

// sound
static constexpr gpio_num_t sound_power_pin = GPIO_NUM_46;
static constexpr auto i2s_port = I2S_NUM_0;
static constexpr gpio_num_t i2s_mck_io = GPIO_NUM_2;
static constexpr gpio_num_t i2s_bck_io = GPIO_NUM_17;
static constexpr gpio_num_t i2s_ws_io = GPIO_NUM_47;
static constexpr gpio_num_t i2s_do_io = GPIO_NUM_15;
static constexpr gpio_num_t i2s_di_io = GPIO_NUM_16;
static constexpr gpio_num_t mute_pin = GPIO_NUM_1;

// uSD card
static constexpr gpio_num_t sdcard_cs = GPIO_NUM_10;
static constexpr gpio_num_t sdcard_mosi = GPIO_NUM_11;
static constexpr gpio_num_t sdcard_miso = GPIO_NUM_13;
static constexpr gpio_num_t sdcard_sclk = GPIO_NUM_12;
static constexpr auto sdcard_spi_num = SPI3_HOST;

} // namespace box_hal
75 changes: 75 additions & 0 deletions main/box_3.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#pragma once

#include "hal/spi_types.h"
#include "driver/gpio.h"
#include "driver/i2s_std.h"
#include "driver/spi_master.h"

#include "i2c.hpp"
#include "st7789.hpp"
#include "touchpad_input.hpp"
#include "gt911.hpp"

namespace hal {

static constexpr std::string_view dev_kit = "ESP32-S3-BOX-3";

// internal i2c (touchscreen, audio codec)
static constexpr auto internal_i2c_port = I2C_NUM_0;
static constexpr auto internal_i2c_clock_speed = 400 * 1000;
static constexpr gpio_num_t internal_i2c_sda = GPIO_NUM_8;
static constexpr gpio_num_t internal_i2c_scl = GPIO_NUM_18;

// external I2c (peripherals)
static constexpr auto external_i2c_port = I2C_NUM_1;
static constexpr auto external_i2c_clock_speed = 400 * 1000;
static constexpr gpio_num_t external_i2c_sda = GPIO_NUM_41;
static constexpr gpio_num_t external_i2c_scl = GPIO_NUM_40;

// LCD
static constexpr int lcd_clock_speed = 60 * 1000 * 1000;
static constexpr auto lcd_spi_num = SPI2_HOST;
static constexpr gpio_num_t lcd_cs = GPIO_NUM_5;
static constexpr gpio_num_t lcd_mosi = GPIO_NUM_6;
static constexpr gpio_num_t lcd_sclk = GPIO_NUM_7;
static constexpr gpio_num_t lcd_reset = GPIO_NUM_48;
static constexpr gpio_num_t lcd_dc = GPIO_NUM_4;
static constexpr gpio_num_t backlight = GPIO_NUM_47; // was 45 on ESP32-S3-BOX
static constexpr size_t display_width = 320;
static constexpr size_t display_height = 240;
static constexpr bool backlight_value = true;
static constexpr bool reset_value = true; // was false on ESP32-S3-BOX
static constexpr bool invert_colors = true;
static constexpr auto rotation = espp::Display::Rotation::LANDSCAPE;
static constexpr bool mirror_x = false;
static constexpr bool mirror_y = true;
using DisplayDriver = espp::St7789;

// touch
static constexpr bool touch_swap_xy = false;
static constexpr bool touch_invert_x = false;
static constexpr bool touch_invert_y = false;
static constexpr gpio_num_t touch_interrupt = GPIO_NUM_3;
using TouchDriver = espp::Gt911;
#define TOUCH_DRIVER_USE_WRITE 1
#define TOUCH_DRIVER_USE_READ 0
#define TOUCH_DRIVER_USE_WRITE_READ 1

// sound
static constexpr gpio_num_t sound_power_pin = GPIO_NUM_46;
static constexpr auto i2s_port = I2S_NUM_0;
static constexpr gpio_num_t i2s_mck_io = GPIO_NUM_2;
static constexpr gpio_num_t i2s_bck_io = GPIO_NUM_17;
static constexpr gpio_num_t i2s_ws_io = GPIO_NUM_45; // was 47 on ESP32-S3-BOX
static constexpr gpio_num_t i2s_do_io = GPIO_NUM_15;
static constexpr gpio_num_t i2s_di_io = GPIO_NUM_16;
static constexpr gpio_num_t mute_pin = GPIO_NUM_1;

// uSD card
static constexpr gpio_num_t sdcard_cs = GPIO_NUM_10;
static constexpr gpio_num_t sdcard_mosi = GPIO_NUM_11;
static constexpr gpio_num_t sdcard_miso = GPIO_NUM_13;
static constexpr gpio_num_t sdcard_sclk = GPIO_NUM_12;
static constexpr auto sdcard_spi_num = SPI3_HOST;

} // namespace box_hal
Loading

0 comments on commit 93ea4f8

Please sign in to comment.