Skip to content

Fixing imports and adding Encoder printouts to the ivp #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"reportMissingModuleSource": "none"
},
"python.analysis.extraPaths": [
"c:\\Users\\origi\\.vscode\\extensions\\joedevivo.vscode-circuitpython-0.1.19-win32-x64\\boards\\0x2E8A\\0x1000",
"c:\\Users\\origi\\.vscode\\extensions\\joedevivo.vscode-circuitpython-0.1.19-win32-x64\\stubs",
"c:\\Users\\origi\\AppData\\Roaming\\Code\\User\\globalStorage\\joedevivo.vscode-circuitpython\\bundle\\20221208\\adafruit-circuitpython-bundle-py-20221208\\lib"
"c:\\Users\\origi\\.vscode\\extensions\\joedevivo.vscode-circuitpython-0.1.20-win32-x64\\boards\\0x2E8A\\0x1000",
"c:\\Users\\origi\\.vscode\\extensions\\joedevivo.vscode-circuitpython-0.1.20-win32-x64\\stubs",
"c:\\Users\\origi\\AppData\\Roaming\\Code\\User\\globalStorage\\joedevivo.vscode-circuitpython\\bundle\\20230330\\adafruit-circuitpython-bundle-py-20230330\\lib"
],
"circuitpython.board.version": "7.1.0",
"circuitpython.board.vid": "0x2E8A",
Expand Down
14 changes: 10 additions & 4 deletions SampleCode/sample_miscellaneous.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ def test_leds():
while brightness > 0:
led.set_brightness(brightness)
led.set_color(255,0,0)
time.sleep(0.5)
time.sleep(0.33)
led.set_color(0,255,0)
time.sleep(0.5)
time.sleep(0.33)
led.set_color(0,0,255)
time.sleep(0.5)
brightness -= 0.25
time.sleep(0.33)
brightness -= 0.5
led.set_color(0,0,0)
led.set_brightness(0)

Expand All @@ -51,17 +51,23 @@ def ivp():
print(f"Left Reflectance: {reflectance.get_left()}, Right Reflectance: {reflectance.get_right()}")
time.sleep(0.1)
while (buttons.is_GP20_pressed() or buttons.is_GP21_pressed()):
# Wait until user to release button before continuing
time.sleep(.01)
while not buttons.is_GP20_pressed() and not buttons.is_GP21_pressed():
print(f"Ultrasonic Distance: {sonar.get_distance()}")
time.sleep(0.1)
while (buttons.is_GP20_pressed() or buttons.is_GP21_pressed()):
# Wait until user to release button before continuing
time.sleep(.01)
print("Testing Servo")
test_servo()
print("Testing LEDs")
wait_for_button()
test_leds()
print("Testing Motor Encoders:")
while not buttons.is_GP20_pressed() and not buttons.is_GP21_pressed():
print(f"Left: {drivetrain.get_left_encoder_position()}, Right: {drivetrain.get_right_encoder_position()}")
time.sleep(0.1)
print("Testing Drivetrain:")
wait_for_button()
test_drive()
14 changes: 7 additions & 7 deletions WPILib/WPILib.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import board as _board
from _drivetrain import Drivetrain
from _encoded_motor import EncodedMotor
from _ultrasonic_wrapper import Ultrasonic
from _reflectance_wrapper import Reflectance
from _servo import Servo
from _buttons import Buttons
from _led import RGBLED
from ._drivetrain import Drivetrain
from ._ultrasonic_wrapper import Ultrasonic
from ._reflectance_wrapper import Reflectance
from ._servo import Servo
from ._buttons import Buttons
from ._encoded_motor import EncodedMotor
from ._led import RGBLED

import time

Expand Down
8 changes: 6 additions & 2 deletions code.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
from SampleCode.sample_miscellaneous import *
from SampleCode.sample_sensor_access import *

ivp()

def main():
#
# Your Code Here!
#
ivp()
main()