Skip to content

Commit d69c230

Browse files
committed
js: add tests for motor class
1 parent 7ccb690 commit d69c230

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

js/examples/test-all-classes.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var ev3dev = require('../bin/index.js');
2+
3+
// Run motor
4+
console.log('Motor --------------');
5+
var motor = new ev3dev.Motor();
6+
['dutyCycle', 'dutyCycleSp', 'portName', 'position',
7+
'positionSp', 'pulsesPerSecond', 'pulsesPerSecondSp',
8+
'rampDownSp', 'rampUpSp', 'regulationMode', 'run',
9+
'runMode', 'speedRegulationP', 'state', 'stopMode',
10+
'stopModes', 'timeSp', 'type'
11+
].forEach(function (value) {
12+
console.log(value + ": " + motor[value]);
13+
});
14+
15+
console.log('Setting motor properties...');
16+
motor.rampUpSp = 100;
17+
motor.rampDownSp = 100;
18+
motor.runMode = 'time';
19+
motor.timeSp = 1000;
20+
motor.dutyCycleSp = 50;
21+
console.log('Running motor...');
22+
motor.run = 1;
23+
console.log('-------------------')

js/motor.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ class Motor extends MotorBase {
113113

114114
//PROPERTIES
115115

116+
get portName(): string {
117+
return this.getString("port_name");
118+
}
119+
116120
get dutyCycle(): number {
117121
return this.getNumber(this.motorProperties.dutyCycle);
118122
}

0 commit comments

Comments
 (0)