Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed GUI crashes on RaspberryPi. #221

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pythoncode/FortiusAnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,17 @@ def GuiMessageToMain(self, command, wait=True, p1=None, p2=None):
# while we are waiting for the response on cmd_Runoff or cmd_Tacx2Dongle
# we ignore the response here and cmd_StopButton does not start wait-loop
# to avoid some sort of nesting or so.
# Note: since GuiMessageToMain is called from the RunOffThread and the Tacx2DongleThread
# we may not call self.setValues() or self.SetMessages() directly.
# ------------------------------------------------------------------
if cmd == command:
break # command is ready
elif cmd == cmd_StopButton:
pass
elif cmd == cmd_SetValues:
self.SetValues(rtn[0], rtn[1], rtn[2], rtn[3], rtn[4], rtn[5], rtn[6], rtn[7], rtn[8], rtn[9], rtn[10])# rtn is tuple
wx.CallAfter(self.SetValues, rtn[0], rtn[1], rtn[2], rtn[3], rtn[4], rtn[5], rtn[6], rtn[7], rtn[8], rtn[9], rtn[10])# rtn is tuple
elif cmd == cmd_SetMessages:
self.SetMessages(rtn[0], rtn[1], rtn[2])# rtn is (Tacx, Dongle, HRM) tuple
wx.CallAfter(self.SetMessages, rtn[0], rtn[1], rtn[2])# rtn is (Tacx, Dongle, HRM) tuple
elif cmd == cmd_PedalStrokeAnalysis:
self.PedalStrokeAnalysis(rtn[0], rtn[1])# rtn is (info, Cadence) tuple
pass
Expand Down Expand Up @@ -648,4 +650,4 @@ def mainProgram():
RestartApplication = False
while True:
mainProgram()
if not RestartApplication: break
if not RestartApplication: break
13 changes: 7 additions & 6 deletions pythoncode/FortiusAntGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,9 +813,9 @@ def SetValues(self, fSpeed, iRevs, iPower, iTargetMode, iTargetPower, fTargetGra
if delta >= 1: # Refresh once per second
self.LastFields = time.time() # Time in seconds

self.Speed.SetSpeedValue(float(min(max(0, fSpeed), self.SpeedMax)))
self.Revs.SetSpeedValue (float(min(max(0, iRevs), self.RevsMax )))
self.Power.SetSpeedValue(float(min(max(0, iPowerMean), self.PowerMax)))
wx.CallAfter(self.Speed.SetSpeedValue, float(min(max(0, fSpeed), self.SpeedMax)))
wx.CallAfter(self.Revs.SetSpeedValue, float(min(max(0, iRevs), self.RevsMax )))
wx.CallAfter(self.Power.SetSpeedValue, float(min(max(0, iPowerMean), self.PowerMax)))

if True:
# Alternating suffix makes the texts being refreshed
Expand Down Expand Up @@ -1193,9 +1193,10 @@ def OnClick_btnRunoff_Thread(self):
self.callRunoff()
self.OnTimerEnabled = True
self.RunningSwitch = False # Just to be sure
self.OnClick_btnStop() # Thread may stop for any reason
wx.CallAfter(self.OnClick_btnStop) # Thread may stop for any reason
# Do GUI actions to enable the
# correct buttons.
# And do it via wx.CallAfter since we are not the GUI thread.

if self.CloseButtonPressed == True:
self.CloseButtonPressed = False # Otherwise self.Close() is blocked
Expand Down Expand Up @@ -1233,10 +1234,10 @@ def OnClick_btnStart_Thread(self):
self.callTacx2Dongle()
self.OnTimerEnabled= True
self.RunningSwitch = False # Just to be sure
self.OnClick_btnStop() # Thread may stop for any reason
wx.CallAfter(self.OnClick_btnStop) # Thread may stop for any reason
# Do GUI actions to enable the
# correct buttons.

# And do it via wx.CallLater since we our not the GUI thread.
if self.CloseButtonPressed == True:
self.CloseButtonPressed = False # Otherwise self.Close() is blocked
self.Close()
Expand Down