From 140a6660f63f88d05ba9aae0bf1c4b401bb6574d Mon Sep 17 00:00:00 2001 From: cirakg Date: Sun, 25 Oct 2026 14:17:45 +0100 Subject: fix(codes): encoding progress follows the work The QR percentage counted phases and the display froze at 90 % once encoding ended, so the first opening sat at 90 % while the slow stages ran. Each 2D symbology now weights its phases by measured cost, interpolates inside the long ones, and the display splits encode, pack and runs; a cached code counts its runs from 0. Co-Authored-By: Claude Opus 5.5 --- source/codes/Pdf417.mc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'source/codes/Pdf417.mc') diff --git a/source/codes/Pdf417.mc b/source/codes/Pdf417.mc index a294aa7..c905a2d 100644 --- a/source/codes/Pdf417.mc +++ b/source/codes/Pdf417.mc @@ -35,6 +35,8 @@ module Pdf417 { const NUMERIC_LATCH = 902; const ROW_HEIGHT = 3; const QUIET = 2; + // Cumulative percent at the end of each phase 0-2 (see Pdf417Job.percent). + const PHASE_ENDS = [40, 70, 100]; const MAX_CODEWORDS = 928; const KIND_TEXT = 0; @@ -383,8 +385,25 @@ module Pdf417 { level = ecLevel; } + // Progress 0-100: the share of each phase (simulator timings), and + // inside the Reed-Solomon and row phases how far they have got. function percent() as Number { - return _phase == 1 && _words.size() > 0 ? 20 + 60 * _at / _words.size() : _phase * 30; + var done = 0; + var total = 0; + if (_phase == 1) { // data codewords done + done = _at; + total = _words.size(); + } else if (_phase == 2) { // rows built + done = _at; + total = rows; + } + return Codes.phased(PHASE_ENDS, _phase, done, total); + } + + // Packing and runs: about 62 / 7 / 31 % of a whole display job (the + // wide matrices make the runs a third). + function stageEnds() as Array { + return [62, 69]; } function matrix() as Codes.Matrix? { -- cgit v1.2.3