Files
makronix/mobile/tools/phone-screen.sh
T
lotherkandClaude Sonnet 5.5 73c9de51a6 licence: the CNCL line in every file Makronix wrote (tools, docs, www, mobile, top level)
consmirror.c: the BSD notice is replaced (Makronix's own file).  Files with
changes of other sessions pending are left for their commit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 11:50:26 +00:00

28 lines
1.0 KiB
Bash

#!/bin/sh
# License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree.
#
# Grab one frame of a camera pointed at the phone and print the mean
# brightness (0-255) of the screen's area: the measure of "white display"
# for boot tests (devices/hotdogb/AGENTS.md) that needs no one at the
# phone. Calibrated 2026-11-08 with the camera of that day: 0 for the
# black console, 255 for a white framebuffer.
#
# Usage: phone-screen.sh [OUT.jpg]
# CAM (default /dev/video4) names the camera, CROP the screen's area in
# its frame as ffmpeg's w:h:x:y (default 500:700:600:150).
set -eu
. "$(dirname "$0")/lib.sh"
cam=${CAM:-/dev/video4}
crop=${CROP:-500:700:600:150}
out=${1:-$ROOT/build/cam/screen.jpg}
mkdir -p "$(dirname "$out")"
command -v ffmpeg >/dev/null || die "needs ffmpeg"
timeout 20 ffmpeg -hide_banner -loglevel error -f v4l2 -i "$cam" \
-frames:v 1 -y "$out" || die "no frame from $cam"
ffmpeg -hide_banner -loglevel error -i "$out" \
-vf "crop=$crop,scale=1:1" -f rawvideo -pix_fmt gray - |
od -An -tu1 | tr -d ' '