hello_touch

Example of the component cube32esp/cube32_bsp v0.0.17
# hello_touch

Raw touch-panel demo for the CUBE32 board, without LVGL. It draws a green trace under your finger directly on the display and prints the touch coordinates to the console.

## Features

- **Hardware auto-detection**: the display model (resolution, rotation, touch chip) is detected from the touch controller's I2C address; the example stops with an error if no known model is found
- **Direct display drawing**: uses the display driver matching the detected board (`fillRect`, no LVGL): ST7789 on the 240×320 boards, ST7796S on the 320×320 board. The ST7796S driver corrects that panel's native orientation, so the trace appears exactly where you touch
- **Touch trace**: green points joined by lines follow the finger; jumps of 50 px or more between two samples are not joined
- **Touch indicator**: a square in the top-right corner of the header bar is **green** while touched and **red** otherwise
- **Console output**: `Touch: X=…, Y=…, Strength=…` for every sample while pressed, and `Touch released`
- **Auto-clear**: the drawing area is cleared after 30 seconds without touch
- **Bus scan**: the I2C bus is scanned at start-up and the devices found are listed

## Hardware

- CUBE32 board (ESP32-S3) with a supported touch display; the touch IC is CST816S, FT6336 or GT911 (320×320 board)

## Configuration

`sdkconfig.defaults` of the release example already has what the demo needs:

| Setting | Why |
|---------|-----|
| `CONFIG_CUBE32_DISPLAY_ENABLED=y` | Display driver (part of the standard example template) |
| `CONFIG_CUBE32_TOUCH_ENABLED=y` | Raw touch driver |

LVGL is not used. In the BSP dev project select the demo with `idf.py menuconfig` → `CUBE32 Application Selection` → `Hello Touch Example` (it is only listed when the display and touch are enabled).

## Build and run

```bash
idf.py set-target esp32s3
idf.py build
idf.py -p <port> flash monitor
```

Run `idf.py set-target esp32s3` again after deleting `sdkconfig`; otherwise the target falls back to `esp32`.

## Usage

1. Flash the example; the screen is black with a grey header bar and a red indicator at the top right.
2. Touch the screen: the indicator turns green and a green trace follows your finger.
3. Lift the finger: the indicator turns red again.
4. Leave the screen untouched for 30 seconds to clear the drawing.

## Console output

```
I (xxxx) hello_touch: ========================================
I (xxxx) hello_touch: CUBE32 Hello Touch Example
I (xxxx) hello_touch: ========================================
I (xxxx) hello_touch: Scanning hardware...
I (xxxx) hello_touch: Detected display model: <model> (240x320)
I (xxxx) hello_touch: Display initialized: 240x320
I (xxxx) hello_touch: Touch initialized: CST816S (240x320)
I (xxxx) hello_touch: Touch Demo Started!
I (xxxx) hello_touch: Touch: X=120, Y=160, Strength=0
I (xxxx) hello_touch: Touch released
```

To create a project from this example, run:

idf.py create-project-from-example "cube32esp/cube32_bsp=0.0.17:hello_touch"

or download archive (~9.74 KB)