Skip to content

Commit fc691f4

Browse files
committed
lua: fixed motor API and tests
1 parent 6b7ddab commit fc691f4

File tree

3 files changed

+13
-22
lines changed

3 files changed

+13
-22
lines changed

lua/drive.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
require 'ev3dev'
44

5+
error("This file is based on outdated motor APIs and therefore no longer works.")
6+
57
MotorControl = class()
68

79
MotorControl.ninetyDegrees = 250

lua/ev3dev-lang-test.lua

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,11 @@ require 'ev3dev'
2525

2626
function printMotorInfo(o)
2727
print(" Current state is "..o:state())
28-
print(" duty cycle: "..o:dutyCycle().." speed: "..o:speed().."\n")
29-
print(" Current command is "..o:commands())
28+
print(" duty cycle: "..o:dutyCycle())
29+
print(" speed: "..o:speed())
30+
print(" position: "..o:position())
3031
print(" stop command: "..o:stopCommand())
31-
print(" speed regulation: "..o:speedRegulationEnabled().."\n")
32-
--print(" Speed setpoint is "..o:speedSetpoint())
33-
34-
if (o:runMode() == o.runModeTime) then
35-
print(" Time setpoint is "..o:timeSetpoint())
36-
end
37-
38-
if (o:runMode() == o.runModePosition) then
39-
print(" Position setpoint is "..o:positionSetpoint())
40-
end
41-
42-
--print(" ramp up: "..o:rampUp().." ramp down: "..o:rampDown())
43-
32+
print(" speed regulation: "..o:speedRegulationEnabled())
4433
end
4534

4635
s = TouchSensor()
@@ -166,7 +155,7 @@ if (ledPFoutD:connected()) then
166155
end
167156

168157
print("Beeping...")
169-
Sound.beep();
158+
--Sound.beep();
170159

171160
print("Sound volume is "..Sound.volume())
172161

lua/ev3dev.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ OUTPUT_D = "outD"
217217

218218
Motor = class(Device)
219219

220-
Motor.Large = "tacho"
221-
Motor.Medium = "minitacho"
220+
Motor.Large = "lego-ev3-l-motor"
221+
Motor.Medium = "lego-ev3-m-motor"
222222

223223
Motor.ModeOff = "off"
224224
Motor.ModeOn = "on"
@@ -238,13 +238,13 @@ function Motor:init(port, motor_types)
238238
local m = { port_name = { port } }
239239

240240
if (motor_types ~= nil) then
241-
m["type"] = motor_types
241+
m["driver_name"] = motor_types
242242
end
243243

244244
Device.init(self, "tacho-motor", "motor", m)
245245

246246
if (self:connected()) then
247-
self._type = self:getAttrString("type")
247+
self._type = self:getAttrString("driver_name")
248248
self._port = self:getAttrString("port_name")
249249
else
250250
self._type = nil
@@ -463,7 +463,7 @@ end
463463
LargeMotor = class(Motor)
464464

465465
function LargeMotor:init(port)
466-
Motor.init(self, port, { "tacho" } )
466+
Motor.init(self, port, { Motor.Large } )
467467
end
468468

469469
------------------------------------------------------------------------------
@@ -472,7 +472,7 @@ end
472472
MediumMotor = class(Motor)
473473

474474
function MediumMotor:init(port)
475-
Motor.init(self, port, { "minitacho" } )
475+
Motor.init(self, port, { Motor.Medium } )
476476
end
477477

478478
------------------------------------------------------------------------------

0 commit comments

Comments
 (0)