summaryrefslogtreecommitdiff
path: root/source/codes/Pdf417.mc
diff options
context:
space:
mode:
authorcirakg <cirakg@cirakg.xyz>2026-10-25 14:17:45 +0100
committercirakg <cirakg@cirakg.xyz>2026-10-25 14:17:45 +0100
commit140a6660f63f88d05ba9aae0bf1c4b401bb6574d (patch)
tree943cbc93931e7ecabd979895ee29440a2c81c552 /source/codes/Pdf417.mc
parent67e7ce3d496c34a30ff498eaff2074543350318a (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'source/codes/Pdf417.mc')
-rw-r--r--source/codes/Pdf417.mc21
1 files changed, 20 insertions, 1 deletions
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<Number> {
+ return [62, 69];
}
function matrix() as Codes.Matrix? {