MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / drawVersion

Function drawVersion

Libraries/QRCode/src/qrcode.c:351–378  ·  view source on GitHub ↗

Draws two copies of the version bits (with its own error correction code), based on this object's version field (which only has an effect for 7 <= version <= 40).

Source from the content-addressed store, hash-verified

349// Draws two copies of the version bits (with its own error correction code),
350// based on this object's version field (which only has an effect for 7 <= version <= 40).
351static void drawVersion(BitBucket *modules, BitBucket *isFunction, uint8_t version) {
352
353 int8_t size = modules->bitOffsetOrWidth;
354
355#if LOCK_VERSION != 0 && LOCK_VERSION < 7
356 return;
357
358#else
359 if (version < 7) { return; }
360
361 // Calculate error correction code and pack bits
362 uint32_t rem = version; // version is uint6, in the range [7, 40]
363 for (uint8_t i = 0; i < 12; i++) {
364 rem = (rem << 1) ^ ((rem >> 11) * 0x1F25);
365 }
366
367 uint32_t data = version << 12 | rem; // uint18
368
369 // Draw two copies
370 for (uint8_t i = 0; i < 18; i++) {
371 bool bit = ((data >> i) & 1) != 0;
372 uint8_t a = size - 11 + i % 3, b = i / 3;
373 setFunctionModule(modules, isFunction, a, b, bit);
374 setFunctionModule(modules, isFunction, b, a, bit);
375 }
376
377#endif
378}
379
380static void drawFunctionPatterns(BitBucket *modules, BitBucket *isFunction, uint8_t version, uint8_t ecc) {
381

Callers 2

drawFunctionPatternsFunction · 0.85
drawFunctionPatternsMethod · 0.85

Calls 1

setFunctionModuleFunction · 0.85

Tested by 1

drawFunctionPatternsMethod · 0.68