summaryrefslogtreecommitdiff
path: root/source/settings
diff options
context:
space:
mode:
authorcirakg <cirakg@cirakg.xyz>2026-10-21 03:55:01 +0200
committercirakg <cirakg@cirakg.xyz>2026-10-21 03:55:01 +0200
commit88f1cac4fa530fc30fd6ef01970af11c7a959b8e (patch)
tree4e2e52b36a6faa2dd50d3b6b07fbfe46fb5dc48c /source/settings
parenta69e23fb5266dd942d125239e7dcbe8a7c8ab956 (diff)
fix(codes): bound every 2D encoding step under the watchdog; draw large codes from runs
M6's step sizes were estimates, only exercised with small codes. With the largest inputs the app accepts, every 2D encoder tripped the watchdog on the Forerunner 255S (and the biggest steps were far over the 768 KB watches' limit), so a large code added from the phone would have stopped the app during settings processing at every start. - QR: resumable segmentation, Reed-Solomon, interleaving, function patterns and final mask; mask scoring on rows and columns packed 16 modules per word (same penalties, checked against the per-module rules). - Reed-Solomon: resumable field tables and generator, encoder shifting with native slice. - Data Matrix, Aztec, PDF417: resumable encodation, stuffing, compaction, placement and build; Data Matrix's grid as a byte array (90 KB -> 35 KB); PDF417 refuses text that can't fit the screen before compacting. - Cache format 2 with 16-bit sizes (wide PDF417 was cached wrong); packing in steps; codes drawn as runs, and from a bitmap painted in steps when a frame can't draw all runs. - The job runner does two steps per tick on 768 KB watches; gen_products --check verifies each product's watchdogCount fits that. - CodeView renews full brightness (AMOLED) or the backlight (MIP) for up to a minute from its single ticker; a tap restarts the minute. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'source/settings')
-rw-r--r--source/settings/CodeForm.mc20
1 files changed, 12 insertions, 8 deletions
diff --git a/source/settings/CodeForm.mc b/source/settings/CodeForm.mc
index 89d519d..810cd6e 100644
--- a/source/settings/CodeForm.mc
+++ b/source/settings/CodeForm.mc
@@ -115,7 +115,8 @@ module CodeForm {
// Encodes a code once to prove it is valid and to check that it fits this
// screen. When step() returns true: error is set, or the code is fine
-// (notes may hold remarks) and, for 2D codes, cache holds Matrix.toBytes().
+// (notes may hold remarks) and, for 2D codes, cache holds the packed matrix
+// (Codes.Packed).
class CodeCheck extends Jobs.Job {
// Linear codes draw with 10 quiet modules on each side (CodeView).
@@ -129,7 +130,7 @@ class CodeCheck extends Jobs.Job {
private var _payload as String;
private var _options as Number;
private var _job as Codes.MatrixJob? = null;
- private var _matrix as Codes.Matrix? = null;
+ private var _packer as Codes.Packer? = null;
private var _started as Boolean = false;
private var _w as Number;
private var _h as Number;
@@ -157,11 +158,14 @@ class CodeCheck extends Jobs.Job {
_payload = "";
return false;
}
- var matrix = _matrix;
- if (matrix != null) {
- // Packing gets a step of its own (it runs over every module).
- cache = matrix.toBytes();
- _matrix = null;
+ var packer = _packer;
+ if (packer != null) {
+ // Packing runs in steps of its own (it visits every module).
+ if (!packer.step(budget)) {
+ return false;
+ }
+ cache = packer.result;
+ _packer = null;
return true;
}
var job = _job as Codes.MatrixJob;
@@ -181,7 +185,7 @@ class CodeCheck extends Jobs.Job {
if (!Codes.fits(totalW, totalH, px, _w, _h, _round)) {
notes.add("Too large for this screen: needs " + px + " px per module, " + totalW * px + " x " + totalH * px + " px");
}
- _matrix = m;
+ _packer = new Codes.Packer(m);
return false;
}