From 6d80d5e596e24e74ab01acfb01e547c68fe7369a Mon Sep 17 00:00:00 2001 From: Antoni Luong Pham Date: Sat, 5 Dec 2020 14:21:41 -0800 Subject: [PATCH] sets/ev3/home: refactor --- sets/ev3/home/ev3rstorm/.vscode/settings.json | 2 +- sets/ev3/home/gripp3r/.vscode/settings.json | 2 +- sets/ev3/home/r3ptar/.vscode/settings.json | 2 +- sets/ev3/home/spik3r/.vscode/settings.json | 2 +- sets/ev3/home/track3r/.vscode/settings.json | 2 +- .../home_bonus/bobb3e/.vscode/settings.json | 2 +- sets/ev3/home_bonus/bobb3e/bobb3e.py | 20 ++++++------- .../home_bonus/dinor3x/.vscode/settings.json | 2 +- .../el3ctric_guitar/.vscode/settings.json | 2 +- .../home_bonus/ev3_game/.vscode/settings.json | 2 +- .../home_bonus/mr_b3am/.vscode/settings.json | 2 +- .../robodoz3r/.vscode/settings.json | 2 +- sets/ev3/home_bonus/robodoz3r/rc_tank_util.py | 28 +++++++++---------- .../sets_ev3_home_bonus.code-workspace | 10 +++++++ .../home_bonus/wack3m/.vscode/settings.json | 2 +- sets/ev3/home_bonus/wack3m/wack3m.py | 10 +++---- 16 files changed, 50 insertions(+), 42 deletions(-) diff --git a/sets/ev3/home/ev3rstorm/.vscode/settings.json b/sets/ev3/home/ev3rstorm/.vscode/settings.json index 42a109f..ea2d3db 100644 --- a/sets/ev3/home/ev3rstorm/.vscode/settings.json +++ b/sets/ev3/home/ev3rstorm/.vscode/settings.json @@ -3,5 +3,5 @@ "files.eol": "\n", "debug.openDebug": "neverOpen", "editor.rulers": [79], - "python.linting.enabled": true + "python.linting.flake8Enabled": true } diff --git a/sets/ev3/home/gripp3r/.vscode/settings.json b/sets/ev3/home/gripp3r/.vscode/settings.json index 42a109f..ea2d3db 100644 --- a/sets/ev3/home/gripp3r/.vscode/settings.json +++ b/sets/ev3/home/gripp3r/.vscode/settings.json @@ -3,5 +3,5 @@ "files.eol": "\n", "debug.openDebug": "neverOpen", "editor.rulers": [79], - "python.linting.enabled": true + "python.linting.flake8Enabled": true } diff --git a/sets/ev3/home/r3ptar/.vscode/settings.json b/sets/ev3/home/r3ptar/.vscode/settings.json index 42a109f..ea2d3db 100644 --- a/sets/ev3/home/r3ptar/.vscode/settings.json +++ b/sets/ev3/home/r3ptar/.vscode/settings.json @@ -3,5 +3,5 @@ "files.eol": "\n", "debug.openDebug": "neverOpen", "editor.rulers": [79], - "python.linting.enabled": true + "python.linting.flake8Enabled": true } diff --git a/sets/ev3/home/spik3r/.vscode/settings.json b/sets/ev3/home/spik3r/.vscode/settings.json index 42a109f..ea2d3db 100644 --- a/sets/ev3/home/spik3r/.vscode/settings.json +++ b/sets/ev3/home/spik3r/.vscode/settings.json @@ -3,5 +3,5 @@ "files.eol": "\n", "debug.openDebug": "neverOpen", "editor.rulers": [79], - "python.linting.enabled": true + "python.linting.flake8Enabled": true } diff --git a/sets/ev3/home/track3r/.vscode/settings.json b/sets/ev3/home/track3r/.vscode/settings.json index 42a109f..ea2d3db 100644 --- a/sets/ev3/home/track3r/.vscode/settings.json +++ b/sets/ev3/home/track3r/.vscode/settings.json @@ -3,5 +3,5 @@ "files.eol": "\n", "debug.openDebug": "neverOpen", "editor.rulers": [79], - "python.linting.enabled": true + "python.linting.flake8Enabled": true } diff --git a/sets/ev3/home_bonus/bobb3e/.vscode/settings.json b/sets/ev3/home_bonus/bobb3e/.vscode/settings.json index 42a109f..ea2d3db 100644 --- a/sets/ev3/home_bonus/bobb3e/.vscode/settings.json +++ b/sets/ev3/home_bonus/bobb3e/.vscode/settings.json @@ -3,5 +3,5 @@ "files.eol": "\n", "debug.openDebug": "neverOpen", "editor.rulers": [79], - "python.linting.enabled": true + "python.linting.flake8Enabled": true } diff --git a/sets/ev3/home_bonus/bobb3e/bobb3e.py b/sets/ev3/home_bonus/bobb3e/bobb3e.py index 0be617e..2762971 100644 --- a/sets/ev3/home_bonus/bobb3e/bobb3e.py +++ b/sets/ev3/home_bonus/bobb3e/bobb3e.py @@ -16,17 +16,15 @@ class Bobb3e: lift_motor_port: str = Port.A, ir_sensor_port: str = Port.S4, ir_beacon_channel: int = 1): self.ev3_brick = EV3Brick() - - self.drive_base = \ - DriveBase( - left_motor= - Motor(port=left_motor_port, - positive_direction=Direction.COUNTERCLOCKWISE), - right_motor= - Motor(port=right_motor_port, - positive_direction=Direction.COUNTERCLOCKWISE), - wheel_diameter=self.WHEEL_DIAMETER, - axle_track=self.AXLE_TRACK) + + left_motor = Motor(port=left_motor_port, + positive_direction=Direction.COUNTERCLOCKWISE) + right_motor = Motor(port=right_motor_port, + positive_direction=Direction.COUNTERCLOCKWISE) + self.drive_base = DriveBase(left_motor=left_motor, + right_motor=right_motor, + wheel_diameter=self.WHEEL_DIAMETER, + axle_track=self.AXLE_TRACK) self.lift_motor = Motor(port=lift_motor_port, positive_direction=Direction.CLOCKWISE) diff --git a/sets/ev3/home_bonus/dinor3x/.vscode/settings.json b/sets/ev3/home_bonus/dinor3x/.vscode/settings.json index 42a109f..ea2d3db 100644 --- a/sets/ev3/home_bonus/dinor3x/.vscode/settings.json +++ b/sets/ev3/home_bonus/dinor3x/.vscode/settings.json @@ -3,5 +3,5 @@ "files.eol": "\n", "debug.openDebug": "neverOpen", "editor.rulers": [79], - "python.linting.enabled": true + "python.linting.flake8Enabled": true } diff --git a/sets/ev3/home_bonus/el3ctric_guitar/.vscode/settings.json b/sets/ev3/home_bonus/el3ctric_guitar/.vscode/settings.json index 42a109f..ea2d3db 100644 --- a/sets/ev3/home_bonus/el3ctric_guitar/.vscode/settings.json +++ b/sets/ev3/home_bonus/el3ctric_guitar/.vscode/settings.json @@ -3,5 +3,5 @@ "files.eol": "\n", "debug.openDebug": "neverOpen", "editor.rulers": [79], - "python.linting.enabled": true + "python.linting.flake8Enabled": true } diff --git a/sets/ev3/home_bonus/ev3_game/.vscode/settings.json b/sets/ev3/home_bonus/ev3_game/.vscode/settings.json index 42a109f..ea2d3db 100644 --- a/sets/ev3/home_bonus/ev3_game/.vscode/settings.json +++ b/sets/ev3/home_bonus/ev3_game/.vscode/settings.json @@ -3,5 +3,5 @@ "files.eol": "\n", "debug.openDebug": "neverOpen", "editor.rulers": [79], - "python.linting.enabled": true + "python.linting.flake8Enabled": true } diff --git a/sets/ev3/home_bonus/mr_b3am/.vscode/settings.json b/sets/ev3/home_bonus/mr_b3am/.vscode/settings.json index 42a109f..ea2d3db 100644 --- a/sets/ev3/home_bonus/mr_b3am/.vscode/settings.json +++ b/sets/ev3/home_bonus/mr_b3am/.vscode/settings.json @@ -3,5 +3,5 @@ "files.eol": "\n", "debug.openDebug": "neverOpen", "editor.rulers": [79], - "python.linting.enabled": true + "python.linting.flake8Enabled": true } diff --git a/sets/ev3/home_bonus/robodoz3r/.vscode/settings.json b/sets/ev3/home_bonus/robodoz3r/.vscode/settings.json index 42a109f..ea2d3db 100644 --- a/sets/ev3/home_bonus/robodoz3r/.vscode/settings.json +++ b/sets/ev3/home_bonus/robodoz3r/.vscode/settings.json @@ -3,5 +3,5 @@ "files.eol": "\n", "debug.openDebug": "neverOpen", "editor.rulers": [79], - "python.linting.enabled": true + "python.linting.flake8Enabled": true } diff --git a/sets/ev3/home_bonus/robodoz3r/rc_tank_util.py b/sets/ev3/home_bonus/robodoz3r/rc_tank_util.py index d16fd42..d0f7185 100644 --- a/sets/ev3/home_bonus/robodoz3r/rc_tank_util.py +++ b/sets/ev3/home_bonus/robodoz3r/rc_tank_util.py @@ -14,20 +14,20 @@ class RemoteControlledTank: left_motor_port: Port = Port.B, right_motor_port: Port = Port.C, polarity: str = 'normal', ir_sensor_port: Port = Port.S4, ir_beacon_channel: int = 1): - self.driver = \ - DriveBase( - left_motor=Motor(port=left_motor_port, - positive_direction= - Direction.CLOCKWISE - if polarity == 'normal' - else Direction.COUNTERCLOCKWISE), - right_motor=Motor(port=right_motor_port, - positive_direction= - Direction.CLOCKWISE - if polarity == 'normal' - else Direction.COUNTERCLOCKWISE), - wheel_diameter=wheel_diameter, - axle_track=axle_track) + if polarity == 'normal': + left_motor = Motor(port=left_motor_port, + positive_direction=Direction.CLOCKWISE) + right_motor = Motor(port=right_motor_port, + positive_direction=Direction.CLOCKWISE) + else: + left_motor = Motor(port=left_motor_port, + positive_direction=Direction.COUNTERCLOCKWISE) + right_motor = Motor(port=right_motor_port, + positive_direction=Direction.COUNTERCLOCKWISE) + self.driver = DriveBase(left_motor=left_motor, + right_motor=right_motor, + wheel_diameter=wheel_diameter, + axle_track=axle_track) self.ir_sensor = InfraredSensor(port=ir_sensor_port) self.ir_beacon_channel = ir_beacon_channel diff --git a/sets/ev3/home_bonus/sets_ev3_home_bonus.code-workspace b/sets/ev3/home_bonus/sets_ev3_home_bonus.code-workspace index 32620a4..426951a 100644 --- a/sets/ev3/home_bonus/sets_ev3_home_bonus.code-workspace +++ b/sets/ev3/home_bonus/sets_ev3_home_bonus.code-workspace @@ -1,5 +1,8 @@ { "folders": [ + { + "path": "bobb3e" + }, { "path": "dinor3x" }, @@ -11,8 +14,15 @@ }, { "path": "mr_b3am" + }, + { + "path": "robodoz3r" + }, + { + "path": "wack3m" } ], + "settings": { "debug.openDebug": "neverOpen" } diff --git a/sets/ev3/home_bonus/wack3m/.vscode/settings.json b/sets/ev3/home_bonus/wack3m/.vscode/settings.json index 42a109f..ea2d3db 100644 --- a/sets/ev3/home_bonus/wack3m/.vscode/settings.json +++ b/sets/ev3/home_bonus/wack3m/.vscode/settings.json @@ -3,5 +3,5 @@ "files.eol": "\n", "debug.openDebug": "neverOpen", "editor.rulers": [79], - "python.linting.enabled": true + "python.linting.flake8Enabled": true } diff --git a/sets/ev3/home_bonus/wack3m/wack3m.py b/sets/ev3/home_bonus/wack3m/wack3m.py index 7f70243..40bba6b 100644 --- a/sets/ev3/home_bonus/wack3m/wack3m.py +++ b/sets/ev3/home_bonus/wack3m/wack3m.py @@ -17,7 +17,7 @@ class Wack3m: middle_motor_port: str = Port.A, touch_sensor_port: str = Port.S1, ir_sensor_port: str = Port.S4): self.ev3_brick = EV3Brick() - + self.left_motor = Motor(port=left_motor_port, positive_direction=Direction.CLOCKWISE) self.right_motor = Motor(port=right_motor_port, @@ -167,10 +167,10 @@ class Wack3m: self.ev3_brick.screen.print( 'Avg. Time: {:.1f}s'.format(average_response_time)) - self.ev3_brick.speaker.play_file( - file=SoundFile.FANTASTIC - if average_response_time <= 1 - else SoundFile.GOOD_JOB) + if average_response_time <= 1: + self.ev3_brick.speaker.play_file(file=SoundFile.FANTASTIC) + else: + self.ev3_brick.speaker.play_file(SoundFile.GOOD_JOB) self.ev3_brick.speaker.play_file(file=SoundFile.GAME_OVER)