AI2 Component  (Version nb184)
Ev3Motors.java
Go to the documentation of this file.
1 // -*- mode: java; c-basic-offset: 2; -*-
2 // Copyright 2016 MIT, All rights reserved
3 // Released under the Apache License, Version 2.0
4 // http://www.apache.org/licenses/LICENSE-2.0
5 
6 package com.google.appinventor.components.runtime;
7 
21 import android.os.Handler;
22 
32 @DesignerComponent(version = YaVersion.EV3_MOTORS_COMPONENT_VERSION,
33  description = "A component that provides both high- and low-level interfaces to a LEGO MINDSTORMS EV3 " +
34  "robot, with functions that can control the motors.",
35  category = ComponentCategory.LEGOMINDSTORMS,
36  nonVisible = true,
37  iconName = "images/legoMindstormsEv3.png")
38 @SimpleObject
39 public class Ev3Motors extends LegoMindstormsEv3Base {
40  private static final int DELAY_MILLISECONDS = 50;
41  private static final String DEFAULT_MOTOR_PORTS = "ABC";
42  private static final double DEFAULT_WHEEL_DIAMETER = 4.32;
43 
44  private int motorPortBitField = 1;
45  private double wheelDiameter = DEFAULT_WHEEL_DIAMETER;
46  private boolean directionReversed = false;
47  private boolean regulationEnabled = true;
48  private boolean stopBeforeDisconnect = true;
49  private boolean tachoCountChangedEventEnabled = false;
50  private final Runnable sensorValueChecker;
51  private Handler eventHandler;
52  private int previousValue = 0;
53  private boolean ifReset = false;
54 
58  public Ev3Motors(ComponentContainer container) {
59  super(container, "Ev3Motors");
60  eventHandler = new Handler();
61  sensorValueChecker = new Runnable() {
62  public void run() {
63  String functionName = "";
64 
65  if (bluetooth != null && bluetooth.IsConnected()) {
66  int sensorValue = getOutputCount(functionName, 0, motorPortBitField);
67 
68  if (!ifReset) {
69  if (sensorValue != previousValue && tachoCountChangedEventEnabled) {
70  TachoCountChanged(sensorValue);
71  }
72  } else {
73  ifReset = false;
74  }
75  previousValue = sensorValue;
76  }
77 
78  eventHandler.postDelayed(this, DELAY_MILLISECONDS);
79  }
80  };
81 
82  eventHandler.post(sensorValueChecker);
83 
84  MotorPorts(DEFAULT_MOTOR_PORTS);
87  ReverseDirection(false);
88  WheelDiameter(DEFAULT_WHEEL_DIAMETER);
90  }
91 
95  @SimpleProperty(description = "The motor ports that the motors are connected to. The ports are specified by a sequence of port letters.",
96  category = PropertyCategory.BEHAVIOR,
97  userVisible = false)
98  public String MotorPorts() {
99  return bitFieldToMotorPortLetters(motorPortBitField);
100  }
101 
106  defaultValue = DEFAULT_MOTOR_PORTS)
108  public void MotorPorts(String motorPortLetters) {
109  String functionName = "MotorPorts";
110  try {
111  motorPortBitField = motorPortLettersToBitField(motorPortLetters);
112  } catch (IllegalArgumentException e) {
113  form.dispatchErrorOccurredEvent(this, functionName, ErrorMessages.ERROR_EV3_ILLEGAL_MOTOR_PORT, motorPortLetters);
114  }
115  }
116 
121  defaultValue = "" + DEFAULT_WHEEL_DIAMETER)
123  public void WheelDiameter(double diameter) {
124  wheelDiameter = diameter;
125  }
126 
130  @SimpleProperty(description = "The diameter of the wheels attached on the motors in centimeters.",
131  category = PropertyCategory.BEHAVIOR,
132  userVisible = false)
133  public double WheelDiameter() {
134  return wheelDiameter;
135  }
136 
141  defaultValue = "False")
143  public void ReverseDirection(boolean reversed) {
144  String functionName = "ReverseDirection";
145  try {
146  setOutputDirection(functionName, 0, motorPortBitField, reversed ? -1 : 1); // assume layer = 0
147  directionReversed = reversed;
148  } catch (IllegalArgumentException e) {
149  form.dispatchErrorOccurredEvent(this, functionName, ErrorMessages.ERROR_EV3_ILLEGAL_ARGUMENT, functionName);
150  }
151  }
152 
156  @SimpleProperty(description = "It specifies if the direction of the motors is reversed.",
157  category = PropertyCategory.BEHAVIOR)
158  public boolean ReverseDirection() {
159  return directionReversed;
160  }
161 
166  defaultValue = "True")
168  public void EnableSpeedRegulation(boolean enabled) {
169  regulationEnabled = enabled;
170  }
171 
175  @SimpleProperty(description = "The robot adjusts the power to maintain the speed if speed regulation is enabled.",
176  category = PropertyCategory.BEHAVIOR)
177  public boolean EnableSpeedRegulation() {
178  return regulationEnabled;
179  }
180 
184  @SimpleProperty(description = "Whether to stop the motor before disconnecting.",
185  category = PropertyCategory.BEHAVIOR)
186  public boolean StopBeforeDisconnect() {
187  return stopBeforeDisconnect;
188  }
189 
196  defaultValue = "True")
198  public void StopBeforeDisconnect(boolean stopBeforeDisconnect) {
199  this.stopBeforeDisconnect = stopBeforeDisconnect;
200  }
201 
205  @SimpleProperty(description = "Whether the TachoCountChanged event should fire when the angle is changed.",
206  category = PropertyCategory.BEHAVIOR)
207  public boolean TachoCountChangedEventEnabled() {
208  return tachoCountChangedEventEnabled;
209  }
210 
215  defaultValue = "False")
217  public void TachoCountChangedEventEnabled(boolean enabled) {
218  tachoCountChangedEventEnabled = enabled;
219  }
220 
224  @SimpleFunction(description = "Start to rotate the motors.")
225  public void RotateIndefinitely(int power) {
226  String functionName = "RotateIndefinitely";
227  try {
228  if (regulationEnabled)
229  setOutputPower(functionName, 0, motorPortBitField, power);
230  else
231  setOutputSpeed(functionName, 0, motorPortBitField, power);
232 
233  startOutput(functionName, 0, motorPortBitField);
234  } catch (IllegalArgumentException e) {
235  form.dispatchErrorOccurredEvent(this, functionName, ErrorMessages.ERROR_EV3_ILLEGAL_ARGUMENT, functionName);
236  }
237  }
238 
242  @SimpleFunction(description = "Rotate the motors in a number of tacho counts.")
243  public void RotateInTachoCounts(int power, int tachoCounts, boolean useBrake) {
244  String functionName = "RotateInTachoCounts";
245  try {
246  if (regulationEnabled)
247  outputStepSpeed(functionName, 0, motorPortBitField, power, 0, tachoCounts, 0, useBrake);
248  else
249  outputStepPower(functionName, 0, motorPortBitField, power, 0, tachoCounts, 0, useBrake);
250  } catch (IllegalArgumentException e) {
251  form.dispatchErrorOccurredEvent(this, functionName, ErrorMessages.ERROR_EV3_ILLEGAL_ARGUMENT, functionName);
252  }
253  }
254 
258  @SimpleFunction(description = "Rotate the motors in a period of time.")
259  public void RotateInDuration(int power, int milliseconds, boolean useBrake) {
260  String functionName = "RotateInDuration";
261  try {
262  if (regulationEnabled)
263  outputTimeSpeed(functionName, 0, motorPortBitField, power, 0, milliseconds, 0, useBrake);
264  else
265  outputTimePower(functionName, 0, motorPortBitField, power, 0, milliseconds, 0, useBrake);
266  } catch (IllegalArgumentException e) {
267  form.dispatchErrorOccurredEvent(this, functionName, ErrorMessages.ERROR_EV3_ILLEGAL_ARGUMENT, functionName);
268  }
269  }
270 
274  @SimpleFunction(description = "Rotate the motors in a distance.")
275  public void RotateInDistance(int power, double distance, boolean useBrake) {
276  String functionName = "RotateInDistance";
277  int tachoCounts = (int) (distance * 360.0 / wheelDiameter / Math.PI);
278 
279  try {
280  if (regulationEnabled)
281  outputStepSpeed(functionName, 0, motorPortBitField, power, 0, tachoCounts, 0, useBrake);
282  else
283  outputStepPower(functionName, 0, motorPortBitField, power, 0, tachoCounts, 0, useBrake);
284  } catch (IllegalArgumentException e) {
285  form.dispatchErrorOccurredEvent(this, functionName, ErrorMessages.ERROR_EV3_ILLEGAL_ARGUMENT, functionName);
286  }
287  }
288 
292  @SimpleFunction(description = "Start to rotate the motors at the same speed.")
293  public void RotateSyncIndefinitely(int power, int turnRatio) {
294  String functionName = "RotateSyncIndefinitely";
295 
296  try {
297  // avoid the issue that output sync commands with single motor causes the EV3 to hang
298  if (motorPortBitField != 0) {
299  if (isOneShotInteger(motorPortBitField))
300  setOutputSpeed(functionName, 0, motorPortBitField, power);
301  else
302  outputStepSync(functionName, 0, motorPortBitField, power, turnRatio, 0, true);
303  }
304 
305  } catch (IllegalArgumentException e) {
306  form.dispatchErrorOccurredEvent(this, functionName, ErrorMessages.ERROR_EV3_ILLEGAL_ARGUMENT, functionName);
307  }
308  }
309 
313  @SimpleFunction(description = "Rotate the motors at the same speed for a distance in cm.")
314  public void RotateSyncInDistance(int power, int distance, int turnRatio, boolean useBrake) {
315  String functionName = "RotateSyncInDuration";
316  int tachoCounts = (int) (distance * 360.0 / wheelDiameter / Math.PI);
317 
318  try {
319  // avoid the issue that output sync commands with single motor causes the EV3 to hang
320  if (motorPortBitField != 0) {
321  if (isOneShotInteger(motorPortBitField))
322  outputStepSpeed(functionName, 0, motorPortBitField, power, 0, tachoCounts, 0, useBrake);
323  else
324  outputStepSync(functionName, 0, motorPortBitField, power, turnRatio, tachoCounts, useBrake);
325  }
326 
327  } catch (IllegalArgumentException e) {
328  form.dispatchErrorOccurredEvent(this, functionName, ErrorMessages.ERROR_EV3_ILLEGAL_ARGUMENT, functionName);
329  }
330  }
331 
335  @SimpleFunction(description = "Rotate the motors at the same speed in a period of time.")
336  public void RotateSyncInDuration(int power, int milliseconds, int turnRatio, boolean useBrake) {
337  String functionName = "RotateSyncInDuration";
338 
339  try {
340  // avoid the issue that output sync commands with single motor causes the EV3 to hang
341  if (motorPortBitField != 0) {
342  if (isOneShotInteger(motorPortBitField))
343  outputTimeSpeed(functionName, 0, motorPortBitField, power, 0, milliseconds, 0, useBrake);
344  else
345  outputTimeSync(functionName, 0, motorPortBitField, power, turnRatio, milliseconds, useBrake);
346  }
347 
348  } catch (IllegalArgumentException e) {
349  form.dispatchErrorOccurredEvent(this, functionName, ErrorMessages.ERROR_EV3_ILLEGAL_ARGUMENT, functionName);
350  }
351  }
352 
356  @SimpleFunction(description = "Rotate the motors at the same speed in a number of tacho counts.")
357  public void RotateSyncInTachoCounts(int power, int tachoCounts, int turnRatio, boolean useBrake) {
358  String functionName = "RotateSyncInTachoCounts";
359 
360  try {
361  // avoid the issue that output sync commands with single motor causes the EV3 to hang
362  if (motorPortBitField != 0) {
363  if (isOneShotInteger(motorPortBitField))
364  outputStepSpeed(functionName, 0, motorPortBitField, power, 0, tachoCounts, 0, useBrake);
365  else
366  outputStepSync(functionName, 0, motorPortBitField, power, turnRatio, tachoCounts, useBrake);
367  }
368 
369  } catch (IllegalArgumentException e) {
370  form.dispatchErrorOccurredEvent(this, functionName, ErrorMessages.ERROR_EV3_ILLEGAL_ARGUMENT, functionName);
371  }
372  }
373 
377  @SimpleFunction(description = "Stop the motors of the robot.")
378  public void Stop(boolean useBrake) {
379  String functionName = "Stop";
380  try {
381  stopOutput(functionName, 0, motorPortBitField, useBrake); // assume layer = 0
382  } catch (IllegalArgumentException e) {
383  form.dispatchErrorOccurredEvent(this, functionName, ErrorMessages.ERROR_EV3_ILLEGAL_ARGUMENT, functionName);
384  }
385  }
386 
390  @SimpleFunction(description = "Toggle the direction of motors.")
391  public void ToggleDirection() {
392  String functionName = "ToggleDirection";
393  try {
394  setOutputDirection(functionName, 0, motorPortBitField, 0); // assume layer = 0
395  directionReversed = !directionReversed;
396  } catch (IllegalArgumentException e) {
397  form.dispatchErrorOccurredEvent(this, functionName, ErrorMessages.ERROR_EV3_ILLEGAL_ARGUMENT, functionName);
398  }
399  }
400 
404  @SimpleFunction(description = "Set the current tacho count to zero.")
405  public void ResetTachoCount() {
406  String functionName = "ResetTachoCount";
407  try {
408  clearOutputCount(functionName, 0, motorPortBitField); // assume layer = 0
409  } catch (IllegalArgumentException e) {
410  form.dispatchErrorOccurredEvent(this, functionName, ErrorMessages.ERROR_EV3_ILLEGAL_ARGUMENT, functionName);
411  }
412  }
413 
417  @SimpleFunction(description = "Get the current tacho count.")
418  public int GetTachoCount() {
419  String functionName = "GetTachoCount";
420  try {
421  return getOutputCount(functionName, 0, motorPortBitField); // assume layer = 0
422  } catch (IllegalArgumentException e) {
423  form.dispatchErrorOccurredEvent(this, functionName, ErrorMessages.ERROR_EV3_ILLEGAL_ARGUMENT, functionName);
424  return 0;
425  }
426  }
427 
431  @SimpleEvent(description = "Called when the tacho count has changed.")
432  public void TachoCountChanged(int tachoCount) {
433  EventDispatcher.dispatchEvent(this, "TachoCountChanged", tachoCount);
434  }
435 
436  private int roundValue(int value, int minimum, int maximum) {
437  return value < minimum ? minimum : (value > maximum ? maximum : value);
438  }
439 
440  private boolean isOneShotInteger(int value) {
441  return (value != 0) && ((value & ~(value ^ (value - 1))) == 0);
442  }
443 
444  private void resetOutput(String functionName, int layer, int nos) {
445  if (layer < 0 || layer > 3 || nos < 0 || nos > 15)
446  throw new IllegalArgumentException();
447  ifReset = true;
448  byte[] command = Ev3BinaryParser.encodeDirectCommand(Ev3Constants.Opcode.OUTPUT_RESET,
449  false,
450  0,
451  0,
452  "cc",
453  (byte) layer,
454  (byte) nos);
455  sendCommand(functionName, command, false);
456  }
457 
458  private void startOutput(String functionName, int layer, int nos) {
459  if (layer < 0 || layer > 3 || nos < 0 || nos > 15)
460  throw new IllegalArgumentException();
461 
462  byte[] command = Ev3BinaryParser.encodeDirectCommand(Ev3Constants.Opcode.OUTPUT_START,
463  false,
464  0,
465  0,
466  "cc",
467  (byte) layer,
468  (byte) nos);
469  sendCommand(functionName, command, false);
470  }
471 
472  private void stopOutput(String functionName, int layer, int nos, boolean useBrake) {
473  if (layer < 0 || layer > 3 || nos < 0 || nos > 15)
474  throw new IllegalArgumentException();
475 
476  byte[] command = Ev3BinaryParser.encodeDirectCommand(Ev3Constants.Opcode.OUTPUT_STOP,
477  false,
478  0,
479  0,
480  "ccc",
481  (byte) layer,
482  (byte) nos,
483  useBrake ? (byte) 1 : (byte) 0);
484  sendCommand(functionName, command, false);
485  }
486 
487  private void outputStepPower(String functionName, int layer, int nos, int power, int step1, int step2, int step3, boolean brake) {
488  if (layer < 0 || layer > 3 || nos < 0 || nos > 15 || step1 < 0 || step2 < 0 || step3 < 0)
489  throw new IllegalArgumentException();
490 
491  power = roundValue(power, -100, 100);
492 
493  byte[] command = Ev3BinaryParser.encodeDirectCommand(Ev3Constants.Opcode.OUTPUT_STEP_POWER,
494  false,
495  0,
496  0,
497  "ccccccc",
498  (byte) layer,
499  (byte) nos,
500  (byte) power,
501  step1,
502  step2,
503  step3,
504  (byte) (brake ? 1 : 0));
505  sendCommand(functionName, command, false);
506  }
507 
508  private void outputStepSpeed(String functionName, int layer, int nos, int speed, int step1, int step2, int step3, boolean brake) {
509  if (layer < 0 || layer > 3 || nos < 0 || nos > 15 || step1 < 0 || step2 < 0 || step3 < 0)
510  throw new IllegalArgumentException();
511 
512  speed = roundValue(speed, -100, 100);
513 
514  byte[] command = Ev3BinaryParser.encodeDirectCommand(Ev3Constants.Opcode.OUTPUT_STEP_SPEED,
515  false,
516  0,
517  0,
518  "ccccccc",
519  (byte) layer,
520  (byte) nos,
521  (byte) speed,
522  step1,
523  step2,
524  step3,
525  (byte) (brake ? 1 : 0));
526  sendCommand(functionName, command, false);
527  }
528 
529  private void outputStepSync(String functionName, int layer, int nos, int speed, int turnRatio, int tachoCounts, boolean brake) {
530  if (layer < 0 || layer > 3 || nos < 0 || nos > 15 || turnRatio < -200 || turnRatio > 200)
531  throw new IllegalArgumentException();
532 
533  speed = roundValue(speed, -100, 100);
534 
535  byte[] command = Ev3BinaryParser.encodeDirectCommand(Ev3Constants.Opcode.OUTPUT_STEP_SYNC,
536  false,
537  0,
538  0,
539  "cccccc",
540  (byte) layer,
541  (byte) nos,
542  (byte) speed,
543  (short) turnRatio,
544  tachoCounts,
545  (byte) (brake ? 1 : 0));
546  sendCommand(functionName, command, false);
547  }
548 
549  private void outputTimePower(String functionName, int layer, int nos, int power, int step1, int step2, int step3, boolean brake) {
550  if (layer < 0 || layer > 3 || nos < 0 || nos > 15 || step1 < 0 || step2 < 0 || step3 < 0)
551  throw new IllegalArgumentException();
552 
553  power = roundValue(power, -100, 100);
554 
555  byte[] command = Ev3BinaryParser.encodeDirectCommand(Ev3Constants.Opcode.OUTPUT_TIME_POWER,
556  false,
557  0,
558  0,
559  "ccccccc",
560  (byte) layer,
561  (byte) nos,
562  (byte) power,
563  step1,
564  step2,
565  step3,
566  (byte) (brake ? 1 : 0));
567  sendCommand(functionName, command, false);
568  }
569 
570  private void outputTimeSpeed(String functionName, int layer, int nos, int speed, int step1, int step2, int step3, boolean brake) {
571  if (layer < 0 || layer > 3 || nos < 0 || nos > 15 || step1 < 0 || step2 < 0 || step3 < 0)
572  throw new IllegalArgumentException();
573 
574  speed = roundValue(speed, -100, 100);
575 
576  byte[] command = Ev3BinaryParser.encodeDirectCommand(Ev3Constants.Opcode.OUTPUT_TIME_SPEED,
577  false,
578  0,
579  0,
580  "ccccccc",
581  (byte) layer,
582  (byte) nos,
583  (byte) speed,
584  step1,
585  step2,
586  step3,
587  (byte) (brake ? 1 : 0));
588  sendCommand(functionName, command, false);
589  }
590 
591  private void outputTimeSync(String functionName, int layer, int nos, int speed, int turnRatio, int milliseconds, boolean brake) {
592  if (layer < 0 || layer > 3 || nos < 0 || nos > 15 || milliseconds < 0)
593  throw new IllegalArgumentException();
594 
595  speed = roundValue(speed, -100, 100);
596 
597  byte[] command = Ev3BinaryParser.encodeDirectCommand(Ev3Constants.Opcode.OUTPUT_TIME_SYNC,
598  false,
599  0,
600  0,
601  "cccccc",
602  (byte) layer,
603  (byte) nos,
604  (byte) speed,
605  (short) turnRatio,
606  milliseconds,
607  (byte) (brake ? 1 : 0));
608  sendCommand(functionName, command, false);
609  }
610 
611  private void setOutputDirection(String functionName, int layer, int nos, int direction) {
612  if (layer < 0 || layer > 3 || nos < 0 || nos > 15 || direction < -1 || direction > 1)
613  throw new IllegalArgumentException();
614 
615  byte[] command = Ev3BinaryParser.encodeDirectCommand(Ev3Constants.Opcode.OUTPUT_POLARITY,
616  false,
617  0,
618  0,
619  "ccc",
620  (byte) layer,
621  (byte) nos,
622  (byte) direction);
623  sendCommand(functionName, command, false);
624  }
625 
626  private void setOutputSpeed(String functionName, int layer, int nos, int speed) {
627  if (layer < 0 || layer > 3 || nos < 0 || nos > 15)
628  throw new IllegalArgumentException();
629 
630  speed = roundValue(speed, -100, 100);
631 
632  byte[] command = Ev3BinaryParser.encodeDirectCommand(Ev3Constants.Opcode.OUTPUT_SPEED,
633  false,
634  0,
635  0,
636  "ccc",
637  (byte) layer,
638  (byte) nos,
639  (byte) speed);
640  sendCommand(functionName, command, false);
641  }
642 
643  private void setOutputPower(String functionName, int layer, int nos, int power) {
644  if (layer < 0 || layer > 3 || nos < 0 || nos > 15)
645  throw new IllegalArgumentException();
646 
647  power = roundValue(power, -100, 100);
648 
649  byte[] command = Ev3BinaryParser.encodeDirectCommand(Ev3Constants.Opcode.OUTPUT_POWER,
650  false,
651  0,
652  0,
653  "ccc",
654  (byte) layer,
655  (byte) nos,
656  (byte) power);
657  sendCommand(functionName, command, false);
658  }
659 
660  private int getOutputCount(String functionName, int layer, int nos) {
661  if (layer < 0 || layer > 3 || nos < 0 || nos > 15)
662  throw new IllegalArgumentException();
663 
664  // select the port with minimum port number
665  nos = ((nos ^ (nos - 1)) + 1 >>> 1);
666 
667  int portNumber;
668  switch (nos) {
669  case 1:
670  portNumber = 0;
671  break;
672 
673  case 2:
674  portNumber = 1;
675  break;
676 
677  case 4:
678  portNumber = 2;
679  break;
680 
681  case 8:
682  portNumber = 3;
683  break;
684 
685  default:
686  throw new IllegalArgumentException();
687  }
688 
689  byte[] command = Ev3BinaryParser.encodeDirectCommand(Ev3Constants.Opcode.OUTPUT_GET_COUNT,
690  true,
691  4,
692  0,
693  "ccg",
694  (byte) layer,
695  (byte) portNumber,
696  (byte) 0);
697  byte[] reply = sendCommand(functionName, command, true);
698 
699  if (reply != null && reply.length == 5 && reply[0] == Ev3Constants.DirectReplyType.DIRECT_REPLY) {
700  Object[] values = Ev3BinaryParser.unpack("xi", reply);
701  return (Integer) values[0];
702  } else {
703  return 0;
704  }
705  }
706 
707  private void clearOutputCount(String functionName, int layer, int nos) {
708  if (layer < 0 || layer > 3 || nos < 0 || nos > 15)
709  throw new IllegalArgumentException();
710 
711  byte[] command = Ev3BinaryParser.encodeDirectCommand(Ev3Constants.Opcode.OUTPUT_CLR_COUNT,
712  false,
713  0,
714  0,
715  "cc",
716  (byte) layer,
717  (byte) nos);
718  sendCommand(functionName, command, false);
719  }
720 
721  @Override
722  public void beforeDisconnect(BluetoothConnectionBase bluetoothConnection) {
723  String functionName = "beforeDisconnect";
724  if (stopBeforeDisconnect) {
725  try {
726  stopOutput(functionName, 0, motorPortBitField, true); // assume layer = 0
727  } catch (IllegalArgumentException e) {
728  form.dispatchErrorOccurredEvent(this, functionName, ErrorMessages.ERROR_EV3_ILLEGAL_ARGUMENT, functionName);
729  }
730  }
731  }
732 }
com.google.appinventor.components.runtime.EventDispatcher
Definition: EventDispatcher.java:22
com.google.appinventor.components.common.PropertyTypeConstants.PROPERTY_TYPE_FLOAT
static final String PROPERTY_TYPE_FLOAT
Definition: PropertyTypeConstants.java:76
com.google.appinventor.components.runtime.Ev3Motors.RotateSyncInDistance
void RotateSyncInDistance(int power, int distance, int turnRatio, boolean useBrake)
Definition: Ev3Motors.java:314
com.google.appinventor.components.runtime.Ev3Motors.TachoCountChangedEventEnabled
void TachoCountChangedEventEnabled(boolean enabled)
Definition: Ev3Motors.java:217
com.google.appinventor.components.annotations.SimpleFunction
Definition: SimpleFunction.java:23
com.google.appinventor.components.runtime.LegoMindstormsEv3Base.motorPortLettersToBitField
final int motorPortLettersToBitField(String letters)
Definition: LegoMindstormsEv3Base.java:145
com.google.appinventor.components.runtime.util.ErrorMessages
Definition: ErrorMessages.java:17
com.google.appinventor.components.runtime.util
-*- mode: java; c-basic-offset: 2; -*-
Definition: AccountChooser.java:7
com.google.appinventor.components.runtime.LegoMindstormsEv3Base.bluetooth
BluetoothClient bluetooth
Definition: LegoMindstormsEv3Base.java:30
com.google.appinventor.components.runtime.Ev3Motors.ReverseDirection
boolean ReverseDirection()
Definition: Ev3Motors.java:158
com.google.appinventor.components.common.YaVersion
Definition: YaVersion.java:14
com.google.appinventor.components.annotations.DesignerProperty
Definition: DesignerProperty.java:25
com.google.appinventor.components.common.PropertyTypeConstants.PROPERTY_TYPE_STRING
static final String PROPERTY_TYPE_STRING
Definition: PropertyTypeConstants.java:237
com.google.appinventor.components.runtime.Ev3Motors.GetTachoCount
int GetTachoCount()
Definition: Ev3Motors.java:418
com.google.appinventor.components
com.google.appinventor.components.runtime.util.Ev3BinaryParser
Definition: Ev3BinaryParser.java:21
com.google.appinventor.components.runtime.Ev3Motors.RotateInDuration
void RotateInDuration(int power, int milliseconds, boolean useBrake)
Definition: Ev3Motors.java:259
com.google.appinventor.components.runtime.Ev3Motors.EnableSpeedRegulation
void EnableSpeedRegulation(boolean enabled)
Definition: Ev3Motors.java:168
com.google.appinventor.components.runtime.BluetoothConnectionBase.IsConnected
final boolean IsConnected()
Definition: BluetoothConnectionBase.java:204
com.google.appinventor.components.common.PropertyTypeConstants.PROPERTY_TYPE_BOOLEAN
static final String PROPERTY_TYPE_BOOLEAN
Definition: PropertyTypeConstants.java:35
com.google.appinventor.components.runtime.Ev3Motors.ReverseDirection
void ReverseDirection(boolean reversed)
Definition: Ev3Motors.java:143
com.google.appinventor.components.annotations.DesignerComponent
Definition: DesignerComponent.java:22
com.google.appinventor.components.annotations.SimpleEvent
Definition: SimpleEvent.java:20
com.google.appinventor.components.annotations.PropertyCategory.BEHAVIOR
BEHAVIOR
Definition: PropertyCategory.java:15
com.google.appinventor.components.runtime.Ev3Motors.Ev3Motors
Ev3Motors(ComponentContainer container)
Definition: Ev3Motors.java:58
com.google.appinventor.components.runtime.Ev3Motors.StopBeforeDisconnect
boolean StopBeforeDisconnect()
Definition: Ev3Motors.java:186
com.google.appinventor.components.runtime.Ev3Motors.TachoCountChanged
void TachoCountChanged(int tachoCount)
Definition: Ev3Motors.java:432
com.google.appinventor.components.runtime.Ev3Motors.StopBeforeDisconnect
void StopBeforeDisconnect(boolean stopBeforeDisconnect)
Definition: Ev3Motors.java:198
com.google.appinventor.components.runtime.Ev3Motors
Definition: Ev3Motors.java:39
com.google.appinventor.components.runtime.Ev3Motors.RotateSyncInTachoCounts
void RotateSyncInTachoCounts(int power, int tachoCounts, int turnRatio, boolean useBrake)
Definition: Ev3Motors.java:357
com.google.appinventor.components.runtime.Ev3Motors.RotateSyncIndefinitely
void RotateSyncIndefinitely(int power, int turnRatio)
Definition: Ev3Motors.java:293
com.google.appinventor.components.runtime.EventDispatcher.dispatchEvent
static boolean dispatchEvent(Component component, String eventName, Object...args)
Definition: EventDispatcher.java:188
com.google.appinventor.components.runtime.Ev3Motors.RotateInDistance
void RotateInDistance(int power, double distance, boolean useBrake)
Definition: Ev3Motors.java:275
com.google.appinventor.components.runtime.Ev3Motors.TachoCountChangedEventEnabled
boolean TachoCountChangedEventEnabled()
Definition: Ev3Motors.java:207
com.google.appinventor.components.runtime.Ev3Motors.WheelDiameter
void WheelDiameter(double diameter)
Definition: Ev3Motors.java:123
com.google.appinventor.components.runtime.Ev3Motors.ToggleDirection
void ToggleDirection()
Definition: Ev3Motors.java:391
com.google.appinventor.components.annotations.SimpleProperty
Definition: SimpleProperty.java:23
com.google.appinventor.components.runtime.Ev3Motors.MotorPorts
String MotorPorts()
Definition: Ev3Motors.java:98
com.google.appinventor.components.runtime.LegoMindstormsEv3Base
Definition: LegoMindstormsEv3Base.java:24
com.google.appinventor.components.runtime.Ev3Motors.ResetTachoCount
void ResetTachoCount()
Definition: Ev3Motors.java:405
com.google.appinventor.components.runtime.BluetoothConnectionBase
Definition: BluetoothConnectionBase.java:41
com.google.appinventor.components.annotations.PropertyCategory
Definition: PropertyCategory.java:13
com.google.appinventor.components.runtime.ComponentContainer
Definition: ComponentContainer.java:16
com.google.appinventor.components.runtime
Copyright 2009-2011 Google, All Rights reserved.
Definition: AccelerometerSensor.java:8
com.google.appinventor.components.common
Definition: ComponentCategory.java:7
com.google.appinventor.components.common.ComponentCategory
Definition: ComponentCategory.java:48
com.google.appinventor.components.runtime.LegoMindstormsEv3Base.sendCommand
final byte[] sendCommand(String functionName, byte[] command, boolean doReceiveReply)
Definition: LegoMindstormsEv3Base.java:87
com.google.appinventor.components.runtime.Ev3Motors.MotorPorts
void MotorPorts(String motorPortLetters)
Definition: Ev3Motors.java:108
com.google.appinventor.components.runtime.Ev3Motors.RotateSyncInDuration
void RotateSyncInDuration(int power, int milliseconds, int turnRatio, boolean useBrake)
Definition: Ev3Motors.java:336
com.google.appinventor.components.runtime.Form.dispatchErrorOccurredEvent
void dispatchErrorOccurredEvent(final Component component, final String functionName, final int errorNumber, final Object... messageArgs)
Definition: Form.java:1011
com.google.appinventor.components.annotations.SimpleObject
Definition: SimpleObject.java:23
com.google
com
com.google.appinventor.components.runtime.Ev3Motors.RotateInTachoCounts
void RotateInTachoCounts(int power, int tachoCounts, boolean useBrake)
Definition: Ev3Motors.java:243
com.google.appinventor.components.runtime.LegoMindstormsEv3Base.bitFieldToMotorPortLetters
final String bitFieldToMotorPortLetters(int bitField)
Definition: LegoMindstormsEv3Base.java:190
com.google.appinventor.components.runtime.Ev3Motors.RotateIndefinitely
void RotateIndefinitely(int power)
Definition: Ev3Motors.java:225
com.google.appinventor.components.runtime.util.ErrorMessages.ERROR_EV3_ILLEGAL_MOTOR_PORT
static final int ERROR_EV3_ILLEGAL_MOTOR_PORT
Definition: ErrorMessages.java:217
com.google.appinventor.components.runtime.util.ErrorMessages.ERROR_EV3_ILLEGAL_ARGUMENT
static final int ERROR_EV3_ILLEGAL_ARGUMENT
Definition: ErrorMessages.java:216
com.google.appinventor.components.runtime.AndroidNonvisibleComponent.form
final Form form
Definition: AndroidNonvisibleComponent.java:19
com.google.appinventor.components.runtime.util.Ev3Constants
Definition: Ev3Constants.java:14
com.google.appinventor.components.runtime.Ev3Motors.WheelDiameter
double WheelDiameter()
Definition: Ev3Motors.java:133
com.google.appinventor.components.runtime.Ev3Motors.EnableSpeedRegulation
boolean EnableSpeedRegulation()
Definition: Ev3Motors.java:177
com.google.appinventor.components.runtime.Ev3Motors.beforeDisconnect
void beforeDisconnect(BluetoothConnectionBase bluetoothConnection)
Definition: Ev3Motors.java:722
com.google.appinventor.components.common.PropertyTypeConstants
Definition: PropertyTypeConstants.java:14
com.google.appinventor.components.annotations
com.google.appinventor.components.runtime.Ev3Motors.Stop
void Stop(boolean useBrake)
Definition: Ev3Motors.java:378
com.google.appinventor