-
-
Notifications
You must be signed in to change notification settings - Fork 125
display.py
infinition edited this page Jul 5, 2024
·
1 revision
This document describes the detailed step-by-step process of how the Display
class works, including the specific methods, classes, and functions used at each step.
- The
Display
class imports several modules, including standard libraries (threading
,time
,os
,pandas
,lgpio
,signal
,glob
,logging
,random
,sys
,subprocess
,netifaces
) and custom modules (Image
,ImageDraw
,shared_data
,epd2in13_V2
,Commentaireia
,Logger
).
- An instance of the
Display
class is created to initialize and manage the e-ink display.
- Purpose: Initializes the display and starts the main image and shared data update threads.
-
Key Steps:
-
Initialize Display:
- Initializes the e-ink display and handles any errors during initialization.
-
Start Threads:
- Starts the
update_main_image
,schedule_update_shared_data
, andschedule_update_vuln_count
threads to manage updates.
- Starts the
-
Initialize Display:
- Purpose: Periodically updates the shared data with the latest system information.
-
Key Steps:
-
Loop:
- Continuously updates shared data at regular intervals until the application is set to exit.
-
Loop:
- Purpose: Periodically updates the vulnerability count on the display.
-
Key Steps:
-
Loop:
- Continuously updates the vulnerability count at regular intervals until the application is set to exit.
-
Loop:
- Purpose: Updates the main image on the display with the latest image data.
-
Key Steps:
-
Loop:
- Continuously updates the main image at random intervals until the application is set to exit.
-
Randomize Image:
- Selects a new image based on the current status and updates the display.
-
Loop:
- Purpose: Updates the vulnerability count on the display.
-
Key Steps:
-
Load and Check Files:
- Loads the vulnerability summary file and network knowledge base file, and checks for alive hosts.
-
Update Vulnerability Count:
- Updates the vulnerability count based on the data and writes it to the live status file.
-
Load and Check Files:
- Purpose: Updates the shared data with the latest system information.
-
Key Steps:
-
Load and Check Files:
- Loads the live status file and cracked password files to update various counts.
-
Update Shared Data:
- Updates shared data attributes such as port count, target count, and various connection statuses.
-
Load and Check Files:
- Purpose: Displays a comment based on the status of the orchestrator.
-
Key Steps:
-
Fetch Comment:
- Retrieves a comment from the
Commentaireia
instance based on the current status.
- Retrieves a comment from the
-
Update Display:
- Updates the display with the fetched comment and current status text.
-
Fetch Comment:
- Purpose: Checks if Bluetooth is active.
-
Key Steps:
-
Run Command:
- Executes the
hciconfig
command to check the status of the Bluetooth adapter.
- Executes the
-
Check Status:
- Returns
True
if the adapter is up and running, otherwiseFalse
.
- Returns
-
Run Command:
- Purpose: Checks if Wi-Fi is connected.
-
Key Steps:
-
Run Command:
- Executes the
iwgetid
command to get the current SSID.
- Executes the
-
Check Connection:
- Returns
True
if connected to a Wi-Fi network, otherwiseFalse
.
- Returns
-
Run Command:
-
Purpose: Checks if any device is connected to the specified interface (e.g.,
pan0
orusb0
). -
Key Steps:
-
Run Command:
- Executes the
ip neigh show dev
command to check for connected devices.
- Executes the
-
Check Output:
- Returns
True
if there are any connected devices, otherwiseFalse
.
- Returns
-
Run Command:
-
Purpose: Checks if any device is connected to the USB interface (
usb0
). -
Key Steps:
-
Run Command:
- Executes the
ip neigh show dev usb0
command to check for connected devices.
- Executes the
-
Check Output:
- Returns
True
if there are any connected devices, otherwiseFalse
.
- Returns
-
Run Command:
- Purpose: Main loop for updating the e-ink display with shared data.
-
Key Steps:
-
Loop:
- Continuously updates the display until the application is set to exit.
-
Initialize Display:
- Initializes the e-ink display for partial updates.
-
Display Comment:
- Displays the current comment based on the orchestrator status.
-
Update Display Elements:
- Updates various elements on the display, including status icons, statistics, and images.
-
Render Display:
- Renders the updated content on the e-ink display and saves the current screen image.
-
Loop:
- Purpose: Handles the exit signal and closes the display.
-
Key Steps:
-
Set Exit Flag:
- Sets the
should_exit
flag toTrue
to signal all threads to stop.
- Sets the
-
Cleanup:
- Cleans up the display and exits the application.
-
Set Exit Flag:
- An instance of the
Display
class is created, initializing the e-ink display and starting update threads.
- The main loop is started in a separate thread to continuously update the display.
- The
update_main_image
,schedule_update_shared_data
, andschedule_update_vuln_count
threads continuously update the display and shared data.
- When an exit signal is received, the
handle_exit_display
function sets the exit flag and cleans up the display before exiting.
The Display
class is responsible for managing the e-ink display of the Bjorn project, updating it with relevant data and statuses. It initializes the display, manages multiple threads for updating shared data and vulnerability counts, and handles the rendering of information and images on the display. The class ensures that the display is continuously updated with the latest information and handles system commands to check the status of various connections.