MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / __init__

Method __init__

display.py:96–153  ·  view source on GitHub ↗

Initialize the display and start the main image and shared data update threads.

(self, shared_data)

Source from the content-addressed store, hash-verified

94 """
95 if rotation == 180:
96 return image.transpose(Image.Transpose.ROTATE_180)
97 if rotation == 270:
98 return image.transpose(Image.Transpose.ROTATE_180)
99 return image
100
101
102def _apply_web_rotation(image, rotation):
103 """Apply rotation for the web preview PNG.
104
105 The web preview should match what the user physically sees on the display.
106 * 0° – landscape, show as-is
107 * 90° – portrait, show as-is (getbuffer + physical mount cancel)
108 * 180° – landscape upside-down
109 * 270° – portrait upside-down (getbuffer + physical mount cancel, image was flipped)
110 """
111 if rotation in (180, 270):
112 return image.transpose(Image.Transpose.ROTATE_180)
113 return image
114
115logger = Logger(name="display.py", level=logging.DEBUG)
116
117# Import button listener (only functional on Pi with GPIO)
118try:
119 from epd_button import EPDButtonListener, PAGE_MAIN, PAGE_NETWORK, PAGE_VULN, PAGE_DISCOVERED, PAGE_ADVANCED, PAGE_TRAFFIC
120 from epd_button import (NETDIAG_CARD_FUNCS, NETDIAG_CARD_NAMES,
121 netdiag_card_funcs, netdiag_iface_choices,
122 netdiag_auto_iface)
123except ImportError:
124 EPDButtonListener = None
125 PAGE_MAIN, PAGE_NETWORK, PAGE_VULN, PAGE_DISCOVERED, PAGE_ADVANCED, PAGE_TRAFFIC = 0, 1, 2, 3, 4, 5
126 NETDIAG_CARD_NAMES = ["LINK", "IP", "SWITCH", "DHCP", "WIFI", "SIGNAL",
127 "SPECTRUM", "IFACE", "BT", "ZIGBEE"]
128 NETDIAG_CARD_FUNCS = {}
129 netdiag_card_funcs = (lambda page: [])
130 netdiag_iface_choices = (lambda: [])
131 netdiag_auto_iface = (lambda require_egress=False: None)
132
133# Network Diagnostic mode: number of auto-cycling sub-pages
134# (0=LINK, 1=IP, 2=SWITCH, 3=DHCP, 4=WIFI, 5=SIGNAL, 6=SPECTRUM, 7=IFACE,
135# 8=BT, 9=ZIGBEE). See Display._render_netdiag_page.
136NETDIAG_PAGE_COUNT = 10
137NETDIAG_CYCLE_SECONDS = 5
138
139# Wardriving screens on the 1.44" ST7735S LCD HAT (128x128), paged with the
140# joystick while wardriving runs. Mirrored by lcdhat_input.WARDRIVE_PAGE_COUNT.
141# 0=STATS 1=MAP 2=GPS 3=SKY 4=SESSION 5=VIKING
142# The 2.7" e-paper HAT is unaffected — it keeps its KEY3 stats/map toggle.
143WARDRIVE_PAGE_COUNT = 6
144(WD_PAGE_STATS, WD_PAGE_MAP, WD_PAGE_GPS, WD_PAGE_SKY,
145 WD_PAGE_SESSION, WD_PAGE_VIKING) = range(6)
146
147class Display:
148 def __init__(self, shared_data):
149 """Initialize the display and start the main image and shared data update threads."""
150 self.shared_data = shared_data
151 self.config = self.shared_data.config
152 self.shared_data.ragnarstatustext2 = "Awakening..."
153 self.commentaire_ia = Commentaireia()

Callers

nothing calls this directly

Calls 8

CommentaireiaClass · 0.90
detect_wifi_interfaceFunction · 0.90
EPDButtonListenerClass · 0.90
init_partial_updateMethod · 0.80
infoMethod · 0.80
errorMethod · 0.80
getMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected