Add rotation calibration and millimetre rulers on the calibration sheet
A new rotation setting turns the whole print about the sheet centre, in steps of 0.01 degree, on card sheets and the calibration sheet. The calibration sheet now has millimetre rulers at every card edge; the four lettered ones (A to D) are typed into Settings, which converts them into corrected offsets and rotation. A simulation test checks the conversion against modelled printer errors. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
5dfb50f1a8
commit
e23b6ee6c4
13 files changed
+410
-54
No files matched your search
+22
-3
@@ -51,15 +51,34 @@ test('updateBook round-trips fields', () => {
|
||||
|
||||
test('settings and cache', () => {
|
||||
const db = openDb(':memory:');
|
||||
assert.deepEqual(db.getSettings(), { offsetXmm: 0, offsetYmm: 0 });
|
||||
db.putSettings({ offsetXmm: 1.5, offsetYmm: -2 });
|
||||
assert.deepEqual(db.getSettings(), { offsetXmm: 1.5, offsetYmm: -2 });
|
||||
assert.deepEqual(db.getSettings(), { offsetXmm: 0, offsetYmm: 0, rotationDeg: 0 });
|
||||
db.putSettings({ offsetXmm: 1.5, offsetYmm: -2.05, rotationDeg: 0.37 });
|
||||
assert.deepEqual(db.getSettings(), { offsetXmm: 1.5, offsetYmm: -2.05, rotationDeg: 0.37 });
|
||||
assert.equal(db.cache.get('k'), null);
|
||||
db.cache.set('k', 'v');
|
||||
db.cache.set('k', 'w');
|
||||
assert.equal(db.cache.get('k'), 'w');
|
||||
});
|
||||
|
||||
test('settings saved before rotation existed read rotation as 0', async () => {
|
||||
const { DatabaseSync } = await import('node:sqlite');
|
||||
const { mkdtempSync, rmSync } = await import('node:fs');
|
||||
const { tmpdir } = await import('node:os');
|
||||
const { join } = await import('node:path');
|
||||
const dir = mkdtempSync(join(tmpdir(), 'booksorter-settings-'));
|
||||
try {
|
||||
const path = join(dir, 'old.db');
|
||||
const first = openDb(path);
|
||||
first.close();
|
||||
const raw = new DatabaseSync(path);
|
||||
raw.prepare("INSERT INTO settings (key, value) VALUES ('settings', ?)").run(JSON.stringify({ offsetXmm: -2.7, offsetYmm: 0.5 }));
|
||||
raw.close();
|
||||
const db = openDb(path);
|
||||
assert.deepEqual(db.getSettings(), { offsetXmm: -2.7, offsetYmm: 0.5, rotationDeg: 0 });
|
||||
db.close();
|
||||
} finally { rmSync(dir, { recursive: true, force: true }); }
|
||||
});
|
||||
|
||||
test('a database made before the hierarchy tail gets the column; old books read as not looked for', async () => {
|
||||
const { DatabaseSync } = await import('node:sqlite');
|
||||
const { mkdtempSync, rmSync } = await import('node:fs');
|
||||
|
||||
Reference in new issue
Block a user