Skip to content

Commit

Permalink
fix missing path, remove unused code, use more common fonts, make tex…
Browse files Browse the repository at this point in the history
…t rescale
  • Loading branch information
mavlab-field committed Sep 20, 2018
1 parent 5fe023a commit 56dc535
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 24 deletions.
59 changes: 51 additions & 8 deletions sw/ground_segment/python/atc/atc_frame.py
Expand Up @@ -27,9 +27,11 @@
import array
from cStringIO import StringIO


PPRZ_HOME = os.getenv("PAPARAZZI_HOME", os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
'../../../..')))
'../../../..')))

PPRZ_SRC = os.getenv("PAPARAZZI_SRC", os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
'../../../..')))

sys.path.append(PPRZ_HOME + "/var/lib/python")

Expand Down Expand Up @@ -60,23 +62,63 @@ def message_recv(self, ac_id, msg):
def update(self):
self.Refresh()

def OnSize(self, event):
self.w = event.GetSize()[0]
self.h = event.GetSize()[1]
self.Refresh()

def StatusBox(self, dc, nr, txt, percent, color):
if percent < 0:
percent = 0
if percent > 1:
percent = 1
boxw = self.stat
tdx = int(boxw * 10.0 / 300.0)
tdy = int(boxw * 6.0 / 300.0)
boxh = int(boxw * 40.0 / 300.0)
boxw = self.stat - 2*tdx
spacing = boxh+10

dc.SetPen(wx.Pen(wx.Colour(0,0,0)))
dc.SetBrush(wx.Brush(wx.Colour(220,220,220)))
dc.DrawRectangle(tdx, int(nr*spacing+tdx), int(boxw), boxh)
if color < 0.2
dc.SetBrush(wx.Brush(wx.Colour(250,0,0)))
elif color < 0.6:
dc.SetBrush(wx.Brush(wx.Colour(250,180,0)))
else:
dc.SetBrush(wx.Brush(wx.Colour(0,250,0)))
# dc.DrawLine(200,50,350,50)
dc.DrawRectangle(tdx, int(nr*spacing+tdx), int(boxw * percent), boxh)
dc.DrawText(txt,18,int(nr*spacing+tdy+tdx))


def OnPaint(self, e):
tdx = 10
tdy = 80

w = self.w
h = self.w
h = self.h

if (float(w)/float(h)) > (7.0/5.0):
w = int(h * 7.0/5.0)
else:
h = int(w * 5.0/7.0)

tdy = int(w * 75.0 / 700.0)
tdx = int(w * 15.0 / 700.0)

dc = wx.PaintDC(self)
#brush = wx.Brush("white")
#dc.SetBackground(brush)
#dc.Clear()

fontscale = int(w * 40.0 / 700.0)
if fontscale < 6:
fontscale = 6

# Background
dc.SetBrush(wx.Brush(wx.Colour(0,0,0), wx.TRANSPARENT))
#dc.DrawCircle(w/2,w/2,w/2-1)
font = wx.Font(40, wx.ROMAN, wx.BOLD, wx.NORMAL)
font = wx.Font(fontscale, wx.FONTFAMILY_ROMAN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)
dc.SetFont(font)
dc.DrawText("Airspeed: " + str(self.airspeed) + " kt",tdx,tdx)
dc.DrawText("Ground Speed: " + str(self.gspeed) + " kt",tdx,tdx+tdy*1)
Expand All @@ -97,8 +139,8 @@ def OnPaint(self, e):

def __init__(self):

self.w = 900
self.h = 700
self.w = 700
self.h = 500

self.airspeed = 0;

Expand All @@ -116,6 +158,7 @@ def __init__(self):


self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_CLOSE, self.OnClose)

ico = wx.Icon(PPRZ_SRC + "/sw/ground_segment/python/atc/atc.ico", wx.BITMAP_TYPE_ICO)
Expand Down
20 changes: 4 additions & 16 deletions sw/ground_segment/python/energy_mon/energy_mon_viewer.py
Expand Up @@ -39,18 +39,6 @@
BARH = 140


def QIColour(qi):
return {
0: wx.Colour(64, 64, 64), # This channel is idle
1: wx.Colour(128, 128, 128), # Searching
2: wx.Colour(0, 128, 128), # Signal aquired
3: wx.Colour(255, 0, 0), # Signal detected but unusable
4: wx.Colour(0, 0, 255), # Code Lock on Signal
5: wx.Colour(0, 255, 0), # Code and Carrier locked
6: wx.Colour(0, 255, 0), # Code and Carrier locked
7: wx.Colour(0, 255, 0), # Code and Carrier locked
}[qi]


class EnergyMessage(object):
def __init__(self, msg):
Expand Down Expand Up @@ -102,7 +90,7 @@ def get_temp_perc(self):
return (self.temperature / 60);

def get_volt_color(self):
if self.voltage < 3.4:
if self.voltage < 3.2:
return 0.1
elif self.voltage < 3.6:
return 0.5
Expand All @@ -125,9 +113,9 @@ def get_energy_color(self):
def get_temp_color(self):
if (self.temperature > 20) & (self.temperature < 40):
return 1
elif (self.temperature > 10) & (self.temperature < 50):
return 0.1
return 0
elif (self.temperature > 10) & (self.temperature < 55):
return 0.5
return 0.1

class EnergyMonFrame(wx.Frame):
def message_recv(self, ac_id, msg):
Expand Down
2 changes: 2 additions & 0 deletions sw/ground_segment/python/svinfo/svinfoviewer.py
Expand Up @@ -25,6 +25,8 @@

PPRZ_HOME = os.getenv("PAPARAZZI_HOME", os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
'../../../..')))
PPRZ_SRC = os.getenv("PAPARAZZI_SRC", os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
'../../../..')))

PPRZ_SRC = os.getenv("PAPARAZZI_SRC", os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)),
'../../../..')))
Expand Down

0 comments on commit 56dc535

Please sign in to comment.