-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
114 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
import time | ||
from drv8830 import DRV8830, I2C_ADDR1, I2C_ADDR2 | ||
|
||
|
||
left = DRV8830(I2C_ADDR1) | ||
right = DRV8830(I2C_ADDR2) | ||
|
||
# Move forward | ||
left.forward() | ||
right.forward() | ||
time.sleep(1.0) | ||
|
||
# Turn left | ||
left.reverse() | ||
right.forward() | ||
time.sleep(1.0) | ||
|
||
# Turn right | ||
left.forward() | ||
right.reverse() | ||
time.sleep(1.0) | ||
|
||
# Move backward | ||
left.reverse() | ||
right.reverse() | ||
time.sleep(1.0) | ||
|
||
# Coast to a stop | ||
left.coast() | ||
right.coast() | ||
import time | ||
from drv8830 import DRV8830, I2C_ADDR1, I2C_ADDR2 | ||
|
||
|
||
left = DRV8830(I2C_ADDR1) | ||
right = DRV8830(I2C_ADDR2) | ||
|
||
# Move forward | ||
left.forward() | ||
right.forward() | ||
time.sleep(1.0) | ||
|
||
# Turn left | ||
left.reverse() | ||
right.forward() | ||
time.sleep(1.0) | ||
|
||
# Turn right | ||
left.forward() | ||
right.reverse() | ||
time.sleep(1.0) | ||
|
||
# Move backward | ||
left.reverse() | ||
right.reverse() | ||
time.sleep(1.0) | ||
|
||
# Coast to a stop | ||
left.coast() | ||
right.coast() | ||
time.sleep(1.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,65 @@ | ||
from i2cdevice import MockSMBus | ||
|
||
|
||
def test_forward(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.forward() | ||
|
||
|
||
def test_reverse(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.reverse() | ||
|
||
|
||
def test_brake(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.brake() | ||
|
||
|
||
def test_coast(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.coast() | ||
|
||
|
||
def test_set_outputs(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.set_outputs(out1=0, out2=0) | ||
|
||
|
||
def test_set_voltage(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.set_voltage(5.06) | ||
assert drv8830.get_voltage() == 5.06 | ||
|
||
|
||
def test_set_voltage_snap(): | ||
# Should snap to the nearest available voltage and read back correctly | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.set_voltage(0.82) | ||
assert drv8830.get_voltage() == 0.80 | ||
|
||
|
||
def test_voltage_out_of_range(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.set_voltage(0) | ||
assert drv8830.get_voltage() == 0 | ||
|
||
|
||
def test_get_fault(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
assert drv8830.get_fault().current_limit == 0 | ||
|
||
|
||
def test_clear_fault(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.clear_fault() | ||
from i2cdevice import MockSMBus | ||
|
||
|
||
def test_forward(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.forward() | ||
|
||
|
||
def test_reverse(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.reverse() | ||
|
||
|
||
def test_brake(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.brake() | ||
|
||
|
||
def test_coast(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.coast() | ||
|
||
|
||
def test_set_outputs(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.set_outputs(out1=0, out2=0) | ||
|
||
|
||
def test_set_voltage(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.set_voltage(5.06) | ||
assert drv8830.get_voltage() == 5.06 | ||
|
||
|
||
def test_set_voltage_snap(): | ||
# Should snap to the nearest available voltage and read back correctly | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.set_voltage(0.82) | ||
assert drv8830.get_voltage() == 0.80 | ||
|
||
|
||
def test_voltage_out_of_range(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.set_voltage(0) | ||
assert drv8830.get_voltage() == 0 | ||
|
||
|
||
def test_get_fault(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
assert drv8830.get_fault().current_limit == 0 | ||
|
||
|
||
def test_clear_fault(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.clear_fault() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
from i2cdevice import MockSMBus | ||
|
||
|
||
def test_setup(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
del drv8830 | ||
|
||
|
||
def test_setup_alt_addr2(): | ||
from drv8830 import DRV8830, I2C_ADDR2 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1), i2c_addr=I2C_ADDR2) | ||
del drv8830 | ||
|
||
|
||
def test_setup_alt_addr3(): | ||
from drv8830 import DRV8830, I2C_ADDR3 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.select_i2c_address(I2C_ADDR3) | ||
from i2cdevice import MockSMBus | ||
|
||
|
||
def test_setup(): | ||
from drv8830 import DRV8830 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
del drv8830 | ||
|
||
|
||
def test_setup_alt_addr2(): | ||
from drv8830 import DRV8830, I2C_ADDR2 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1), i2c_addr=I2C_ADDR2) | ||
del drv8830 | ||
|
||
|
||
def test_setup_alt_addr3(): | ||
from drv8830 import DRV8830, I2C_ADDR3 | ||
drv8830 = DRV8830(i2c_dev=MockSMBus(1)) | ||
drv8830.select_i2c_address(I2C_ADDR3) |