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

Add color enum for the led of XL-320. #66

Merged
merged 1 commit into from Apr 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions pypot/dynamixel/conversion.py
Expand Up @@ -15,6 +15,7 @@
import numpy
import itertools

from enum import Enum

# MARK: - Position

Expand Down Expand Up @@ -247,6 +248,17 @@ def alarm_to_dxl(value, model):
return sum(2 ** i for i in indices)


XL320LEDColors = Enum('Colors', 'off red green yellow '
'blue pink cyan white')

def dxl_to_led_color(value, model):
return XL320LEDColors(value + 1).name

def led_color_to_dxl(value, model):
value = getattr(XL320LEDColors, value).value - 1
value = int(value) & 0b111
return value

# MARK: - Various utility functions

def dxl_to_bool(value, model):
Expand Down
6 changes: 6 additions & 0 deletions pypot/dynamixel/io/io_320.py
Expand Up @@ -130,6 +130,12 @@ def factory_reset(self, ids, except_ids=False, except_baudrate_and_ids=False):
'setter_name': '_set_LED',
'getter_name': 'is_led_on'
},
'LED color': {
'address': 0x19,
'length': 1,
'dxl_to_si': conv.dxl_to_led_color,
'si_to_dxl': conv.led_color_to_dxl,
},
'pid gain': {
'address': 0x1B,
'length': 1,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -18,7 +18,7 @@ def version():
version=version(),
packages=find_packages(),

install_requires=['numpy', 'pyserial'],
install_requires=['numpy', 'pyserial', 'enum34'],

extras_require={
'tools': [], # Extras require: PyQt4 (not a PyPi packet)
Expand Down