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

Function getModeBits

Libraries/QRCode/src/qrcode.c:147–164  ·  view source on GitHub ↗

We store the following tightly packed (less 8) in modeInfo <=9 <=26 <= 40 NUMERIC ( 10, 12, 14); ALPHANUMERIC ( 9, 11, 13); BYTE ( 8, 16, 16);

Source from the content-addressed store, hash-verified

145// ALPHANUMERIC ( 9, 11, 13);
146// BYTE ( 8, 16, 16);
147static char getModeBits(uint8_t version, uint8_t mode) {
148 // Note: We use 15 instead of 16; since 15 doesn't exist and we cannot store 16 (8 + 8) in 3 bits
149 // hex(int("".join(reversed([('00' + bin(x - 8)[2:])[-3:] for x in [10, 9, 8, 12, 11, 15, 14, 13, 15]])), 2))
150 unsigned int modeInfo = 0x7bbb80a;
151
152#if LOCK_VERSION == 0 || LOCK_VERSION > 9
153 if (version > 9) { modeInfo >>= 9; }
154#endif
155
156#if LOCK_VERSION == 0 || LOCK_VERSION > 26
157 if (version > 26) { modeInfo >>= 9; }
158#endif
159
160 char result = 8 + ((modeInfo >> (3 * mode)) & 0x07);
161 if (result == 15) { result = 16; }
162
163 return result;
164}
165
166
167

Callers 1

encodeDataCodewordsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected