@@ -171,8 +171,16 @@ class EV3 {
171
171
disconnectSession ( ) {
172
172
this . _bt . disconnectSession ( ) ;
173
173
window . clearInterval ( this . _pollingIntervalID ) ; // TODO: window?
174
+ this . speed = 50 ;
175
+ this . _sensors = {
176
+ distance : 0 ,
177
+ brightness : 0 ,
178
+ buttons : [ 0 , 0 , 0 , 0 ]
179
+ } ;
180
+ this . _motorPositions = [ 0 , 0 , 0 , 0 ] ;
174
181
this . _sensorPorts = [ ] ;
175
182
this . _motorPorts = [ ] ;
183
+ this . _pollingIntervalID = null ;
176
184
}
177
185
178
186
/**
@@ -885,17 +893,39 @@ class Scratch3Ev3Blocks {
885
893
}
886
894
887
895
motorTurnClockwise ( args ) {
888
- const port = Cast . toNumber ( args . PORT ) ;
896
+ const port = Cast . toNumber ( args . PORT ) ; // TODO: fix
889
897
const time = Cast . toNumber ( args . TIME ) * 1000 ;
890
898
891
- return this . _device . motorTurnClockwise ( port , time ) ;
899
+ let p = null ;
900
+ if ( port === 1 ) {
901
+ p = 1 ;
902
+ } else if ( port === 2 ) {
903
+ p = 2 ;
904
+ } else if ( port === 3 ) {
905
+ p = 4 ;
906
+ } else if ( port === 4 ) {
907
+ p = 8 ;
908
+ }
909
+
910
+ return this . _device . motorTurnClockwise ( p , time ) ;
892
911
}
893
912
894
913
motorTurnCounterClockwise ( args ) {
895
- const port = Cast . toNumber ( args . PORT ) ;
914
+ const port = Cast . toNumber ( args . PORT ) ; // TODO: fix
896
915
const time = Cast . toNumber ( args . TIME ) * 1000 ;
897
916
898
- return this . _device . motorTurnCounterClockwise ( port , time ) ;
917
+ let p = null ;
918
+ if ( port === 1 ) {
919
+ p = 1 ;
920
+ } else if ( port === 2 ) {
921
+ p = 2 ;
922
+ } else if ( port === 3 ) {
923
+ p = 4 ;
924
+ } else if ( port === 4 ) {
925
+ p = 8 ;
926
+ }
927
+
928
+ return this . _device . motorTurnCounterClockwise ( p , time ) ;
899
929
}
900
930
901
931
motorRotate ( args ) {
0 commit comments