Skip to content

Commit 555469b

Browse files
committed
Merge pull request #114 from jovermann/master
Do not use OIDs >= 15000.
2 parents 2f35261 + f89aa81 commit 555469b

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/KnownCodes.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ firstObjectCode :: Word16
1414
firstObjectCode = 1000
1515

1616
lastObjectCode :: Word16
17-
lastObjectCode = fromIntegral $ V.length knownRawCodes - 1
17+
-- Empirically, the pen does not recognize OIDs >= 15000:
18+
lastObjectCode = 14999
19+
-- Last object code accoring to the known raw codes:
20+
-- lastObjectCode = fromIntegral $ V.length knownRawCodes - 1
1821

1922
knownRawCodes :: V.Vector Word16
2023
knownRawCodes =

src/TipToiYaml.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,19 @@ scriptCodes codes codeMap productId
178178
-- objectCodeOffsetMax = lastObjectCode - firstObjectCode.
179179
-- This would assign perfectly usable object codes, and would minimize the
180180
-- probability of object code collisions between products, but sometimes
181-
-- object codes would wrap around from 16383 to 1000 even for small projects
181+
-- object codes would wrap around from 14999 to 1000 even for small projects
182182
-- which may be undesirable. We arbitrarily do not use the last 999 possible
183183
-- offsets to avoid a wrap around in object codes for projects with <= 1000
184184
-- object codes. This does not impose any limit on the number of object codes
185-
-- per project. Every project can always use all 15384 object codes.
185+
-- per project. Every project can always use all 14000 object codes.
186186
objectCodeOffsetMax = lastObjectCode - firstObjectCode - 999
187187

188188
-- Distribute the used object codes for different projects across the whole
189189
-- range of usable object codes. We do this by multiplying the productId with
190190
-- the golden ratio to achive a maximum distance between different projects,
191-
-- indepedent of the total number of different projects.
192-
-- 8890 = (16383-1000-999+1)*((sqrt(5)-1)/2)
193-
objectCodeOffset = toWord16(rem (productId * 8890) (toWord32(objectCodeOffsetMax) + 1))
191+
-- independent of the total number of different projects.
192+
-- 8035 = (14999-1000-999+1)*((sqrt(5)-1)/2)
193+
objectCodeOffset = toWord16(rem (productId * 8035) (toWord32(objectCodeOffsetMax) + 1))
194194

195195
-- objectCodes always contains _all_ possible object codes [firstObjectCode..lastObjectCode],
196196
-- starting at firstObjectCode+objectCodeOffset and then wrapping around.

0 commit comments

Comments
 (0)