-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvar.py
More file actions
88 lines (63 loc) · 2.86 KB
/
var.py
File metadata and controls
88 lines (63 loc) · 2.86 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Modules
from dotenv import load_dotenv
import json
import logging
import os
import sys
import time
import traceback
from PIL import ImageFont
##### VARIABLES #####
load_dotenv()
start_time = time.time()
##### SYSTEM #####
debuglevel = os.getenv("DEBUG_LEVEL", "INFO")
file_handler = logging.FileHandler('21UP.log')
stdout_handler = logging.StreamHandler(sys.stdout)
handlers = [file_handler, stdout_handler]
logging.basicConfig(handlers=handlers, format='%(asctime)s %(levelname)s - %(message)s', level=debuglevel)
logging.info(f"Setting debug level at {debuglevel}")
production = os.getenv("PRODUCTION", "True").lower() in ('true', '1', 't')
##### INVOICES #####
x_api_key = os.getenv("LNBITS_INVOICE_KEY")
lnbits_server = os.getenv("LNBITS_SERVER", "send.laisee.org")
memo_str = os.getenv("MEMO_STRING", "Thank you for your purchase from 21UP!")
expiry = int(os.getenv("INVOICE_EXPIRY", 60))
##### TRAYS #####
tray0 = json.loads(os.environ['TRAY0'])
tray1 = json.loads(os.environ['TRAY1'])
tray2 = json.loads(os.environ['TRAY2'])
tray3 = json.loads(os.environ['TRAY3'])
tray4 = json.loads(os.environ['TRAY4'])
tray5 = json.loads(os.environ['TRAY5'])
label = [tray0[0], tray1[0], tray2[0], tray3[0], tray4[0], tray5[0]]
amount = [tray0[1], tray1[1], tray2[1], tray3[1], tray4[1], tray5[1]]
unit = [tray0[2], tray1[2], tray2[2], tray3[2], tray4[2], tray5[2]]
pin_in = [tray0[3], tray1[3], tray2[3], tray3[3], tray4[3], tray5[3]]
pin_out = [tray0[4], tray1[4], tray2[4], tray3[4], tray4[4], tray5[4]]
logging.debug(f"Labels: {label}")
logging.debug(f"Amounts: {amount}")
logging.debug(f"Unit: {unit}")
logging.debug(f"Pin In: {pin_in}")
logging.debug(f"Pin Out: {pin_out}")
button_delay = float(os.getenv("BUTTON_DELAY", 50)) / 1000
relay_duration = float(os.getenv("RELAY_DURATION", 500)) / 1000
##### DISPLAY #####
show_display = os.getenv("SHOWDISPLAY", "True").lower() in ('true', '1', 't')
display_expiry = int(os.getenv("DISPLAY_DELAY", 1))
suceess_screen_expiry = int(os.getenv("SUCCESS_SCREEN_EXPIRY", 5))
picdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'pic')
press_icondir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'pic/press_icons')
libdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'lib')
if os.path.exists(libdir):
sys.path.append(libdir)
press_icons = os.listdir(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'pic/press_icons'))
font_a = os.getenv("FONTA", "Font.ttc")
font_b = os.getenv("FONTB", "Rushfordclean.otf")
fontsize_a = int(os.getenv("FONTSIZEA", 24))
fontsize_b = int(os.getenv("FONTSIZEB", 32))
#font36 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 36)
fontA = ImageFont.truetype(os.path.join(picdir, font_a), fontsize_a)
fontB = ImageFont.truetype(os.path.join(picdir, font_b), fontsize_b)
##### BAROMETER #####
barometer = os.getenv("BAROMETER", "True").lower() in ('true', '1', 't')