diff --git a/ev3/ev3dev.py b/ev3/ev3dev.py index 19544bc..34fc177 100755 --- a/ev3/ev3dev.py +++ b/ev3/ev3dev.py @@ -104,30 +104,7 @@ def fset(self, value): return cls - -class Ev3Dev(object): - - def __init__(self): - self.sys_path = "" - - def read_value(self, name): - attr_file = os.path.join(self.sys_path, name) - if os.path.isfile(attr_file): - with open(attr_file) as f: - value = f.read().strip() - return value - else: - return None - - def write_value(self, name, value): - attr_file = os.path.join(self.sys_path, name) - if os.path.isfile(attr_file): - with open(attr_file, 'w') as f: - f.write(str(value)) - else: - return - - def get_battery_percentage(self): +def get_battery_percentage(): """ Return an int() of the percentage of battery life remaining """ @@ -181,6 +158,30 @@ def get_battery_percentage(self): (voltage_max, voltage_min, voltage_now)) return 0 +class Ev3Dev(object): + + def __init__(self): + self.sys_path = "" + + def read_value(self, name): + attr_file = os.path.join(self.sys_path, name) + if os.path.isfile(attr_file): + with open(attr_file) as f: + value = f.read().strip() + return value + else: + return None + + def write_value(self, name, value): + attr_file = os.path.join(self.sys_path, name) + if os.path.isfile(attr_file): + with open(attr_file, 'w') as f: + f.write(str(value)) + else: + return + + + @create_ev3_property( bin_data={'read_only': True}, bin_data_format={'read_only': True}, diff --git a/setup.py b/setup.py index 73c4a9b..f00e4a8 100755 --- a/setup.py +++ b/setup.py @@ -3,12 +3,12 @@ from setuptools import setup setup(name='python-ev3', - version='0.0.2.2', + version='0.0.2.3', license='Apache License 2.0', description='Python library of ev3dev firmware', author='Gong Yi', author_email='topikachu@163.com', url='https://github.com/topikachu/python-ev3', packages=['ev3'], - download_url="https://github.com/topikachu/python-ev3/releases/tag/0.0.2.2" + download_url="https://github.com/topikachu/python-ev3/releases/tag/0.0.2.3" )