Skip to content

Commit

Permalink
Added DME display depending on HSI source
Browse files Browse the repository at this point in the history
  • Loading branch information
blauret committed Dec 13, 2023
1 parent 50516a1 commit b2c50c6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
16 changes: 16 additions & 0 deletions pyG5/pyG5Network.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ def __init__(self, parent=None):
# list the datarefs to request
self.datarefs = [
# ( dataref, frequency, unit, description, num decimals to display in formatted output )
(
"sim/cockpit/radios/nav1_dme_dist_m",
30,
"kt",
"dme Range anv1",
0,
"_nav1dme",
),
(
"sim/cockpit/radios/nav2_dme_dist_m",
30,
"kt",
"dme Range nav2",
0,
"_nav2dme",
),
(
"sim/cockpit2/radios/indicators/nav1_bearing_deg_mag",
30,
Expand Down
18 changes: 15 additions & 3 deletions pyG5/pyG5View.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ def __init__(self, parent=None):
("nav2dft", 0),
("nav1bearing", 0),
("nav2bearing", 0),
("nav1dme", 0),
("nav2dme", 0),
("gpsdft", 0),
("gpsgsavailable", 0),
("gpsvnavavailable", 0),
Expand Down Expand Up @@ -1305,7 +1307,11 @@ def paintEvent(self, event):
)

# draw the dist box
if int(self._hsiSource) == 2:
if (
int(self._hsiSource) == 2
or (int(self._hsiSource) == 1 and int(self._nav2fromto) != 0)
or (int(self._hsiSource) == 0 and int(self._nav1fromto) != 0)
):
font.setPixelSize(12)
font.setBold(False)
self.qp.setFont(font)
Expand All @@ -1325,12 +1331,18 @@ def paintEvent(self, event):
font.setBold(True)
self.qp.setFont(font)
self.setPen(1, navColor)
if int(self._hsiSource) == 2:
dist = self._gpsdmedist
elif int(self._hsiSource) == 1:
dist = self._nav2dme
else:
dist = self._nav1dme

distRect = QRectF(g5Width - 105, 12, 105, 45 - 12)
self.qp.drawText(
distRect,
Qt.AlignmentFlag.AlignCenter,
"{}".format(round(self._gpsdmedist, 1)),
"{}".format(round(dist, 1)),
)

# set default font size
Expand Down Expand Up @@ -1596,7 +1608,7 @@ def paintEvent(self, event):
"{}".format(self.getNavTypeString(self._nav1type, "")),
)

if int(self._nav2fromto) != 0:
if int(self._nav2fromto) != 0 and vertAvailable == 0:
# set color to grey
self.setPen(2, Qt.GlobalColor.gray)

Expand Down

0 comments on commit b2c50c6

Please sign in to comment.