Photonicat 2 小屏幕自定义
| 适用 / Applies to | Photonicat 2(内置 LCD 小屏), pcat-manager-web 2026-06 及以后版本 / Photonicat 2 (built-in LCD), pcat-manager-web builds from 2026-06 onward |
|---|
Photonicat 2 的内置小屏幕不只是状态显示器——通过管理界面的 /screen 页面可以调整亮度息屏策略、可视化编辑屏幕布局,甚至接入自定义数据源(HTTP 接口 / Shell 命令 / UCI 配置值),把任何你关心的数据显示到屏幕上(公网 IP、BTC 价格、家里的温度传感器……)。
The photonicat 2's built-in mini screen is more than a status display — the manager UI's /screen page lets you tune brightness/dimming, visually edit the screen layout, and attach custom data sources (HTTP endpoints / shell commands / UCI values) to render any data you care about (public IP, BTC price, a home temperature sensor…).
中文说明
页面地址:管理界面 → 小屏幕(/screen),共三个标签页。
1. 屏幕设置
- 最大 / 最小亮度:设定屏幕亮度范围。
- 自动降低亮度时间:电池供电与充电两种状态分别设定息屏/降亮延迟——插电时可以常亮,用电池时尽快变暗省电。
- 短信显示开关及条数限制:控制屏幕上是否显示短信以及最多显示多少条(隐私考虑可关闭)。
- 实时预览:页面内嵌当前屏幕画面的实时预览(后端接口
/api/v1/screen/frame.png),不用低头看设备就能确认显示效果。
2. 屏幕编辑器
可视化布局编辑器,在网页上的画布中直接编辑屏幕内容:
- 添加/移动/删除显示元素,绑定数据键(data key)——既可用内置数据(电量、信号、速率、公网 IP 等),也可用下述自定义数据源产生的键。
- 编辑结果保存到
user_config,Web 后端与屏幕守护进程(Go 程序)读取同一份配置,保存后屏幕立即生效。 - 恢复默认:默认布局可随时通过
/api/v1/screen/default_config.json找回,改坏了不用怕。
3. 自定义数据源(custom_metrics)
编辑器下方的数据源区域可添加三种类型的数据源,产生的 data key 供屏幕元素引用:
| 类型 | 说明 | 典型用途 |
|---|---|---|
| HTTP/HTTPS 轮询 | 周期性请求一个 URL,按配置的解析器提取数值 | 公网 IP、加密货币价格(BTC 示例用 Photonicat 官方 API)、天气、家庭传感器接口 |
| 命令 Command | 周期性执行一条 shell 命令,取其输出 | CPU 温度、磁盘剩余、连接数、任意脚本 |
| UCI 值 | 读取一项 OpenWrt UCI 配置 | 显示当前 SSID、APN 等配置项 |
- 每个数据源有启用开关、独立的采集周期与解析设置。
- 状态与测试:每个源显示最近一次取值/错误信息与成功次数,并有"立即执行"按钮(
/api/v1/screen/custom_metrics/<源名>/execute)方便调试,不用等下一个周期。
4. Public IP 标签页
自定义公网 IP 查询(网页与 LCD 共用):多个 URL 按顺序尝试、每源可配 json:字段 / regex:正则 / line:行号 解析器、自定义 User-Agent,返回值自动校验为合法 IPv4/IPv6。photonicat.com 被墙时换成任意可达的 IP 查询源即可恢复屏幕公网 IP 显示。页面内有完整示例。
English
Location: manager UI → Mini Screen (/screen), three tabs.
1. Screen settings
- Max / min brightness range.
- Auto-dim delays set separately for on-battery and on-charger — stay bright when plugged in, dim fast on battery.
- SMS display toggle and count limit — hide messages from the screen entirely for privacy, or cap how many show.
- Live preview embedded in the page (backed by
/api/v1/screen/frame.png) so you can verify the layout without looking at the device.
2. Screen editor
A visual canvas editor for the screen layout:
- Add/move/remove display elements and bind them to data keys — built-ins (battery, signal, throughput, public IP…) or keys produced by the custom data sources below.
- Layouts persist to
user_config, read by both the web backend and the Go screen daemon — one config, applied immediately on save. - The factory layout is always recoverable via
/api/v1/screen/default_config.json.
3. Custom data sources (custom_metrics)
Three source types feed data keys for screen elements:
| Type | What it does | Typical uses |
|---|---|---|
| HTTP/HTTPS poll | Periodically fetch a URL and extract a value with a configured parser | public IP, crypto prices (the BTC example uses the official Photonicat API), weather, home sensor endpoints |
| Command | Periodically run a shell command and take its output | CPU temperature, disk free, connection counts, any script |
| UCI value | Read an OpenWrt UCI config value | current SSID, APN, any config item |
- Each source has an enable toggle, its own poll interval and parser settings.
- Status & testing: per-source last value/error and success count, plus an execute-now button (
/api/v1/screen/custom_metrics/<name>/execute) for debugging without waiting a cycle.
4. Public IP tab
Configurable public-IP lookup shared by the web UI and the LCD: ordered URLs, per-source json:field / regex:pattern / line:N parsers, custom User-Agent, responses validated as real IPv4/IPv6. If photonicat.com is blocked in your region, point it at any reachable IP echo service and the LCD shows your public IP again. A worked example is embedded in the page.