VCYD Help

Virtual Cheap Yellow Display: run ESP32 CYD firmware on your Mac.

Getting started

VCYD opens on a menu drawn on a virtual CYD screen. The window is the panel: 320×240 for the 2.8" board (ESP32-2432S028R, ILI9341) or 480×320 for the 3.5" board (ESP32-3248S035R, ST7796). Your mouse is the touch screen.

Opening files

VCYD opens two kinds of files: touch scripts (.vcydtouch) and ESP32 firmware images (.bin). Use whichever way is handiest:

HowWhat to do
File menuFile > Open… (⌘O) and pick a file.
Recent filesFile > Open Recent lists files you opened before. Clear Menu empties it.
Drag and dropDrop a file on the VCYD window or on the VCYD icon in the Dock.
FinderDouble-click a .vcydtouch file. For a .bin, right-click it and choose Open With > VCYD.
Terminalopen -a VCYD file.vcydtouch, or pass the file to the program: /Applications/VCYD.app/Contents/MacOS/VCYD file.bin

File > Close (⌘W) closes whatever is open and returns to the menu.

.bin is used by many programs, so VCYD doesn't take it over. To open every .bin in VCYD and show the red BIN icon, select one in Finder, choose File > Get Info, set Open with to VCYD and click Change All….

The demos

DemoTry this
PaintPick a colour from the top bar and draw. CLEAR wipes the canvas.
PlasmaA full-screen animated plasma. Touch to move the centre of the ripple.
StarfieldHold the mouse button down to go to warp and steer toward the pointer.
LifeConway's Game of Life coloured by cell age. Drag to add cells; tap the top-left corner to reseed.
Bubble PopTap bubbles before they float away. Ten escapes ends the round; tap to play again.

Every demo is ordinary CYD firmware and runs unchanged on a real board. Their source is in the examples/ folder of the VCYD repository.

Touch, keys and menus

InputAction
Left mouse buttonTouch (hold and drag to move your finger)
1–5Start a demo from the menu
BSwitch board from the menu
M or DeleteBack to the menu
SSave a screenshot (vcyd-000.bmp, …) in the current folder
EscQuit
⌘O, ⌘W, ⌘?Open, Close, VCYD Help

Touch scripts

A touch script replays taps and drags, so you can repeat a UI test or show a demo hands-free. It is a plain text file, one event per line. Times are milliseconds after the script starts, and X/Y are screen pixels.

# demo: bubble-pop
# board: 28
900 down 160 120
920 up
1600 down 100 150
1640 move 120 150
1660 up

Scripts also work from the command line with --input, which makes them handy for automated tests (see Command-line options).

Firmware images (.bin)

Opening an ESP32 application image shows what is inside it: size, entry point, flash mode and size, chip, and each segment's load address and length. A full flash dump that starts with the bootloader has its app image at offset 0x10000, so VCYD reports that it doesn't recognise it.

Running .bin files is coming in a later version of VCYD, which emulates the ESP32 itself. Until then, run your firmware from source as described next.

Running your own firmware

VCYD runs firmware from source. It compiles your sketch for the Mac and swaps in Mac versions of the libraries CYD code uses, so the program draws in the VCYD window instead of on the panel. You need the Xcode command line tools (xcode-select --install) and SDL2 (brew install sdl2).

With PlatformIO

Add a native environment next to your ESP32 ones in platformio.ini:

[env:vcyd-28]
platform = native
lib_deps = https://github.com/rauls4/VCYD.git
build_flags = -D MY_BOARD_IS_CYD_28

Then build and run it:

pio run -e vcyd-28 -t exec
.pio/build/vcyd-28/program --scale 3     # run again with options

If your shared [env] section sets framework = arduino or ESP32-only libraries, move those into a section that only the board environments extend, so the native environment doesn't inherit them. To use a local copy of VCYD, set lib_deps = symlink:///path/to/VCYD.

With the Arduino IDE

The Arduino IDE only builds for boards, so it can't make a Mac program. Use VCYD's Makefile instead:

  1. Get the VCYD source (git clone https://github.com/rauls4/VCYD.git).
  2. Copy your sketch folder somewhere and rename MySketch.ino to main.cpp. Add #include <Arduino.h> at the top and declare any functions before you use them, which the IDE normally does for you.
  3. Build and run:
    cd VCYD
    make SKETCH=/path/to/MySketch NAME=mysketch
    build/mysketch/mysketch

Add CPPFLAGS="-I/path/to/headers -DMY_SETTING=1" for extra include folders or defines.

What your code can use

The Arduino basics (setup/loop, Serial, millis, delay, random, pins), GFX Library for Arduino (Arduino_ILI9341, Arduino_ST7796, shapes, bitmaps and the built-in text font) and XPT2046_Touchscreen. Serial prints in Terminal. Touch readings run from 0 to 4095 across the screen; a real panel needs calibration (about 200 to 3900). If your code uses something VCYD doesn't have yet, the build stops and names it.

Command-line options

OptionEffect
--scale NWindow size multiplier (default 2)
--headlessRun without a window (also VCYD_HEADLESS=1)
--exit-after MSQuit after MS milliseconds
--screenshot FILESave a BMP of the screen when quitting
--input FILEReplay a touch script from the start
FILEOpen a .vcydtouch or .bin, as if opened from Finder

For example, to check a screen automatically:

build/bubble-pop-28/bubble-pop --headless --input taps.vcydtouch \
  --exit-after 3000 --screenshot result.bmp

What VCYD simulates

VCYD is for layout, touch and logic. It does not model ESP32 speed, its memory limits, SPI transfer time, WiFi, SD cards or audio. Your code runs much faster on a Mac than on the board, so keep checking speed and memory on real hardware. To keep the window responsive, long loops should call delay() or yield(), which they also need on the board to keep the watchdog happy.

Troubleshooting

macOS says VCYD can't be opened

This build is signed only for the Mac it was built on. Build it on your Mac with make install-app, or right-click VCYD in Applications and choose Open once.

Nothing happens, or "Library not loaded: libSDL2"

Install SDL2 with brew install sdl2.

Touch scripts show text instead of the TOUCH icon in Finder

Finder's icon view previews text files. The TOUCH icon appears in list view and Get Info, or everywhere if you turn off View > Show View Options > Show icon preview.

The window stops responding

The firmware is stuck in a loop that never calls delay() or yield(). Press Esc or quit from the Dock, then add a yield() inside the loop.

VCYD · questions: [email protected]. More at silvadesign.com/vcyd. The built-in font and drawing routines derive from Adafruit_GFX / Arduino_GFX (BSD license).