Skip to content

Commit 8e10645

Browse files
authored
Issue#340 #342 #353 (#354)
* issues #340 #342 #355 implemented * +exec
1 parent 5794e75 commit 8e10645

9 files changed

+97
-66
lines changed

Development/FortiusANT CreateWindowsExecutable.bat

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
@echo pyinstaller is documented: https://pyinstaller.readthedocs.io/en/stable/
2+
@echo the .exe is "unpacked" into C:\Users\%username%\AppData\Local\Temp
3+
14
cd ..\pythoncode
25
del dist\FortiusANT.exe
36
pyinstaller --clean MakeFortiusANT.spec

StartUp/ExplorAnt (simulate).bat

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
..\pythoncode\ExplorAnt.py -d127 -s -H12345
2+
pause

WindowsExecutable/FortiusANT.exe

347 Bytes
Binary file not shown.

pythoncode/FortiusAntCommand.py

+52-47
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#-------------------------------------------------------------------------------
22
# Version info
33
#-------------------------------------------------------------------------------
4-
__version__ = "2021-04-13"
4+
__version__ = "2021-12-02"
5+
# 2021-12-02 default command line value for HRM was False, changed to None
6+
# HRM=0 has another meaning than "HRM not specified"
7+
# same applied to all other integer command-line variables
58
# 2021-04-13 added: mph
69
# 2021-04-13 If AntRequired and self.antDeviceID == -1, a message is given
710
# 2021-03-24 changed: command line help + validation
@@ -205,20 +208,20 @@ def __init__(self):
205208
parser.add_argument('-b', dest='ble', help=constants.help_b, required=False, action='store_true')
206209
else:
207210
pass # If -b is requested but not available, then an error is appropriate
208-
parser.add_argument ('-B', dest='DeviceNumberBase', metavar='0...65535', help=constants.help_B, required=False, default=False, type=int)
209-
parser.add_argument ('-c', dest='CalibrateRR', metavar='0...100', help=constants.help_c, required=False, default=False, type=int)
211+
parser.add_argument ('-B', dest='DeviceNumberBase', metavar='0...65535', help=constants.help_B, required=False, default=None, type=int)
212+
parser.add_argument ('-c', dest='CalibrateRR', metavar='0...100', help=constants.help_c, required=False, default=None, type=int)
210213
# parser.add_argument ('-C', dest='CtrlCommand', metavar='ANT+DeviceID', help=constants.help_C, required=False, default=False, type=int)
211214
parser.add_argument ('-C', dest='CtrlCommand', metavar='ANT+DeviceID', help=argparse.SUPPRESS, required=False, default=False, type=int)
212-
parser.add_argument ('-d', dest='debug', metavar='0...255', help=constants.help_d, required=False, default=False, type=int)
213-
parser.add_argument ('-D', dest='antDeviceID', metavar='USB-DeviceID', help=constants.help_D, required=False, default=False, type=int)
215+
parser.add_argument ('-d', dest='debug', metavar='0...255', help=constants.help_d, required=False, default=None, type=int)
216+
parser.add_argument ('-D', dest='antDeviceID', metavar='USB-DeviceID', help=constants.help_D, required=False, default=None, type=int)
214217
parser.add_argument ('-e', dest='homeTrainer', help=constants.help_e, required=False, action='store_true')
215218
# -h help!!
216219
if UseGui:
217220
parser.add_argument('-g', dest='gui', help=constants.help_g, required=False, action='store_true')
218221
else:
219222
parser.add_argument('-g', dest='g_IgnoredIfDefined', help=argparse.SUPPRESS, required=False, action='store_true')
220223
parser.add_argument ('-G', dest='GradeAdjust', metavar='% / % / %', help=constants.help_G, required=False, default=False)
221-
parser.add_argument ('-H', dest='hrm', metavar='ANT+DeviceID', help=constants.help_H, required=False, default=False, type=int)
224+
parser.add_argument ('-H', dest='hrm', metavar='ANT+DeviceID', help=constants.help_H, required=False, default=None, type=int)
222225
parser.add_argument ('-i', dest='imperial', help=constants.help_i, required=False, action='store_true')
223226
if UseGui or OnRaspberry:
224227
parser.add_argument('-l', dest='StatusLeds', help=constants.help_l, required=False, action='store_true')
@@ -235,12 +238,12 @@ def __init__(self):
235238
parser.add_argument('-O', dest='OutputDisplay', metavar='see text', help=constants.help_O, required=False, default=False)
236239
else:
237240
parser.add_argument('-O', dest='O_IgnoredIfDefined', help=argparse.SUPPRESS, required=False, default=False)
238-
parser.add_argument ('-p', dest='factor', metavar='%', help=constants.help_p, required=False, default=False, type=int)
241+
parser.add_argument ('-p', dest='factor', metavar='%', help=constants.help_p, required=False, default=None, type=int)
239242
parser.add_argument ('-P', dest='PowerMode', help=constants.help_P, required=False, action='store_true')
240243
parser.add_argument ('-r', dest='Resistance', help=constants.help_r, required=False, action='store_true')
241244
parser.add_argument ('-R', dest='Runoff', metavar='see text', help=constants.help_R, required=False, default=False)
242245
parser.add_argument ('-s', dest='simulate', help=constants.help_s, required=False, action='store_true')
243-
#scs parser.add_argument ('-S', dest='scs', metavar='ANT+ DeviceID',help=constants.help_S, required=False, default=False, type=int)
246+
#scs parser.add_argument ('-S', dest='scs', metavar='ANT+ DeviceID',help=constants.help_S, required=False, default=None, type=int)
244247
parser.add_argument ('-T', dest='Transmission', metavar='see text', help=constants.help_T, required=False, default=False)
245248
self.ant_tacx_models = ['Bushido', 'Genius', 'Vortex', 'Magneticbrake', 'Motorbrake']
246249
parser.add_argument ('-t', dest='TacxType', help=constants.help_t, required=False, default=False, \
@@ -331,7 +334,7 @@ def __init__(self):
331334
#-----------------------------------------------------------------------
332335
# Get DeviceNumberBase
333336
#-----------------------------------------------------------------------
334-
if self.args.DeviceNumberBase:
337+
if self.args.DeviceNumberBase != None:
335338
try:
336339
self.DeviceNumberBase = int(self.args.DeviceNumberBase)
337340
except:
@@ -342,7 +345,7 @@ def __init__(self):
342345
# Not limitted to a range here, because can be different for different
343346
# types of brakes, although initially only used for Magnetic Brake
344347
#-----------------------------------------------------------------------
345-
if self.args.CalibrateRR:
348+
if self.args.CalibrateRR != None:
346349
try:
347350
self.CalibrateRR = float(self.args.CalibrateRR.replace(',', '.'))
348351
except:
@@ -434,7 +437,7 @@ def __init__(self):
434437
#-----------------------------------------------------------------------
435438
# Get debug-flags, used in debug module
436439
#-----------------------------------------------------------------------
437-
if self.args.debug:
440+
if self.args.debug != None:
438441
try:
439442
self.debug = int(self.args.debug)
440443
except:
@@ -443,7 +446,7 @@ def __init__(self):
443446
#-----------------------------------------------------------------------
444447
# Get antDeviceID
445448
#-----------------------------------------------------------------------
446-
if self.args.antDeviceID:
449+
if self.args.antDeviceID != None:
447450
try:
448451
self.antDeviceID = int(self.args.antDeviceID)
449452
except:
@@ -457,7 +460,10 @@ def __init__(self):
457460
# - next: pair with the defined ANT+ HRM monitor
458461
# the number can be found with ExplorANT
459462
#-----------------------------------------------------------------------
460-
if self.args.hrm:
463+
# 2021-12-02 False==0 and therefore False is a bad default if zero is
464+
# a valid value. Therefore default changed to None
465+
#-----------------------------------------------------------------------
466+
if self.args.hrm != None:
461467
try:
462468
self.hrm = int(self.args.hrm)
463469
except:
@@ -470,7 +476,7 @@ def __init__(self):
470476
# - next: pair with the defined ANT+ SCS
471477
# the number can be found with ExplorANT
472478
#-----------------------------------------------------------------------
473-
#scs if self.args.scs:
479+
#scs if self.args.scs != None:
474480
#scs try:
475481
#scs self.scs = int(self.args.scs)
476482
#scs except:
@@ -479,7 +485,7 @@ def __init__(self):
479485
#-----------------------------------------------------------------------
480486
# Get powerfactor
481487
#-----------------------------------------------------------------------
482-
if self.args.factor:
488+
if self.args.factor != None:
483489
try:
484490
self.PowerFactor = int(self.args.factor) / 100
485491
# I would expect +/- 15% would be enough for compensation, but
@@ -650,48 +656,47 @@ def __init__(self):
650656
def print(self):
651657
try:
652658
v = self.debug # Verbose: print all command-line variables with values
653-
if self.autostart: logfile.Console("-a")
654-
if self.PedalStrokeAnalysis:logfile.Console("-A")
655-
if self.ble: logfile.Console("-b")
656-
if v or self.args.DeviceNumberBase: logfile.Console("-B %s" % self.DeviceNumberBase )
657-
if v or self.args.CalibrateRR: logfile.Console("-c %s" % self.CalibrateRR )
659+
if self.autostart: logfile.Console("-a")
660+
if self.PedalStrokeAnalysis: logfile.Console("-A")
661+
if self.ble: logfile.Console("-b")
662+
if v or self.args.DeviceNumberBase != None: logfile.Console("-B %s" % self.DeviceNumberBase )
663+
if v or self.args.CalibrateRR != None: logfile.Console("-c %s" % self.CalibrateRR )
658664
if v or self.CTRL_SerialL or self.CTRL_SerialR:
659665
logfile.Console("-C %s/%s" % (self.CTRL_SerialL, self.CTRL_SerialR ) )
660-
if v or self.args.debug: logfile.Console("-d %s (%s)" % (self.debug, bin(self.debug) ) )
661-
if v or self.args.antDeviceID: logfile.Console("-D %s" % self.antDeviceID )
666+
if v or self.args.debug != None: logfile.Console("-d %s (%s)" % (self.debug, bin(self.debug) ) )
667+
if v or self.args.antDeviceID != None: logfile.Console("-D %s" % self.antDeviceID )
662668
if v or self.args.GradeAdjust:
663-
if self.GradeAdjust == 1: logfile.Console("-G defines Grade = antGrade * %s" \
664-
% (self.GradeFactor ) )
665-
if self.GradeAdjust == 2: logfile.Console("-G defines Grade = antGrade * %s [* %s (downhill)]" \
666-
% (self.GradeFactor, self.GradeFactorDH) )
667-
if self.GradeAdjust == 3: logfile.Console("-G defines Grade = (antGrade - %s) * %s [* %s (downhill)]" \
668-
% (self.GradeShift, self.GradeFactor, self.GradeFactorDH) )
669-
if self.gui: logfile.Console("-g")
670-
if self.homeTrainer: logfile.Console("-e")
671-
if v or self.args.hrm: logfile.Console("-H %s" % self.hrm )
672-
if self.StatusLeds: logfile.Console("-l")
669+
if self.GradeAdjust == 1: logfile.Console("-G defines Grade = antGrade * %s" \
670+
% (self.GradeFactor ) )
671+
if self.GradeAdjust == 2: logfile.Console("-G defines Grade = antGrade * %s [* %s (downhill)]" \
672+
% (self.GradeFactor, self.GradeFactorDH) )
673+
if self.GradeAdjust == 3: logfile.Console("-G defines Grade = (antGrade - %s) * %s [* %s (downhill)]" \
674+
% (self.GradeShift, self.GradeFactor, self.GradeFactorDH) )
675+
if self.gui: logfile.Console("-g")
676+
if self.homeTrainer: logfile.Console("-e")
677+
if v or self.args.hrm != None: logfile.Console("-H %s" % self.hrm )
678+
if self.StatusLeds: logfile.Console("-l")
673679
if OnRaspberry and (v or self.args.gpioLayout):
674680
logfile.Console("-L %s/%s/%s/%s/%s/%s" % (self.rpiButton, self.rpiTacx, self.rpiShutdown, self.rpiCadence, self.rpiBLE, self.rpiANT) )
675-
if self.manual: logfile.Console("-m")
676-
if self.manualGrade: logfile.Console("-M")
677-
if self.imperial: logfile.Console("-i")
678-
if not self.args.calibrate: logfile.Console("-n")
679-
if v or self.args.factor: logfile.Console("-p %s" % self.PowerFactor )
680-
if v or self.args.OutputDisplay: logfile.Console("-O %s" % self.OutputDisplay)
681-
if self.args.PowerMode: logfile.Console("-P")
682-
if self.args.Resistance: logfile.Console("-r")
683-
if v or self.args.Runoff: logfile.Console("-R defines Runoff: maxSpeed=%s dip=%s minSpeed=%s targetTime=%s power=%s" % \
681+
if self.manual: logfile.Console("-m")
682+
if self.manualGrade: logfile.Console("-M")
683+
if self.imperial: logfile.Console("-i")
684+
if not self.args.calibrate: logfile.Console("-n")
685+
if v or self.args.factor != None: logfile.Console("-p %s" % self.PowerFactor )
686+
if v or self.args.OutputDisplay: logfile.Console("-O %s" % self.OutputDisplay)
687+
if self.args.PowerMode: logfile.Console("-P")
688+
if self.args.Resistance: logfile.Console("-r")
689+
if v or self.args.Runoff: logfile.Console("-R defines Runoff: maxSpeed=%s dip=%s minSpeed=%s targetTime=%s power=%s" % \
684690
(self.RunoffMaxSpeed, self.RunoffDip, self.RunoffMinSpeed, self.RunoffTime, self.RunoffPower) )
685-
if self.args.simulate: logfile.Console("-s")
686-
#scs if v or self.args.scs: logfile.Console("-S %s" % self.scs )
687-
if v or self.args.TacxType: logfile.Console("-t %s" % self.TacxType)
688-
# if v or self.args.Transmission != constants.Transmission:
691+
if self.args.simulate: logfile.Console("-s")
692+
#scs if v or self.args.scs != None: logfile.Console("-S %s" % self.scs )
693+
if v or self.args.TacxType: logfile.Console("-t %s" % self.TacxType)
689694
if v or self.args.Transmission:
690-
logfile.Console('-T %s x %s (start=%sx%s)' % \
695+
logfile.Console('-T %s x %s (start=%sx%s)' % \
691696
(self.Cranckset, self.Cassette, \
692697
self.Cranckset[self.CrancksetStart], \
693698
self.Cassette [self.CassetteStart]) )
694-
if self.exportTCX: logfile.Console("-x")
699+
if self.exportTCX: logfile.Console("-x")
695700

696701
except:
697702
pass # May occur when incorrect command line parameters, error already given before

pythoncode/FortiusAntGui.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#-------------------------------------------------------------------------------
22
# Version info
33
#-------------------------------------------------------------------------------
4-
__version__ = "2021-04-22"
4+
__version__ = "2022-01-04"
5+
# 2022-01-04 text-fields on top of other controls were flickering, because
6+
# the parent was not the on-top control #353
57
# 2021-04-22 centre() done when all controls created
68
# 2021-04-13 clv.imperial: speed in mph
79
# 2021-04-12 Status leds are fixed part of GUI, clv.StatusLeds is for Raspberry only
@@ -168,7 +170,7 @@ def __init__(self, parent, pclv):
168170
self.panel = self # Controls directly on the frame window
169171

170172
# ----------------------------------------------------------------------
171-
# Save Command Line Variables in tge GUI-context
173+
# Save Command Line Variables in the GUI-context
172174
# ----------------------------------------------------------------------
173175
self.clv = pclv
174176

@@ -503,21 +505,21 @@ def __init__(self, parent, pclv):
503505
_TextCtrlW2 = int(SpeedWH/2)
504506

505507
# ----------------------------------------------------------------------
506-
# self.Speed label & text; speed in km/h or mph
508+
# self.Speed value; speed in km/h or mph (On top of self.Speed)
507509
# ----------------------------------------------------------------------
508510
self.txtSpeed = wx.TextCtrl(self.Speed, value="99.9", size=(int(TextCtrlW * 1.2),TextCtrlH), style=wx.TE_CENTER | wx.TE_READONLY | wx.BORDER_NONE)
509511
self.txtSpeed.SetBackgroundColour(bg)
510512
self.txtSpeed.SetPosition(((self.Speed.Width - self.txtSpeed.MinWidth) / 2, self.Speed.Height - self.txtSpeed.MinHeight))
511513

512514
# ----------------------------------------------------------------------
513-
# self.Revs
515+
# self.Revs value; (On top of self.Revs)
514516
# ----------------------------------------------------------------------
515517
self.txtRevs = wx.TextCtrl(self.Revs, value="999/min", size=(int(TextCtrlW * 1.2),TextCtrlH), style=wx.TE_CENTER | wx.TE_READONLY | wx.BORDER_NONE)
516518
self.txtRevs.SetBackgroundColour(bg)
517519
self.txtRevs.SetPosition(((self.Revs.Width - self.txtRevs.MinWidth) / 2, self.Revs.Height - self.txtRevs.MinHeight))
518520

519521
# ----------------------------------------------------------------------
520-
# self.Power
522+
# self.Power values; (On top of self.Power)
521523
# ----------------------------------------------------------------------
522524
self.txtPower = wx.TextCtrl(self.Power, value="999 Watt", size=(TextCtrlW,TextCtrlH), style=wx.TE_CENTER | wx.TE_READONLY | wx.BORDER_NONE)
523525
self.txtPower.SetBackgroundColour(bg)

0 commit comments

Comments
 (0)