Skip to content

Commit 17bd21b

Browse files
committed
Merge branch 'feature/autogen-lua' into develop
2 parents 80051ec + fc691f4 commit 17bd21b

File tree

5 files changed

+299
-177
lines changed

5 files changed

+299
-177
lines changed

autogen/autogen-list.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
"js/motor.ts",
1616
"js/sensor.ts"
1717
],
18+
"lua": [
19+
"lua/ev3dev.lua"
20+
],
1821
"docs": [
1922
"wrapper-specification.md"
2023
]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{% for prop in currentClass.systemProperties %}{%
2+
assign luaName = prop.name | camel_case %}{%
3+
assign type = prop.type | camel_case | capitalize %}{%
4+
if prop.readAccess == true %}
5+
function {{ currentClass.friendlyName | remove:' ' }}:{{ luaName }}()
6+
return self:getAttr{{ type }}("{{ prop.systemName }}")
7+
end
8+
{%
9+
endif %}{%
10+
if prop.writeAccess == true %}
11+
function {{ currentClass.friendlyName | remove:' ' }}:set{{ prop.name | remove:' ' }}(value)
12+
self:setAttr{{ type }}("{{ prop.systemName }}", value)
13+
end
14+
{%
15+
endif %}{%
16+
endfor %}

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: 11 additions & 22 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().." pulses/sec: "..o:pulsesPerSecond().."\n")
29-
print(" Current run mode is "..o:runMode())
30-
print(" stop mode: "..o:stopMode())
31-
print(" regulation mode: "..o:regulationMode().."\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-
28+
print(" duty cycle: "..o:dutyCycle())
29+
print(" speed: "..o:speed())
30+
print(" position: "..o:position())
31+
print(" stop command: "..o:stopCommand())
32+
print(" speed regulation: "..o:speedRegulationEnabled())
4433
end
4534

4635
s = TouchSensor()
@@ -55,7 +44,7 @@ ic = I2CSensor()
5544
if (ic:connected()) then
5645
print("Connected to I2C sensor @ "..c:portName().." with mode "..c:mode())
5746
print ("Value is "..c:value())
58-
if (c:dp() > 0) then
47+
if (c:decimals() > 0) then
5948
print ("Float value is "..c:floatValue())
6049
end
6150
else
@@ -66,7 +55,7 @@ c = ColorSensor()
6655
if (c:connected()) then
6756
print("Connected to color sensor @ "..c:portName().." with mode "..c:mode())
6857
print ("Value is "..c:value())
69-
if (c:dp() > 0) then
58+
if (c:decimals() > 0) then
7059
print ("Float value is "..c:floatValue())
7160
end
7261
else
@@ -77,7 +66,7 @@ u = UltrasonicSensor()
7766
if (u:connected()) then
7867
print("Connected to ultrasonic sensor @ "..u:portName().." with mode "..u:mode())
7968
print ("Value is "..u:value())
80-
if (u:dp() > 0) then
69+
if (u:decimals() > 0) then
8170
print ("Float value is "..u:floatValue())
8271
end
8372
else
@@ -88,7 +77,7 @@ g = GyroSensor()
8877
if (g:connected()) then
8978
print("Connected to gyro sensor @ "..g:portName().." with mode "..g:mode())
9079
print ("Value is "..g:value())
91-
if (g:dp() > 0) then
80+
if (g:decimals() > 0) then
9281
print ("Float value is "..g:floatValue())
9382
end
9483
else
@@ -99,7 +88,7 @@ i = InfraredSensor()
9988
if (i:connected()) then
10089
print("Connected to IR sensor @ "..i:portName().." with mode "..i:mode())
10190
print ("Value is "..i:value())
102-
if (i:dp() > 0) then
91+
if (i:decimals() > 0) then
10392
print ("Float value is "..i:floatValue())
10493
end
10594
else
@@ -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

0 commit comments

Comments
 (0)