Compare commits
8 Commits
main
...
8f0661a73d
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f0661a73d | |||
| df6e27783e | |||
| ac60af82a0 | |||
| f085cd8e8b | |||
| ceb2f538b8 | |||
| aa96a3b3c2 | |||
| 3f6aedffbc | |||
| c6cd1c0b99 |
@@ -1,11 +1,13 @@
|
|||||||
#please use python 3.11
|
#please use python 3.11
|
||||||
import socket
|
import socket
|
||||||
import struct
|
import struct
|
||||||
|
import tkinter.ttk
|
||||||
import serial
|
import serial
|
||||||
import time
|
import time
|
||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
import tkinter
|
||||||
from GAME_METHODS import *
|
from GAME_METHODS import *
|
||||||
|
|
||||||
##check if python 3.11 is running code and exit if not
|
##check if python 3.11 is running code and exit if not
|
||||||
@@ -13,9 +15,12 @@ from GAME_METHODS import *
|
|||||||
if not(sys.version_info[0] == 3 and sys.version_info[1] == 11):
|
if not(sys.version_info[0] == 3 and sys.version_info[1] == 11):
|
||||||
raise Exception("code must be run in python verion 3.11.\ninput struct for network needs to be changed per python version.")
|
raise Exception("code must be run in python verion 3.11.\ninput struct for network needs to be changed per python version.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##system init
|
||||||
runningOs = platform.system()
|
runningOs = platform.system()
|
||||||
|
|
||||||
UDP_IP = "0.0.0.0"
|
UDP_IP = "127.0.0.1"
|
||||||
BEAMNG_UDP_PORT = 4444
|
BEAMNG_UDP_PORT = 4444
|
||||||
FORZA_UDP_PORT= 4843
|
FORZA_UDP_PORT= 4843
|
||||||
SERIAL_PORT = ""
|
SERIAL_PORT = ""
|
||||||
@@ -58,6 +63,46 @@ else:
|
|||||||
print("OS detection failed setting serial port to 'COM5'\n")
|
print("OS detection failed setting serial port to 'COM5'\n")
|
||||||
SERIAL_PORT = 'COM5'
|
SERIAL_PORT = 'COM5'
|
||||||
|
|
||||||
|
##GUI init
|
||||||
|
rootFrameGui= tkinter.Tk()
|
||||||
|
rootFrameGui.title("Car speed to arduino")
|
||||||
|
rootFrameGui.geometry("400x200")
|
||||||
|
|
||||||
|
firstFrameGui=tkinter.ttk.Frame(rootFrameGui,padding=2,relief="groove",borderwidth=2)
|
||||||
|
firstFrameGui.pack(anchor="ne",side="left",expand=True)
|
||||||
|
secondFrameGui=tkinter.ttk.Frame(rootFrameGui,padding=2,relief="groove",borderwidth=2)
|
||||||
|
secondFrameGui.pack(anchor="nw",side="right",expand=True)
|
||||||
|
serialFrameGui = tkinter.ttk.Frame(firstFrameGui,padding=5,relief="groove",borderwidth=2)
|
||||||
|
serialFrameGui.pack(anchor="nw")
|
||||||
|
serialLableText =tkinter.StringVar()
|
||||||
|
serialLableText.set("Serial Port:")
|
||||||
|
serialLable = tkinter.Label(serialFrameGui,textvariable=serialLableText)
|
||||||
|
serialLable.pack(side="top")
|
||||||
|
serialEntry=tkinter.Entry(serialFrameGui)
|
||||||
|
serialEntry.insert(0,SERIAL_PORT)
|
||||||
|
serialEntry.pack(side="left")
|
||||||
|
tkGametype = tkinter.StringVar()
|
||||||
|
tkGametype.set(GameType.BEAMNG.value)
|
||||||
|
gameSelectFrame= tkinter.ttk.Frame(secondFrameGui,padding=5,relief="groove",borderwidth=2)
|
||||||
|
gameSelectFrame.pack(anchor="se")
|
||||||
|
gameSelectText= tkinter.StringVar()
|
||||||
|
gameSelectText.set("Select Game:")
|
||||||
|
gameSelectLable = tkinter.Label(gameSelectFrame,textvariable=gameSelectText)
|
||||||
|
gameSelectLable.pack(side="top")
|
||||||
|
tkinter.Label(gameSelectFrame,textvariable=gameSelectText)
|
||||||
|
gameSelectLOptions= [GameType.BEAMNG,GameType.FORZA]
|
||||||
|
##gameSelectRadioButtons
|
||||||
|
##space after text is so the buttons are the same size
|
||||||
|
tkinter.Radiobutton(gameSelectFrame,text="BeamNG ",variable=tkGametype,value=GameType.BEAMNG.value).pack(anchor="w")
|
||||||
|
tkinter.Radiobutton(gameSelectFrame,text="Forza ",variable=tkGametype,value=GameType.FORZA.value).pack(anchor="w")
|
||||||
|
loggingFrameGui= tkinter.ttk.Frame(firstFrameGui,padding=5,relief="groove",borderwidth=2)
|
||||||
|
loggingFrameGui.pack(anchor="nw")
|
||||||
|
tkLoggingEnabled=tkinter.BooleanVar()
|
||||||
|
tkLoggingEnabled.set(False)
|
||||||
|
tkinter.Checkbutton(loggingFrameGui,text="Enable Logging",variable=tkLoggingEnabled,onvalue=True,offvalue=False).pack(side="bottom")
|
||||||
|
|
||||||
|
rootFrameGui.mainloop()
|
||||||
|
##exit() #### exit for testing
|
||||||
#select game
|
#select game
|
||||||
while gameSelected == False:
|
while gameSelected == False:
|
||||||
gameNo = input("1:BEAMNG\n2:FORZA\n\n7:Toggle CSV out ("+str(csvOut)+")\n9:SET SERIAL PORT ("+SERIAL_PORT+")\n")
|
gameNo = input("1:BEAMNG\n2:FORZA\n\n7:Toggle CSV out ("+str(csvOut)+")\n9:SET SERIAL PORT ("+SERIAL_PORT+")\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user