summaryrefslogtreecommitdiff
path: root/source/codes/Aztec.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/Aztec.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/Aztec.mc')
-rw-r--r--source/codes/Aztec.mc21
1 files changed, 20 insertions, 1 deletions
diff --git a/source/codes/Aztec.mc b/source/codes/Aztec.mc
index 495abbf..0d4a856 100644
--- a/source/codes/Aztec.mc
+++ b/source/codes/Aztec.mc
@@ -44,6 +44,8 @@ module Aztec {
const FIELD_ENTRIES_PER_STEP = 500; // GF(1024) / GF(4096) tables
const GENERATOR_WORK_PER_STEP = 500; // generator coefficient updates
const ECC_WORK_PER_STEP = 400; // data symbols x EC symbols
+ // Cumulative percent at the end of each phase 0-5 (see AztecJob.percent).
+ const PHASE_ENDS = [8, 14, 20, 64, 72, 100];
const GRID_LINES_PER_STEP = 4; // reference grid
const WORDS_PER_STEP = 50; // codewords into bits
const PAIRS_PER_STEP = 250; // spiral bit pairs
@@ -314,8 +316,25 @@ module Aztec {
_ec = EC_PERCENT[option] as Number;
}
+ // Progress 0-100: the share of each phase (simulator timings; the
+ // Reed-Solomon codewords and the spiral take the most).
function percent() as Number {
- return _phase * 100 / 6;
+ var done = 0;
+ var total = 0;
+ var e = _encoder;
+ if (_phase == 3 && e != null) { // data symbols done
+ done = e.percent();
+ total = 100;
+ } else if (_phase == 5) { // bits placed
+ done = _at;
+ total = _bits.size();
+ }
+ return Codes.phased(PHASE_ENDS, _phase, done, total);
+ }
+
+ // Packing and runs: about 86 / 3 / 11 % of a whole display job.
+ function stageEnds() as Array<Number> {
+ return [86, 89];
}
function matrix() as Codes.Matrix? {