-
Notifications
You must be signed in to change notification settings - Fork 22
/
stratux_hud.py
executable file
·82 lines (67 loc) · 2.26 KB
/
stratux_hud.py
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
"""
Main entry code for Stratux HUD
"""
# !python
#
# StratuxHud
#
# Written for Python 3.8
# This code may be run on the Stratux hardware,
# or on a stand-alone Raspberry Pi.
#
# Heavily inspired by https://github.com/kdknigga/pyahrs
#
# Powershell to extract CSV perf data from logs:
# ```
# (((((get-content stratux_hud.log) -replace "^.* - INFO - ", "") -replace "\<.*?\..*?\.", "") -replace " object.*\>", "") -replace "---.*-", "") | Where {$_ -ne ""}
# ```
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# Covered by the GPL V3
# You can view the GNU General Public License at <http://www.gnu.org/licenses/>
# The license is also available in LICENSE in this directory
import logging
import logging.handlers
import sys
from rendering import display
import heads_up_display
from common_utils.logger import HudLogger
__PYTHON_LOGGGER__ = logging.getLogger("stratux_hud")
__PYTHON_LOGGGER__.setLevel(logging.DEBUG)
__LOGGER__ = HudLogger(__PYTHON_LOGGGER__)
__HANDLER__ = logging.handlers.RotatingFileHandler(
"stratux_hud.log",
maxBytes=1048576,
backupCount=10)
__HANDLER__.setFormatter(
logging.Formatter(
'%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
__PYTHON_LOGGGER__.addHandler(__HANDLER__)
__USE_FULLSCREEN_FLAG__ = "fullscreen"
__USE_REDUCED_VISUALS_FLAG__ = "reduced"
def __is_flag_present__(
flag_name: str
) -> bool:
"""
Should we use fullscreen no matter what type of
runtime environment we are in.
Returns:
bool: Should the HUD use fullscreen?
"""
is_flag_present = False
for argument in sys.argv:
is_flag_present |= flag_name.lower() in argument.lower()
return is_flag_present
if __name__ == '__main__':
__LOGGER__.log_info_message("Starting HUD")
__LOGGER__.log_info_message("System, DateTime, Component, Instantaneous, Rolling Mean, Max")
hud = heads_up_display.HeadsUpDisplay(
__LOGGER__,
__is_flag_present__(__USE_FULLSCREEN_FLAG__),
__is_flag_present__(display.FORCE_SOFTWARE_FLAG),
__is_flag_present__(__USE_REDUCED_VISUALS_FLAG__))
hud.run()