-
Notifications
You must be signed in to change notification settings - Fork 17
/
FurtherDocumentation.py
1895 lines (1388 loc) · 64.7 KB
/
FurtherDocumentation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
SPIKE Prime Python Classes
"""
class App:
def __init__(self):
pass
def play_sound(self, name, volume=100):
"""
Plays a sound from the device (tablet or computer).
The program will not continue until the sound has finished playing.
If no sound is found with the given name is found, nothing will happen.
Parameters
-------------
name : The name of the sound to play.
Type : string (text)
Values : Alert, Applause1, Applause2, Applause3, Baa, Bang1, Bang2, BasketballBounce, BigBoing, Bird, Bite, BoatHorn1, BoatHorn2, Bonk, BoomCloud, BoopBingBop, BowlingStrike, Burp1, Burp2, Burp3, CarAccelerate1, CarAccelerating2, CarHorn, CarIdle, CarReverse, CarSkid1, CarSkid2, CarVroom, CatAngry, CatHappy, CatHiss, CatMeow1, CatMeow2, CatMeow3, CatPurring, CatWhining, Chatter, Chirp, Clang, ClockTicking, ClownHonk1, ClownHonk2, ClownHonk3, Coin, Collect, Connect, Crank, CrazyLaugh, Croak, CrowdGasp, Crunch, Cuckoo, CymbalCrash, Disconnect, DogBark1, DogBark2, DogBark3, DogWhining1, DogWhining2, Doorbell1, Doorbell2, Doorbell3, DoorClosing, DoorCreek1, DoorCreek2, DoorHandle, DoorKnock, DoorSlam1, DoorSlam2, DrumRoll, DunDunDunnn, EmotionalPiano, Fart1, Fart2, Fart3, Footsteps, Gallop, GlassBreaking, Glug, GoalCheer, Gong, Growl, Grunt, HammerHit, HeadShake, HighWhoosh, Jump, JungleFrogs, Laser1, Laser2, Laser3, LaughingBaby1, LaughingBaby2, LaughingBoy, LaughingCrowd1, LaughingCrowd2, LaughingGirl, LaughingMale, Lose, LowBoing, LowSqueak, LowWhoosh, MagicSpell, MaleJump1, MaleJump2, Moo, OceanWave, Oops, OrchestraTuning, PartyBlower, Pew, PingPongHit, PlaneFlyingBy, PlaneMotorRunning, PlaneStarting, Pluck, PoliceSiren1, PoliceSiren2, PoliceSiren3, Punch, Rain, Ricochet, Rimshot, RingTone, Rip, Robot1, Robot2, Robot3, RocketExplosionRumble, Rooster, ScramblingFeet, Screech, Seagulls, ServiceAnnouncement, SewingMachine, ShipBell, SirenWhistle, Skid, SlideWhistle1, SlideWhistle2, SneakerSqueak, Snoring, Snort, SpaceAmbience, SpaceFlyby, SpaceNoise, Splash, SportWhistle1, SportWhistle2, SqueakyToy, SquishPop, SuctionCup, Tada, TelephoneRing2, TelephoneRing, Teleport2, Teleport3, Teleport, TennisHit, ThunderStorm, TolietFlush, ToyHonk, ToyZing, Traffic, TrainBreaks, TrainHorn1, TrainHorn2, TrainHorn3, TrainOnTracks, TrainSignal1, TrainSignal2, TrainStart, TrainWhistle, Triumph, TropicalBirds, Wand, WaterDrop, WhistleThump, Whiz1, Whiz2, WindowBreaks, Win, Wobble, WoodTap, Zip
Default : no default value
volume : The volume at which the sound will be played.
Type : integer (positive or negative whole number, including 0)
Values : 0 to 100 %
Default : 100%
Errors
------------
TypeError : name is not a string or volume is not an integer.
RuntimeError : The SPIKE App has been disconnected from the Hub.
"""
pass
def start_sound(self, name, volume):
"""
Starts playing a sound from your device (tablet or computer).
The program will not wait for the sound to finish playing before proceeding to the next command.
If no sound with the given name is found, nothing will happen.
Parameters
-------------
name : The name of the sound to play.
Type : string (text)
Values : Alert, Applause1, Applause2, Applause3, Baa, Bang1, Bang2, BasketballBounce, BigBoing, Bird, Bite, BoatHorn1, BoatHorn2, Bonk, BoomCloud, BoopBingBop, BowlingStrike, Burp1, Burp2, Burp3, CarAccelerate1, CarAccelerating2, CarHorn, CarIdle, CarReverse, CarSkid1, CarSkid2, CarVroom, CatAngry, CatHappy, CatHiss, CatMeow1, CatMeow2, CatMeow3, CatPurring, CatWhining, Chatter, Chirp, Clang, ClockTicking, ClownHonk1, ClownHonk2, ClownHonk3, Coin, Collect, Connect, Crank, CrazyLaugh, Croak, CrowdGasp, Crunch, Cuckoo, CymbalCrash, Disconnect, DogBark1, DogBark2, DogBark3, DogWhining1, DogWhining2, Doorbell1, Doorbell2, Doorbell3, DoorClosing, DoorCreek1, DoorCreek2, DoorHandle, DoorKnock, DoorSlam1, DoorSlam2, DrumRoll, DunDunDunnn, EmotionalPiano, Fart1, Fart2, Fart3, Footsteps, Gallop, GlassBreaking, Glug, GoalCheer, Gong, Growl, Grunt, HammerHit, HeadShake, HighWhoosh, Jump, JungleFrogs, Laser1, Laser2, Laser3, LaughingBaby1, LaughingBaby2, LaughingBoy, LaughingCrowd1, LaughingCrowd2, LaughingGirl, LaughingMale, Lose, LowBoing, LowSqueak, LowWhoosh, MagicSpell, MaleJump1, MaleJump2, Moo, OceanWave, Oops, OrchestraTuning, PartyBlower, Pew, PingPongHit, PlaingFlyingBy, PlaneMotorRunning, PlaneStarting, Pluck, PoliceSiren1, PoliceSiren2, PoliceSiren3, Punch, Rain, Ricochet, Rimshot, RingTone, Rip, Robot1, Robot2, Robot3, RocketExplosionRumble, Rooster, ScramblingFeet, Screech, Seagulls, ServiceAnnouncement, SewingMachine, ShipBell, SirenWhistle, Skid, SlideWhistle1, SlideWhistle2, SneakerSqueak, Snoring, Snort, SpaceAmbience, SpaceFlyby, SpaceNoise, Splash, SportWhistle1, SportWhistle2, SqueakyToy, SquishPop, SuctionCup, Tada, TelephoneRing2, TelephoneRing, Teleport2, Teleport3, Teleport, TennisHit, ThunderStorm, TolietFlush, ToyHonk, ToyZing, Traffic, TrainBreaks, TrainHorn1, TrainHorn2, TrainHorn3, TrainOnTracks, TrainSignal1, TrainSignal2, TrainStart, TrainWhistle, Triumph, TropicalBirds, Wand, WaterDrop, WhistleThump, Whiz1, Whiz2, WindowBreaks, Win, Wobble, WoodTap, Zip
Default : no default value
volume : The volume at which the sound will be played.
Type : integer (positive or negative whole number, including 0)
Values : 0 to 100 %
Default : 100%
Errors
------------
TypeError : name is not a string or volume is not an integer.
RuntimeError : The SPIKE App has been disconnected from the Hub.
"""
pass
class DistanceSensor:
def __init__(self, port):
"""
Allows access to the connected distance sensor.
Parameters
-------------
port : The port label the sensor is connected to
Type : string (text)
Values : 'A', 'B', 'C', 'D', and 'E'
Default : no default value
"""
pass
def light_up_all(self, brightness=100):
"""
Lights up all of the lights on the Distance Sensor with the specified brightness.
Parameters
---------
brightness : The specified brightness of all the lights.
Type : integer (positive or negative whole number, including 0)
Values : 0 to 100 % (0 is off and 100 is full brightness.)
Default : 100 %
Errors
----------
TypeError : brightness is not an integer.
RuntimeError : The sensor has been disconnected from the Port.
"""
pass
def light_up(self, right_top=100, left_top=100, right_bottom=100, left_bottom=100):
"""
Sets the brightness of the individual lights on the Distance Sensor.
Parameters
-------------
right_top : The brightness of the light above the right part of the Distance Sensor.
Type : integer (positive or negative whole number, including 0)
Values : 0 to 100% (0 is off and 100 is full brightness.)
Default : 100
left_top : The brightness of the light above the left part of the Distance Sensor.
Type : integer (positive or negative whole number, including 0)
Values : 0 to 100% (0 is off and 100 is full brightness.)
Default : 100
right_bottom : The brightness of the light below the right part of the Distance Sensor.
Type : integer (positive or negative whole number, including 0)
Values : 0 to 100% (0 is off and 100 is full brightness.)
Default : 100
left_bottom : The brightness of the light below the left part of the Distance Sensor.
Type : integer (positive or negative whole number, including 0)
Values : 0 to 100% (0 is off and 100 is full brightness.)
Default : 100
Errors
---------------
TypeError : right_top, left_top, right_bottom or left_bottom is not a number.
RuntimeError : The sensor has been disconnected from the Port.
"""
pass
def get_distance_cm(self, short_range=False):
"""
Retrieves the measured distance in centimeters.
Parameters
----------
short_range : Whether to use or not the short range mode. The short range mode increases accuracy but it can only detect nearby objects.
Type : boolean
Values : True or False
Default : False
Returns
----------------
The measured distance, or "none" if the distance cannot be measured.
Type : float (decimal number)
Values : 0 to 200 cm
Errors
------------
TypeError : short_range is not a boolean.
RuntimeError : The sensor has been disconnected from the Port.
"""
pass
def get_distance_inches(self, short_range=False):
"""
Gets the measured distance in inches.
Parameters
----------
short_range : Whether or not to use short range mode. Short range mode increases accuracy but it can only detect nearby objects.
Type : boolean
Values : True or False
Default : False
Returns
------------------
The measured distance, or "none" if the distance cannot be measured.
Type : float (decimal number)
Values : any value between 0 and 79
Errors
-------------
TypeError : short_range is not a boolean.
RuntimeError : The sensor has been disconnected from the Port.
"""
pass
def get_distance_percentage(self, short_range=False):
"""
Retrieves the measured distance in percent.
Parameters
---------
short_range : Whether or not to use short range mode. Short range mode increases accuracy but it can only detect nearby objects.
Type : boolean
Values : True or False
Default : False
Returns
----------
The measured distance, or "none" if the distance cannot be measured.
Type : integer (positive or negative whole number, including 0)
Values : any value between 0 and 100
Errors
----------
TypeError : short_range is not a boolean.
RuntimeError : The sensor has been disconnected from the Port.
"""
pass
def wait_for_distance_farther_than(self, distance, unit='cm', short_range=False):
"""
Waits until the measured distance is greater than distance.
Parameters
-----------
distance : The target distance to detect, from the sensor to an object.
Type : float (decimal number)
Values : any value
Default : no default value
unit : Unit of measurement of the distance.
Type : string (text)
Values : 'cm','in','%'
Default : cm
short_range : Whether or not to use short range mode. Short range mode increases accuracy but it can only detect nearby objects.
Type : boolean
Values : True or False
Default : False
Errors
----------
TypeError : distance is not a number or unit is not a string or short_range is not a boolean.
ValueError : unit is not one of the allowed values.
RuntimeError : The sensor has been disconnected from the Port.
"""
pass
def wait_for_distance_closer_than(self, distance, unit='cm', short_range=False):
"""
Waits until the measured distance is less than distance.
Parameters
--------------
distance : The target distance to detect, from the sensor to an object.
Type : float (decimal number)
Values : any value
Default : no default value
unit : Unit of measurement of the distance.
Type : string (text)
Values : 'cm','in','%'
Default : cm
short_range : Whether or not to use short range mode. Short range mode increases accuracy but it can only detect nearby objects.
Type : boolean
Values : True or False
Default : False
Errors
------------
TypeError : distance is not a number or unit is not a string or short_range is not a boolean.
ValueError : unit is not one of the allowed values. short_range is not a boolean.
RuntimeError: The sensor has been disconnected from the Port.
"""
pass
class ForceSensor:
def __init__(self, port):
"""
Allows access to the connected force sensor.
Parameters
-------------
port : The port label the sensor is connected to
Type : string (text)
Values : 'A', 'B', 'C', 'D', and 'E'
Default : no default value
"""
pass
def is_pressed(self):
"""
Tests whether the button on the sensor is pressed.
Returns
----------
True if the button is pressed.
Type : boolean
Values : True or False
Errors
-----------
RuntimeError : The Force Sensor has been disconnected from the port.
"""
pass
def get_force_newton(self):
"""
Retrieves the measured force, in newtons.
Returns
-----------
The measured force in newtons.
Type : float (decimal number)
Values : between 0 and 10
Errors
------------
RuntimeError : The Force Sensor has been disconnected from the port.
"""
pass
def get_force_percentage(self):
"""
Retrieves the measured force as a percentage of the maximum force.
Returns
------------
The measured force, in percentage.
Type : integer (positive or negative whole number, including 0)
Values : between 0 - 100%.
Errors
-----------
RuntimeError : The Force Sensor has been disconnected from the port.
"""
pass
def wait_until_pressed(self):
"""
Waits until the Force Sensor is pressed.
Errors
----------
RuntimeError : The sensor has been disconnected from the port.
"""
pass
def wait_until_released(self):
"""
Waits until the Force Sensor is released.
Errors
---------
RuntimeError : The sensor has been disconnected from the Port.
"""
pass
class LightMatrix:
def __init__(self):
"""
Controls the light matrix on the Spike Hub
"""
pass
def show_image(self, image, brightness=100):
"""
Shows an image on the Light Matrix.
Parameters
-----------
image : Name of the image.
Type : string (text)
Values : ANGRY, ARROW_E, ARROW_N, ARROW_NE, ARROW_NW, ARROW_S, ARROW_SE, ARROW_SW, ARROW_W, ASLEEP, BUTTERFLY, CHESSBOARD, CLOCK1, CLOCK10, CLOCK11, CLOCK12, CLOCK2, CLOCK3, CLOCK4, CLOCK5, CLOCK6, CLOCK7, CLOCK8, CLOCK9, CONFUSED, COW, DIAMOND, DIAMOND_SMALL, DUCK, FABULOUS, GHOST, GIRAFFE, GO_RIGHT, GO_LEFT, GO_IP, GO_DOWN, HAPPY, HEART, HEART_SMALL, HOUSE, MEH, MUSIC_CROTCHET, MUSIC_QUAVER, MUSIC_QUAVERS, NO, PACMAN, PITCHFORK, RABBIT, ROLLERSKATE, SAD, SILLY, SKULL, SMILE, SNAKE, SQUARE, SQUARE_SMALL, STICKFIGURE, SURPRISED, SWORD, TARGET, TORTOISE, TRIANGLE, TRIANGLE_LEFT, TSHIRT, UMBRELLA, XMAS, YES
Default : no default value
brightness : Brightness of the image
Type : integer (positive or negative whole number, including 0)
Values : 0 to 100%
Default : 100
Errors
-------------------
TypeError : image is not a string or brightness is not an integer.
ValueError : image is not one of the allowed values.
"""
pass
def set_pixel(self, x, y, brightness=100):
"""
Sets the brightness of one pixel (one of the 25 LED) on the Light Matrix.
Parameters
-----------
x : Pixel position, counting from the left.
Type : integer (positive or negative whole number, including 0)
Values : 1 to 5
Default : no default value
y : Pixel position, counting from the top.
Type : integer (positive or negative whole number, including 0)
Values : 1 to 5
Default : no default value
brightness : Brightness of the pixel
Type : integer (positive or negative whole number, including 0)
Values : 0 to 100%
Default : 100
Errors
--------------
TypeError : x, y or brightness is not an integer.
ValueError : x, y is not within the allowed range of 0-4.
"""
pass
def write(self, text):
"""
Writes text on the Light Matrix, one letter at a time, scrolling from right to left.
Your program will not continue until all of the letters have been shown.
Parameters
---------
text : Text to write.
Type : string (text)
Values : any text
Default : no default value
"""
pass
def off(self):
"""
Turns off all the pixels on the Light Matrix.
"""
pass
class MotionSensor:
def __init__(self):
"""
Senses angle and motion changes and it built into the Hub.
"""
pass
def reset_yaw_angle(self):
"""
Sets the yaw angle to 0.
"""
pass
def get_yaw_angle(self):
"""
Retrieves the yaw angle of the Hub.
"Yaw" is the rotation around the front-back (vertical) axis. "Pitch" the is rotation around the left-right (transverse) axis. "Roll" the is rotation around the front-back (longitudinal) axis.
Returns
-------
The yaw angle, specified in degrees.
Type : Integer (Positive or negative whole number, including 0)
Values : -180 to 180 BUG: in 1.2 the values are -179 to 179
"""
pass
def get_orientation(self):
"""
Retrieves the current orientation of the Hub.
Returns
-------
The Hub's current orientation.
Type : string (text)
Values : 'front','back','up','down','leftside','rightside'
"""
pass
def get_gesture(self):
"""
Retrieves the most recently-detected gesture.
Returns
---------
The gesture.
Type : string (text)
Values : 'shaken','tapped','doubletapped','falling'
"""
pass
def get_roll_angle(self):
"""
Retrieves the roll angle of the Hub.
"Roll" is the rotation around the front-back (longitudinal) axis. "Yaw" is the rotation around the front-back (vertical) axis. "Pitch" is the rotation around the left-right (transverse) axis.
Returns
-----------
The roll angle, specified in degrees.
Type : Integer (Positive or negative whole number, including 0)
Values : -180 to 180 BUG: currently returns -179 to 179
"""
pass
def get_pitch_angle(self):
"""
Retrieves the pitch angle of the Hub.
"Pitch" is the rotation around the left-right (transverse) axis. "Roll" is the rotation around the front-back (longitudinal) axis. "Yaw" is the rotation around the front-back (vertical) axis.
Returns
-----------
The pitch angle, specified in degrees.
Type : Integer (Positive or negative whole number, including 0)
Values : -180 to 180 BUG: only reads -90 to 90
"""
pass
def was_gesture(self, gesture):
"""
Tests whether a gesture has occurred since the last time was_gesture() was used or since the beginning of the program (for the first use).
Parameters
------------
gesture : The name of the gesture.
Type : string (text)
Values : 'shaken','tapped','doubletapped','falling','None'
Default : no default value
Errors
------------
TypeError : gesture is not a string.
ValueError : gesture is not one of the allowed values.
Returns
----------
True if gesture has occurred since the last time was_gesture() was called, otherwise False.
Type : boolean
Values : True or False
"""
pass
def wait_for_new_gesture(self):
"""
Waits until a new gesture happens.
Returns
--------------
The new gesture.
Type : string (text)
Values : 'shaken','tapped','doubletapped','falling'
"""
pass
def wait_for_new_orientation(self):
"""
Waits until the orientation of the Hub changes.
The first time this method is called, it will immediately return the current value. After that, calling this method will block the program until the Hub's orientation has changed since the previous time this method was called.
Returns
----------
The Hub's new orientation.
Type : string (text)
Values : 'front', 'back', 'up', 'down', 'left side', 'right side'
"""
pass
class Motor:
def __init__(self, port):
"""
Controls a single motor
Parameters
-------------
port : The port label the motor is connected to.
Type : string (text)
Values : 'A', 'B', 'C', 'D', and 'E'
Default : no default value
"""
pass
def run_to_position(self, degrees, direction='shortest path', speed=None):
"""
Runs the motor to an absolute position.
The sign of the speed will be ignored (absolute value) and the motor will always travel in the direction specified by direction parameter. If speed is greater than 100, it will be limited to 100.
Parameters
------------
degrees : The target position.
Type : integer (positive or negative whole number, including 0)
Values : 0 to 359
Default : no default value
direction : The direction to use to reach the target position.
Type : string (text)
Values : shortest path' could run in either direction depending on the shortest distance to the target. - 'clockwise' will make the motor run clockwise until it reaches the target position. - 'counterclockwise' will make the motor run counterclockwise until it reaches the target position.
Default : no default value
speed : The motor's speed.
Type : integer (positive or negative whole number, including 0)
Values : 0 to 100%
Default : if no value is specified, it will use the default speed set by set_default_speed().
Errors
-----------------
TypeError : degrees or speed is not an integer or direction is not a string.
ValueError : direction is not one of the allowed values or degrees is not within the range of 0-359 (both inclusive).
RuntimeError : The motor has been disconnected from the Port.
"""
pass
def run_to_degrees_counted(self, degrees, speed=None):
"""
Runs the motor to until degrees counted is equal to the value specified by the degrees parameter.
The sign of the speed will be ignored and the motor will always travel in the direction required to reach degrees. If speed is greater than 100, it will be limited to 100.
Parameters
-----------
degrees : The target degrees counted.
Type : integer (positive or negative whole number, including 0)
Values : any number
Default : no default value
speed : The desired speed..
Type : integer (positive or negative whole number, including 0)
Values : 0 to 100% (positive values only)
Default : if no value is specified, it will use the default speed set by set_default_speed().
Errors
-----------
TypeError : degrees or speed is not an integer.
RuntimeError : The motor has been disconnected from the Port.
"""
pass
def run_for_degrees(self, degrees, speed=None):
"""
Runs the motor for a given number of degrees.
Parameters
-------------
degrees : The number of degrees the motor should run.
Type : integer (positive or negative whole number, including 0)
Values : any number
Default : no default value
speed : The motor's speed
Type : integer (positive or negative whole number, including 0)
Values : -100% to 100%
Default : if no value is specified, it will use the default speed set by set_default_speed().
Errors
----------
TypeError : degrees or speed is not an integer.
RuntimeError : The motor has been disconnected from the Port.
"""
pass
def run_for_rotations(self, rotations, speed=None):
"""
Runs the motor for a specified number of rotations.
Parameters
-------------
rotations : The number of rotations the motor should run.
Type : float (decimal number)
Values : any number
Default : no default value
speed : The motor's speed
Type : integer (positive or negative whole number, including 0)
Values : -100% to 100%
Default : if no value is specified, it will use the default speed set by set_default_speed().
Errors
-------------
TypeError : rotations is not a number or speed is not an integer.
RuntimeError : The motor has been disconnected from the Port.
"""
pass
def run_for_seconds(self, seconds, speed=None):
"""
Runs the motor for a specified number of seconds.
Parameters
-----------
seconds : The number of seconds for which the motor should run.
Type : float (decimal number)
Values : any number
Default : no default value
speed : The motor's speed.
Type : integer (positive or negative whole number, including 0)
Values : -100% to 100%
Default : if no value is specified, it will use the default speed set by set_default_speed().
Errors
----------
TypeError : seconds is not a number or speed is not an integer.
RuntimeError : The motor has been disconnected from the Port.
"""
pass
def start(self, speed=None):
"""
Starts running the motor at a specified speed.
The motor will keep moving at this speed until you give it another motor command, or when your program ends.
Parameters
----------
speed : The motor's speed.
Type : integer (positive or negative whole number, including 0)
Values : -100% to 100%
Default : if no value is specified, it will use the default speed set by set_default_speed().
Errors
--------
TypeError : speed is not an integer.
RuntimeError : The motor has been disconnected from the Port.
"""
pass
def stop(self):
"""
Stops the motor. What the motor does after it stops depends on the action set in set_stop_action(). The default value of set_stop_action() is coast.
Errors
----------
RuntimeError : The motor has been disconnected from the Port.
"""
pass
def start_at_power(self, power):
"""
Starts rotating the motor at a specified power level.
The motor will keep moving at this power level until you give it another motor command, or when your program ends.
Parameters
---------
power : Power of the motor.
Type : integer (positive or negative whole number, including 0)
Values : -100% to 100%
Default : no default value
Errors
---------
TypeError : power is not an integer.
RuntimeError : The motor has been disconnected from the Port.
"""
pass
def get_speed(self):
"""
Retrieves the speed of the motor.
Returns
----------
The current speed of the motor
Type : integer (positive or negative whole number, including 0)
Values : -100% to 100%
Errors
------------
RuntimeError : The motor has been disconnected from the Port.
"""
pass
def get_position(self):
"""
Retrieves the position of the motor. This is the clockwise angle between the moving marker and the zero-point marker on the motor.
Returns
----------
The position of the motor
Type : integer (positive or negative whole number, including 0)
Values : 0 to 359 degrees
Errors
------------
RuntimeError : The motor has been disconnected from the Port.
"""
pass
def get_degrees_counted(self):
"""
Retrieves the degrees counted by the motor.
Returns
-----------
The number of degrees counted.
Type : integer (positive or negative whole number, including 0)
Values : any number
Errors
----------
RuntimeError : The motor has been disconnected from the Port.
"""
pass
def get_default_speed(self):
"""
Retrieves the current default motor speed.
Returns
---------
The default motor's speed.
Type : integer (positive or negative whole number, including 0)
Values : -100% to 100%.
Errors
----------
RuntimeError : The motor has been disconnected from the Port.
"""
pass
def was_interrupted(self):
"""
Tests whether the motor was interrupted.
Returns
-----------
True if the motor was interrupted since the last time was_interrupted() was called, otherwise False.
Type : boolean
Values : True or False
Errors
-----------
RuntimeError : The motor has been disconnected from the Port.
"""
pass
def was_stalled(self):
"""
Tests whether the motor was stalled.
Returns
-----------
True if the motor was stalled since the last time was_stalled() was called, otherwise False.
Type : boolean
Values : True or False
Errors
-----------
RuntimeError : The motor has been disconnected from the Port.
"""
pass
def set_degrees_counted(self, degrees_counted):
"""
Sets the number of degrees counted to a desired value.
Parameters
----------
degrees_counted : The value to which the number of degrees counted should be set.
Type : integer (positive or negative whole number, including 0)
Values : any number
Default : no default value
Errors
----------
TypeError : degrees_counted is not an integer.
RuntimeError : The motor has been disconnected from the Port.
"""
pass
def set_default_speed(self, default_speed):
"""
Sets the default motor speed. This speed will be used when you omit the speed argument in one of the other methods, such as run_for_degrees.
Setting the default speed does not affect any motors that are currently running.
It will only have an effect when another motor method is called after this method.
If the value of default_speed is outside of the allowed range, the default speed will be set to -100 or 100 depending on whether the value was negative or positive.
Parameters
-----------
default_speed : The default speed value.
Type : integer (positive or negative whole number, including 0)
Values : -100% to 100%.
Default : no default value
Errors
------------
TypeError : default_speed is not an integer.
"""
pass
def set_stop_action(self, action):
"""
Sets the default behavior when a motor stops.
Parameters
-------------
action : The desired motor behavior when the motor stops.
Type : string (text)
Values : 'coast','brake','hold'
Default : coast
Errors
------------
TypeError : action is not a string.
ValueError : action is not one of the allowed values.