-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconst.py
More file actions
58 lines (42 loc) · 1.54 KB
/
Copy pathconst.py
File metadata and controls
58 lines (42 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#-*- coding:utf-8 -*-
# Global variables and Constants defined here
# sizes of QR Code, on increasing in steps of 4 modules per side up to
# Version 40 which measures 177 modules × 177 module
VERSION_TABLE = {1: 21, 2: 25, 3: 29, 40: 177}
# mode indicators
MODES = {'ECI': 7, 'Numeric': 1, 'Alphanumeric': 2, 'Byte': 4, 'Kanji': 8}
# mode indicators bits
MODE_BITS = 4
# ending symbol
ENDING = '0000'
# error correction indicator
ERROR_CORR_INDICATOR = {'L': '01', 'M': '00', 'Q': '11', 'H': '10'}
# the alpha-numeric map table
ALPHANUMERIC_TABLE = {' ': 36, '$': 37, '%': 38, '*': 39, '+': 40,
'-': 41, '.': 42, '/': 43, ':': 44, '0': 0, 'A': 10}
# character count indicator
COUNT_INDICATOR = 9
# encode data bits
DATA_BITS = 11
DATA_BITS_MINI = 6
# codeword bits
CODEWORD_BITS = 8
# the data capacity of qr code on specific mode and correction level
DATA_CAPACITY = {2: {'Alphanumeric': {'L': 47, 'M': 38, 'Q': 29, 'H': 20}}}
# number of max data bits
MAX_DATA_BITS = {'L': 272, 'M': 224, 'Q': 176, 'H': 128}
# padding bytes
PADDING_BYTES = ['11101100', '00010001']
# Error correction code per block (c, k, r)
# c = total number of codewords
# k = number of data codewords,
# r = error correction capacity
ERROR_CORR_PER_BLOCK = {'L': (44, 34, 4), 'M': (44, 28, 8),
'Q': (44, 22, 11), 'H': (44, 16, 14)}
# Number of error correction codewords
NUM_OF_CORR_CODEWORDS = {'L': 10, 'M': 16, 'Q': 22, 'H': 28}
# Value of p
VALLUE_OF_P = {'L': 2, 'M': 0, 'Q': 0, 'H': 0}
# draw direction
UPWARDS = 0
DOWNWARDS = 1