Commit be23687a authored by Alberto Vicente's avatar Alberto Vicente

Fixed text and changed name of properties.

parent 7fd14ec7
......@@ -3,7 +3,7 @@
A simple utility to configure Logitech steering wheels for Linux. Currently in alpha status so it can have bugs and
limited functionality.
##Dependencies
## Dependencies
pyLinuxWheel needs python 3 and the following packages: python-gi python-gi-cairo python3-gi python3-gi-cairo
gir1.2-gtk-3.0 to be executed.
......@@ -23,6 +23,6 @@ Only this following models are supported
Logitech models: G25, G27, G29, Driving Force GT
Applications blocks changes in "Unsupported models" this method is a desired behaviour to avoid bad changes in
Application blocks changes in "Unsupported models" this method is a desired behaviour to avoid bad changes in
the driver
......@@ -12,10 +12,10 @@ class WheelService:
def __init__(self):
self.name_wheel = "Unsupported Wheel"
self.id = "-1"
self.current_grades = 1
self.current_degrees = 1
self.supported_wheel = False
self.max_grades = -1
self.min_grades = -1
self.max_degrees = -1
self.min_degrees = -1
self.driver_path = '/sys/bus/hid/drivers/logitech'
self.model_wheels_supported = ['DFGT','G25','G27','G29']
......@@ -30,21 +30,21 @@ class WheelService:
self.name_wheel = device_id.readline()
self.id = self.name_wheel
with open(self.driver_path + '/' + device_dir + '/' + 'range', 'r') as device_range:
self.current_grades = int(device_range.readline())
self.current_degrees = int(device_range.readline())
for model in self.model_wheels_supported:
if model in self.id:
self.supported_wheel = True
self.max_grades = 900
self.min_grades = 40
self.max_degrees = 900
self.min_degrees = 40
except Exception:
print('Error reading drivers properties ')
def write_driver_grades(self):
def write_driver_degrees(self):
try:
grades = int(self.current_grades)
if not self.min_grades - 1 < grades < self.max_grades + 1:
degrees = int(self.current_degrees)
if not self.min_degrees - 1 < degrees < self.max_degrees + 1:
raise ValueError(
'Error, Valid range is between ' + str(self.min_grades) + ' and ' + str(self.max_grades))
'Error, Valid range is between ' + str(self.min_degrees) + ' and ' + str(self.max_degrees))
else:
if self.supported_wheel:
id_wheel_root = next(os.walk(self.driver_path))
......@@ -53,13 +53,13 @@ class WheelService:
device_files = next(os.walk(self.driver_path + '/' + device_dir))
if 'range' in device_files[2]:
with open(self.driver_path + '/' + device_dir + '/' + 'range', 'w') as device_range:
device_range.write(str(grades))
device_range.write(str(degrees))
else:
raise ValueError('Unknow value, it is not a supported wheel')
except ValueError as verror:
print(verror)
except Exception as error:
print('Error writing drivers grades')
print('Error writing drivers degrees')
class MainUIHandler:
......@@ -74,11 +74,11 @@ class MainUIHandler:
Gtk.main_quit()
def onSavePressed(self, button):
print(self.wheel_service.current_grades)
self.wheel_service.write_driver_grades()
print(self.wheel_service.current_degrees)
self.wheel_service.write_driver_degrees()
def scaleMoved(self, scale):
self.wheel_service.current_grades = scale.get_value()
self.wheel_service.current_degrees = scale.get_value()
class MainUI:
......@@ -90,9 +90,9 @@ class MainUI:
self.glade_file = "data/glade_files/mainui.glade"
self.main_ui_handler = MainUIHandler(self.wheel_service)
def add_marks(self, scale, mark_current, list_grades):
set_grades = set(list_grades)
for grade in set_grades:
def add_marks(self, scale, mark_current, list_degrees):
set_degrees = set(list_degrees)
for grade in set_degrees:
scale.add_mark(grade, Gtk.PositionType.TOP,str(grade))
def load_window(self):
......@@ -102,11 +102,11 @@ class MainUI:
scale_range = self.builder.get_object("scale_range")
self.builder.get_object("save_button").set_sensitive(self.wheel_service.supported_wheel)
scale_range.set_sensitive(self.wheel_service.supported_wheel)
scale_range.set_value(self.wheel_service.current_grades)
scale_range.set_range(self.wheel_service.min_grades, self.wheel_service.max_grades)
scale_range.set_value(self.wheel_service.current_degrees)
scale_range.set_range(self.wheel_service.min_degrees, self.wheel_service.max_degrees)
if self.wheel_service.supported_wheel:
list_grades = [self.wheel_service.current_grades,self.wheel_service.min_grades, self.wheel_service.max_grades, 240, 360, 540, 720]
self.add_marks(scale_range, self.wheel_service.current_grades, list_grades)
list_degrees = [self.wheel_service.current_degrees,self.wheel_service.min_degrees, self.wheel_service.max_degrees, 240, 360, 540, 720]
self.add_marks(scale_range, self.wheel_service.current_degrees, list_degrees)
self.builder.connect_signals(self.main_ui_handler)
self.window = self.builder.get_object("main_window")
self.window.connect('destroy', Gtk.main_quit)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment