Skip to content

Commit 3a8bd61

Browse files
committed
Merge pull request #164 from rhempel/feature-support-new-11-kernel
Feature support new 11 kernel
2 parents 539123b + 4f289b8 commit 3a8bd61

File tree

6 files changed

+48
-89
lines changed

6 files changed

+48
-89
lines changed

ev3dev-lang

ev3dev/brickpi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class Leds(object):
5353
LED1 = ( blue_led1, )
5454
LED2 = ( blue_led2, )
5555

56+
BLACK = ( 0, )
5657
BLUE = ( 1, )
5758

5859
@staticmethod

ev3dev/core.py

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# -----------------------------------------------------------------------------
2525

2626
# ~autogen autogen-header
27-
# Sections of the following code were auto-generated based on spec v1.1.0
27+
# Sections of the following code were auto-generated based on spec v1.2.0
2828

2929
# ~autogen
3030

@@ -269,7 +269,6 @@ def __init__(self, address=None, name_pattern=SYSTEM_DEVICE_NAME_CONVENTION, nam
269269
self._driver_name = None
270270
self._duty_cycle = None
271271
self._duty_cycle_sp = None
272-
self._encoder_polarity = None
273272
self._full_travel_count = None
274273
self._polarity = None
275274
self._position = None
@@ -286,8 +285,8 @@ def __init__(self, address=None, name_pattern=SYSTEM_DEVICE_NAME_CONVENTION, nam
286285
self._speed_i = None
287286
self._speed_d = None
288287
self._state = None
289-
self._stop_command = None
290-
self._stop_commands = None
288+
self._stop_action = None
289+
self._stop_actions = None
291290
self._time_sp = None
292291

293292
# ~autogen
@@ -391,22 +390,6 @@ def duty_cycle_sp(self):
391390
def duty_cycle_sp(self, value):
392391
self._duty_cycle_sp = self.set_attr_int(self._duty_cycle_sp, 'duty_cycle_sp', value)
393392

394-
@property
395-
def encoder_polarity(self):
396-
"""
397-
Sets the polarity of the rotary encoder. This is an advanced feature to all
398-
use of motors that send inversed encoder signals to the EV3. This should
399-
be set correctly by the driver of a device. It You only need to change this
400-
value if you are using a unsupported device. Valid values are `normal` and
401-
`inversed`.
402-
"""
403-
self._encoder_polarity, value = self.get_attr_string(self._encoder_polarity, 'encoder_polarity')
404-
return value
405-
406-
@encoder_polarity.setter
407-
def encoder_polarity(self, value):
408-
self._encoder_polarity = self.set_attr_string(self._encoder_polarity, 'encoder_polarity', value)
409-
410393
@property
411394
def full_travel_count(self):
412395
"""
@@ -613,35 +596,35 @@ def state(self):
613596
return value
614597

615598
@property
616-
def stop_command(self):
599+
def stop_action(self):
617600
"""
618-
Reading returns the current stop command. Writing sets the stop command.
601+
Reading returns the current stop action. Writing sets the stop action.
619602
The value determines the motors behavior when `command` is set to `stop`.
620603
Also, it determines the motors behavior when a run command completes. See
621-
`stop_commands` for a list of possible values.
604+
`stop_actions` for a list of possible values.
622605
"""
623-
self._stop_command, value = self.get_attr_string(self._stop_command, 'stop_command')
606+
self._stop_action, value = self.get_attr_string(self._stop_action, 'stop_action')
624607
return value
625608

626-
@stop_command.setter
627-
def stop_command(self, value):
628-
self._stop_command = self.set_attr_string(self._stop_command, 'stop_command', value)
609+
@stop_action.setter
610+
def stop_action(self, value):
611+
self._stop_action = self.set_attr_string(self._stop_action, 'stop_action', value)
629612

630613
@property
631-
def stop_commands(self):
614+
def stop_actions(self):
632615
"""
633-
Returns a list of stop modes supported by the motor controller.
616+
Returns a list of stop actions supported by the motor controller.
634617
Possible values are `coast`, `brake` and `hold`. `coast` means that power will
635618
be removed from the motor and it will freely coast to a stop. `brake` means
636619
that power will be removed from the motor and a passive electrical load will
637620
be placed on the motor. This is usually done by shorting the motor terminals
638621
together. This load will absorb the energy from the rotation of the motors and
639622
cause the motor to stop more quickly than coasting. `hold` does not remove
640-
power from the motor. Instead it actively try to hold the motor at the current
623+
power from the motor. Instead it actively tries to hold the motor at the current
641624
position. If an external force tries to turn the motor, the motor will 'push
642625
back' to maintain its position.
643626
"""
644-
self._stop_commands, value = self.get_attr_set(self._stop_commands, 'stop_commands')
627+
self._stop_actions, value = self.get_attr_set(self._stop_actions, 'stop_actions')
645628
return value
646629

647630
@property
@@ -814,7 +797,7 @@ class LargeMotor(Motor):
814797
"""
815798

816799
SYSTEM_CLASS_NAME = Motor.SYSTEM_CLASS_NAME
817-
SYSTEM_DEVICE_NAME_CONVENTION = 'motor*'
800+
SYSTEM_DEVICE_NAME_CONVENTION = '*'
818801

819802
def __init__(self, address=None, name_pattern=SYSTEM_DEVICE_NAME_CONVENTION, name_exact=False, **kwargs):
820803

@@ -831,7 +814,7 @@ class MediumMotor(Motor):
831814
"""
832815

833816
SYSTEM_CLASS_NAME = Motor.SYSTEM_CLASS_NAME
834-
SYSTEM_DEVICE_NAME_CONVENTION = 'motor*'
817+
SYSTEM_DEVICE_NAME_CONVENTION = '*'
835818

836819
def __init__(self, address=None, name_pattern=SYSTEM_DEVICE_NAME_CONVENTION, name_exact=False, **kwargs):
837820

@@ -848,7 +831,7 @@ class NxtMotor(Motor):
848831
"""
849832

850833
SYSTEM_CLASS_NAME = Motor.SYSTEM_CLASS_NAME
851-
SYSTEM_DEVICE_NAME_CONVENTION = 'motor*'
834+
SYSTEM_DEVICE_NAME_CONVENTION = '*'
852835

853836
def __init__(self, address=None, name_pattern=SYSTEM_DEVICE_NAME_CONVENTION, name_exact=False, **kwargs):
854837

ev3dev/ev3.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ class Leds(object):
5555
LEFT = ( red_left, green_left, )
5656
RIGHT = ( red_right, green_right, )
5757

58+
BLACK = ( 0, 0, )
5859
RED = ( 1, 0, )
5960
GREEN = ( 0, 1, )
6061
AMBER = ( 1, 1, )
6162
ORANGE = ( 1, 0.5, )
62-
YELLOW = ( 0.5, 1, )
63+
YELLOW = ( 0.1, 1, )
6364

6465
@staticmethod
6566
def set_color(group, color, pct=1):

spec_version.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# ~autogen spec_version
2-
spec_version = "1.1.0"
2+
spec_version = "1.2.0"
33
kernel_versions = {
4-
"10-ev3dev"
5-
"10-rc1-ev3dev"
4+
"11-ev3dev"
5+
"11-rc1-ev3dev"
66
}
77

88
# ~autogen

tests/motor/motor_param_unittest.py

Lines changed: 24 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -118,31 +118,6 @@ def test_duty_cycle_sp_after_reset(self):
118118
self._param['motor'].command = 'reset'
119119
self.assertEqual(self._param['motor'].duty_cycle_sp, 0)
120120

121-
class TestTachoMotorEncoderPolarityValue(ptc.ParameterizedTestCase):
122-
123-
def test_encoder_polarity_normal_value(self):
124-
self._param['motor'].encoder_polarity = 'normal'
125-
self.assertEqual(self._param['motor'].encoder_polarity, 'normal')
126-
127-
def test_encoder_polarity_inversed_value(self):
128-
self._param['motor'].encoder_polarity = 'inversed'
129-
self.assertEqual(self._param['motor'].encoder_polarity, 'inversed')
130-
131-
def test_encoder_polarity_illegal_value(self):
132-
with self.assertRaises(IOError):
133-
self._param['motor'].encoder_polarity = "ThisShouldNotWork"
134-
135-
def test_encoder_polarity_after_reset(self):
136-
if ('normal' == motor_info[self._param['motor'].driver_name]['encoder_polarity']):
137-
self._param['motor'].encoder_polarity = 'inversed'
138-
else:
139-
self._param['motor'].encoder_polarity = 'normal'
140-
self._param['motor'].command = 'reset'
141-
if ('normal' == motor_info[self._param['motor'].driver_name]['encoder_polarity']):
142-
self.assertEqual(self._param['motor'].encoder_polarity, 'normal')
143-
else:
144-
self.assertEqual(self._param['motor'].encoder_polarity, 'inversed')
145-
146121
class TestTachoMotorMaxSpeedValue(ptc.ParameterizedTestCase):
147122

148123
def test_max_speed_value(self):
@@ -459,39 +434,39 @@ def test_state_value_after_reset(self):
459434
self._param['motor'].command = 'reset'
460435
self.assertEqual(self._param['motor'].state, [])
461436

462-
class TestTachoMotorStopCommandValue(ptc.ParameterizedTestCase):
437+
class TestTachoMotorStopActionValue(ptc.ParameterizedTestCase):
463438

464-
def test_stop_command_illegal(self):
439+
def test_stop_action_illegal(self):
465440
with self.assertRaises(IOError):
466-
self._param['motor'].stop_command = 'ThisShouldNotWork'
441+
self._param['motor'].stop_action = 'ThisShouldNotWork'
467442

468-
def test_stop_command_coast(self):
469-
self._param['motor'].stop_command = 'coast'
470-
self.assertEqual(self._param['motor'].stop_command, 'coast')
443+
def test_stop_action_coast(self):
444+
self._param['motor'].stop_action = 'coast'
445+
self.assertEqual(self._param['motor'].stop_action, 'coast')
471446

472-
def test_stop_command_brake(self):
473-
self._param['motor'].stop_command = 'brake'
474-
self.assertEqual(self._param['motor'].stop_command, 'brake')
447+
def test_stop_action_brake(self):
448+
self._param['motor'].stop_action = 'brake'
449+
self.assertEqual(self._param['motor'].stop_action, 'brake')
475450

476-
def test_stop_command_hold(self):
477-
self._param['motor'].stop_command = 'hold'
478-
self.assertEqual(self._param['motor'].stop_command, 'hold')
451+
def test_stop_action_hold(self):
452+
self._param['motor'].stop_action = 'hold'
453+
self.assertEqual(self._param['motor'].stop_action, 'hold')
479454

480-
def test_time_sp_after_reset(self):
481-
self._param['motor'].stop_command = 'hold'
455+
def test_stop_action_after_reset(self):
456+
self._param['motor'].stop_action = 'hold'
482457
self._param['motor'].command = 'reset'
483-
self.assertEqual(self._param['motor'].stop_command, 'coast')
458+
self.assertEqual(self._param['motor'].stop_action, 'coast')
484459

485-
class TestTachoMotorStopCommandsValue(ptc.ParameterizedTestCase):
460+
class TestTachoMotorStopActionsValue(ptc.ParameterizedTestCase):
486461

487-
def test_stop_commands_value(self):
488-
self.assertTrue(set(self._param['motor'].stop_commands) == {'coast'
489-
,'brake'
490-
,'hold'})
462+
def test_stop_actions_value(self):
463+
self.assertTrue(set(self._param['motor'].stop_actions) == {'coast'
464+
,'brake'
465+
,'hold'})
491466

492-
def test_stop_commands_value_is_read_only(self):
467+
def test_stop_actions_value_is_read_only(self):
493468
with self.assertRaises(AttributeError):
494-
self._param['motor'].stop_commands = "ThisShouldNotWork"
469+
self._param['motor'].stop_actions = "ThisShouldNotWork"
495470

496471
class TestTachoMotorTimeSpValue(ptc.ParameterizedTestCase):
497472

@@ -528,7 +503,6 @@ def AddTachoMotorParameterTestsToSuite( suite, driver_name, params ):
528503
suite.addTest(ptc.ParameterizedTestCase.parameterize(TestTachoMotorFullTravelCountValue, param=params))
529504
suite.addTest(ptc.ParameterizedTestCase.parameterize(TestTachoMotorDriverNameValue, param=params))
530505
suite.addTest(ptc.ParameterizedTestCase.parameterize(TestTachoMotorDutyCycleSpValue, param=params))
531-
suite.addTest(ptc.ParameterizedTestCase.parameterize(TestTachoMotorEncoderPolarityValue, param=params))
532506
suite.addTest(ptc.ParameterizedTestCase.parameterize(TestTachoMotorMaxSpeedValue, param=params))
533507
suite.addTest(ptc.ParameterizedTestCase.parameterize(TestTachoMotorPositionPValue, param=params))
534508
suite.addTest(ptc.ParameterizedTestCase.parameterize(TestTachoMotorPositionIValue, param=params))
@@ -544,8 +518,8 @@ def AddTachoMotorParameterTestsToSuite( suite, driver_name, params ):
544518
suite.addTest(ptc.ParameterizedTestCase.parameterize(TestTachoMotorSpeedIValue, param=params))
545519
suite.addTest(ptc.ParameterizedTestCase.parameterize(TestTachoMotorSpeedDValue, param=params))
546520
suite.addTest(ptc.ParameterizedTestCase.parameterize(TestTachoMotorStateValue, param=params))
547-
suite.addTest(ptc.ParameterizedTestCase.parameterize(TestTachoMotorStopCommandValue, param=params))
548-
suite.addTest(ptc.ParameterizedTestCase.parameterize(TestTachoMotorStopCommandsValue, param=params))
521+
suite.addTest(ptc.ParameterizedTestCase.parameterize(TestTachoMotorStopActionValue, param=params))
522+
suite.addTest(ptc.ParameterizedTestCase.parameterize(TestTachoMotorStopActionsValue, param=params))
549523
suite.addTest(ptc.ParameterizedTestCase.parameterize(TestTachoMotorTimeSpValue, param=params))
550524

551525
if __name__ == '__main__':

0 commit comments

Comments
 (0)