Skip to content

Latest commit

 

History

History
447 lines (343 loc) · 17.5 KB

CLI.md

File metadata and controls

447 lines (343 loc) · 17.5 KB

CYD_CLI

Русский | English

Русский

CYD_CLI.exe управляет поддерживаемым дисплеем CYD из cmd, PowerShell, batch-файлов и других программ. Если параметр --port не задан или задан как --port auto, программа проверяет COM1...COM256 и подключается к первому устройству, которое ответило на команду CYD HELLO. Конкретный порт задаётся, например, параметром --port COM5.

Быстрый старт

CYD_CLI.exe info
CYD_CLI.exe reset
CYD_CLI.exe clear black
CYD_CLI.exe text 10 20 3 yellow "Hello CYD"
CYD_CLI.exe rect 10 60 120 40 cyan fill
CYD_CLI.exe circle 220 100 35 red outline
CYD_CLI.exe qr "https://example.com/CYD"
CYD_CLI.exe tone 880 500 255
CYD_CLI.exe melody "BPM=120: 4C4, 4D#4, 8Gb4, 16P, 32A7"
CYD_CLI.exe sd-info
CYD_CLI.exe wifi-scan

Команда melody <notation> [volume] запускает автономную мелодию и ждёт событие её завершения. Громкость по умолчанию — 255. Строка начинается с BPM=20..400:; ноты разделяются пробелами или запятыми и записываются как [длительность][.][нота][#|b][октава]. Допустимы длительности 1,2,4,8,16,32, ноты C,D,E,F,G,A,B/H, паузы P/R и октавы 1…7. Например, 4.C4 — четвертная с точкой, а C4 использует длительность 4 по умолчанию. Ограничения: 128 нот, 1024 UTF-8 байта и 5 минут.

Готовая одноголосная партитура «Собачьего вальса» находится в CYD_CLI_DogWaltz.cmd. Она запускает CYD_CLI melody на громкости 40.

Аппаратные команды pixel, line, rect, circle, triangle и text передают только параметры. Рисование выполняет ESP32.

Команда reset не принимает параметров и запрашивает перезапуск ESP32 у прошивки. Это работает и с нативным USB CDC ESP32-S3 платы JC3248W535, у которой линии RTS/DTR не соединены со входом EN. После подтверждения команды CLI завершается; повторное подключение выполняется следующей командой.

Автономный скролл

CYD_CLI.exe scroll "ESP32 scrolling" left 90 10 3 cyan black

Аргументы: текст, направление, скорость в пикселях/с, длительность в секундах, масштаб, цвет и фон. Пока команда работает, ESP32 обновляет скролл локально без передачи кадров с ПК.

Для произвольной области:

CYD_CLI.exe scroll "Status line" left 70 15 2 white black 0 190 320 32

Системные шрифты, изображения и QR-коды

CYD_CLI.exe system-text 10 20 18 white Arial "Текст PureBasic"
CYD_CLI.exe text-file message.txt 14 white Arial black
Get-Content message.txt -Raw | CYD_CLI.exe stdin 14 white Arial black
CYD_CLI.exe image photo.png fit black
CYD_CLI.exe qr "https://example.com/CYD"
CYD_CLI.exe qr "WIFI:T:WPA;S:Network;P:password;;" black white 0

Эти команды используют framebuffer PureBasic. Они поддерживают системные шрифты, сглаживание, кириллицу и форматы изображений PureBasic, но передаются медленнее аппаратных примитивов.

Синтаксис QR-команды:

qr <text> [foreground] [background] [scale]

По умолчанию используются чёрный код, белый фон и автоматический масштаб 0. Код с обязательным светлым полем центрируется по горизонтали и вертикали. Поддерживаются UTF-8, уровень коррекции M, версии 1–10 и до 212 байт UTF-8. Текст с пробелами заключайте в кавычки.

Clock, Date и Timer

CYD_CLI.exe clock
CYD_CLI.exe date
CYD_CLI.exe timer 10
CYD_CLI.exe clock-stop clear
CYD_CLI.exe date-stop clear

Clock и Date получают локальную дату и время ПК при запуске, после чего независимо обновляются самим ESP32. По умолчанию Clock расположен на y=8, Date на y=40; оба элемента центрируются по горизонтали.

Timer показывает обратный отсчёт HH:MM:SS. В отличие от Clock и Date, команда CLI не завершается сразу: она ждёт аппаратное событие достижения нуля и затем печатает Timer complete. Для всех элементов можно дополнительно задать x y scale color background; команды *-stop принимают clear или keep.

SD, GIF и MP3

CYD_CLI.exe upload picture.gif /CYD/picture.gif
CYD_CLI.exe download /CYD/picture.gif downloaded.gif
CYD_CLI.exe sd-list /CYD
CYD_CLI.exe sd-delete /CYD/picture.gif
CYD_CLI.exe gif animation.gif 0 100 cover
CYD_CLI.exe gif-pause
CYD_CLI.exe gif-resume
CYD_CLI.exe gif-stop keep

CYD_CLI.exe mp3 music.mp3 255 once
CYD_CLI.exe mp3-pause
CYD_CLI.exe mp3-resume
CYD_CLI.exe mp3-stop
CYD_CLI.exe media-status
CYD_CLI.exe rgb 255 80 0

Декодер принимает MP3 с постоянным (CBR) и переменным (VBR) битрейтом. Гарантированно проверенный профиль — CBR не выше 256 кбит/с. VBR допустим, только если битрейт каждого отдельного кадра не превышает 256 кбит/с: среднего значения 256 кбит/с недостаточно, поскольку отдельные кадры могут достигать 320 кбит/с. Рекомендуемая перекодировка:

ffmpeg -i input.mp3 -codec:a libmp3lame -b:a 256k output.mp3

Если gif или mp3 получает локальный путь, CLI сначала загружает файл в /CYD/ на SD-карте. Абсолютный путь вида /CYD/music.mp3 запускает уже загруженный файл без повторной передачи. Для GIF нулевое число повторов означает бесконечный цикл. Воспроизведение выполняется ESP32 и продолжается после завершения CLI.

cover заполняет экран с обрезкой выходящих за края частей, contain показывает весь кадр с возможными полями, stretch растягивает кадр до размера экрана. По умолчанию используется cover.

Wi-Fi

CYD_CLI.exe wifi-scan
CYD_CLI.exe wifi-scan hidden

Команда выводит RSSI, канал, тип шифрования, BSSID и SSID. Вариант hidden просит ESP32 включить скрытые сети в результаты сканирования.

Тачскрин

CYD_CLI.exe calibrate 120
CYD_CLI.exe touch 10
CYD_CLI.exe touch 0
CYD_CLI.exe touch-raw 10

touch ждёт первое нажатие не более указанного числа секунд, печатает его координаты и сразу завершает программу. При таймауте выводит 0 0. touch 0 ждёт бесконечно.

x y

touch-raw обходит калибровку и печатает pressed raw_x raw_y pressure. Команда предназначена для проверки физического подключения XPT2046.

Вопросы

CYD_CLI.exe question ok "Операция завершена"
CYD_CLI.exe question yesno "Продолжить?" --beep 200
CYD_CLI.exe question yesnoignore "Повторить операцию?"
CYD_CLI.exe question custom "Выберите режим" "Тихий" "Обычный" "Турбо" --beep 254

Текст автоматически переносится, центрируется и уменьшается до подходящего размера. Нижняя полоса делится на 1–6 одинаковых сенсорных кнопок. CLI ждёт касания и печатает номер выбранного ответа, начиная с 1.

Стандартные кнопки имеют интернациональные подписи OK, YES, NO, IGNORE. Русский текст вопроса и пользовательские подписи команды custom остаются доступными и выводятся системным шрифтом.

Цвета

Поддерживаются имена black, white, red, green, blue, yellow, cyan, magenta, RGB888 в форме #RRGGBB и готовый RGB565 в форме 565:FFFF.

Полная справка:

CYD_CLI.exe --help

Коды завершения:

  • 0 — команда выполнена;
  • 1 — неправильные аргументы;
  • 2 — не удалось подключиться;
  • 3 — команда устройства завершилась ошибкой.

Лицензия

Copyright (C) CheshirCa 2026 — https://t.me/cheshircanest

CYD_CLI распространяется только для некоммерческого использования. При копировании и изменении необходимо сохранять атрибуцию. Полные условия, ограничения коммерческого использования и отказ от гарантий находятся в файле LICENSE.


English

CYD_CLI.exe controls a supported CYD display from cmd, PowerShell, batch files, and other programs. If --port is omitted or specified as --port auto, the program scans COM1 through COM256 and connects to the first device that answers the CYD HELLO command. To select a port explicitly, use an option such as --port COM5.

Quick start

CYD_CLI.exe info
CYD_CLI.exe reset
CYD_CLI.exe clear black
CYD_CLI.exe text 10 20 3 yellow "Hello CYD"
CYD_CLI.exe rect 10 60 120 40 cyan fill
CYD_CLI.exe circle 220 100 35 red outline
CYD_CLI.exe qr "https://example.com/CYD"
CYD_CLI.exe tone 880 500 255
CYD_CLI.exe melody "BPM=120: 4C4, 4D#4, 8Gb4, 16P, 32A7"
CYD_CLI.exe sd-info
CYD_CLI.exe wifi-scan

The melody <notation> [volume] command starts autonomous playback and waits for its completion event. Volume defaults to 255. Notation starts with BPM=20..400:; notes are separated by spaces or commas and use [duration][.][note][#|b][octave]. Durations are 1,2,4,8,16,32, notes are C,D,E,F,G,A,B/H, rests are P/R, and octaves are 1..7. For example, 4.C4 is a dotted quarter note, while C4 uses the default duration 4. Limits are 128 notes, 1024 UTF-8 bytes, and five minutes.

CYD_CLI_DogWaltz.cmd contains a ready monophonic “Dog Waltz” score. It runs CYD_CLI melody at volume 40.

The hardware commands pixel, line, rect, circle, triangle, and text send only their parameters. The ESP32 performs the actual drawing.

The parameterless reset command asks the firmware to restart the ESP32. This also works with the JC3248W535 ESP32-S3 native USB CDC connection, whose RTS/DTR lines are not wired to EN. The CLI exits after the command is acknowledged; the next command opens a new device connection.

Autonomous scrolling

CYD_CLI.exe scroll "ESP32 scrolling" left 90 10 3 cyan black

The arguments specify the text, direction, speed in pixels per second, duration in seconds, scale, foreground color, and background color. While the command is active, the ESP32 updates the scroll locally without receiving frames from the PC.

To use a custom region:

CYD_CLI.exe scroll "Status line" left 70 15 2 white black 0 190 320 32

System fonts, images, and QR codes

CYD_CLI.exe system-text 10 20 18 white Arial "PureBasic text"
CYD_CLI.exe text-file message.txt 14 white Arial black
Get-Content message.txt -Raw | CYD_CLI.exe stdin 14 white Arial black
CYD_CLI.exe image photo.png fit black
CYD_CLI.exe qr "https://example.com/CYD"
CYD_CLI.exe qr "WIFI:T:WPA;S:Network;P:password;;" black white 0

These commands use the PureBasic framebuffer. They support system fonts, antialiasing, Cyrillic text, and PureBasic image formats, but transfer more data than the hardware primitives.

QR command syntax:

qr <text> [foreground] [background] [scale]

The defaults are black foreground, white background, and automatic scale 0. The symbol and its required quiet zone are centered horizontally and vertically. UTF-8, Medium error correction, versions 1–10, and up to 212 UTF-8 bytes are supported. Quote text that contains spaces.

Clock, Date, and Timer

CYD_CLI.exe clock
CYD_CLI.exe date
CYD_CLI.exe timer 10
CYD_CLI.exe clock-stop clear
CYD_CLI.exe date-stop clear

Clock and Date receive the PC's local date and time when started, then update independently on the ESP32. By default, Clock is placed at y=8 and Date at y=40; both are centered horizontally.

Timer displays an HH:MM:SS countdown. Unlike Clock and Date, its CLI command does not exit immediately: it waits for the hardware completion event and then prints Timer complete. Each element also accepts x y scale color background; the *-stop commands accept clear or keep.

SD, GIF, and MP3

CYD_CLI.exe upload picture.gif /CYD/picture.gif
CYD_CLI.exe download /CYD/picture.gif downloaded.gif
CYD_CLI.exe sd-list /CYD
CYD_CLI.exe sd-delete /CYD/picture.gif
CYD_CLI.exe gif animation.gif 0 100 cover
CYD_CLI.exe gif-pause
CYD_CLI.exe gif-resume
CYD_CLI.exe gif-stop keep

CYD_CLI.exe mp3 music.mp3 255 once
CYD_CLI.exe mp3-pause
CYD_CLI.exe mp3-resume
CYD_CLI.exe mp3-stop
CYD_CLI.exe media-status
CYD_CLI.exe rgb 255 80 0

The decoder accepts both constant-bitrate (CBR) and variable-bitrate (VBR) MP3 files. The validated guaranteed profile is CBR at no more than 256 kbps. VBR is suitable only when every individual frame stays at or below 256 kbps: an average of 256 kbps is not sufficient because individual frames may reach 320 kbps. Recommended transcoding command:

ffmpeg -i input.mp3 -codec:a libmp3lame -b:a 256k output.mp3

When gif or mp3 receives a local path, the CLI first uploads the file to /CYD/ on the SD card. An absolute path such as /CYD/music.mp3 starts an already uploaded file without transferring it again. For GIF playback, zero loops means an infinite loop. Playback runs on the ESP32 and continues after the CLI exits.

cover fills the display and crops content outside its edges, contain shows the complete frame and may add borders, and stretch scales the frame to the display dimensions. The default mode is cover.

Wi-Fi

CYD_CLI.exe wifi-scan
CYD_CLI.exe wifi-scan hidden

The command prints RSSI, channel, encryption type, BSSID, and SSID. The hidden variant asks the ESP32 to include hidden networks in the results.

Touchscreen

CYD_CLI.exe calibrate 120
CYD_CLI.exe touch 10
CYD_CLI.exe touch 0
CYD_CLI.exe touch-raw 10

touch waits for the first press for at most the specified number of seconds, prints its coordinates, and exits immediately. On timeout, it prints 0 0. touch 0 waits indefinitely.

x y

touch-raw bypasses calibration and prints pressed raw_x raw_y pressure. Use it to verify the physical XPT2046 connection.

Questions

CYD_CLI.exe question ok "Operation complete"
CYD_CLI.exe question yesno "Continue?" --beep 200
CYD_CLI.exe question yesnoignore "Retry the operation?"
CYD_CLI.exe question custom "Select mode" "Quiet" "Normal" "Turbo" --beep 254

The text is wrapped, centered, and reduced to fit automatically. The bottom strip is divided into one to six equal touch buttons. The CLI waits for a touch and prints the selected answer number, starting with 1.

Standard buttons use the international labels OK, YES, NO, and IGNORE. Cyrillic question text and custom answer labels are supported and rendered with a system font.

Colors

Supported values are black, white, red, green, blue, yellow, cyan, and magenta, RGB888 as #RRGGBB, or preconverted RGB565 as 565:FFFF.

Full command reference:

CYD_CLI.exe --help

Exit codes:

  • 0 — command completed successfully;
  • 1 — invalid arguments;
  • 2 — connection failed;
  • 3 — the device command failed.

License

Copyright (C) CheshirCa 2026 — https://t.me/cheshircanest

CYD_CLI is distributed for non-commercial use only. Attribution must be preserved in copied or modified versions. See LICENSE for the complete terms, commercial-use restrictions, and warranty disclaimer.