forked from cskau/Python_ST7735
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
10 changed files
with
85 additions
and
83 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
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
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
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
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
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
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
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,10 +1,10 @@ | ||
def test_128_64_0(GPIO, spidev, numpy, st7735): | ||
def test_128_64_0(gpiodevice, gpiod, spidev, numpy, st7735): | ||
display = st7735.ST7735(port=0, cs=0, dc=24, width=128, height=64, rotation=0) | ||
assert display.width == 128 | ||
assert display.height == 64 | ||
|
||
|
||
def test_128_64_90(GPIO, spidev, numpy, st7735): | ||
def test_128_64_90(gpiodevice, gpiod, spidev, numpy, st7735): | ||
display = st7735.ST7735(port=0, cs=0, dc=24, width=128, height=64, rotation=90) | ||
assert display.width == 64 | ||
assert display.height == 128 |
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,18 +1,18 @@ | ||
import mock | ||
|
||
|
||
def test_display(GPIO, spidev, numpy, st7735): | ||
def test_display(gpiodevice, gpiod, spidev, numpy, st7735): | ||
display = st7735.ST7735(port=0, cs=0, dc=24) | ||
numpy.dstack().flatten().tolist.return_value = [0xff, 0x00, 0xff, 0x00] | ||
display.display(mock.MagicMock()) | ||
|
||
spidev.SpiDev().xfer3.assert_called_with([0xff, 0x00, 0xff, 0x00]) | ||
|
||
|
||
def test_color565(GPIO, spidev, numpy, st7735): | ||
def test_color565(gpiodevice, gpiod, spidev, numpy, st7735): | ||
assert st7735.color565(255, 255, 255) == 0xFFFF | ||
|
||
|
||
def test_image_to_data(GPIO, spidev, numpy, st7735): | ||
def test_image_to_data(gpiodevice, gpiod, spidev, numpy, st7735): | ||
numpy.dstack().flatten().tolist.return_value = [] | ||
assert st7735.image_to_data(mock.MagicMock()) == [] |
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,38 +1,31 @@ | ||
import mock | ||
|
||
|
||
def test_setup(GPIO, spidev, numpy, st7735): | ||
display = st7735.ST7735(port=0, cs=0, dc=24) | ||
del display | ||
def test_setup(gpiodevice, gpiod, spidev, numpy, st7735): | ||
_ = st7735.ST7735(port=0, cs=0, dc="GPIO24") | ||
|
||
GPIO.output.assert_has_calls([ | ||
mock.call(24, True), | ||
mock.call(24, False) | ||
gpiodevice.get_pin.assert_has_calls([ | ||
mock.call("GPIO24", "st7735-dc", st7735.OUTL) | ||
], any_order=True) | ||
|
||
|
||
def test_setup_no_invert(GPIO, spidev, numpy, st7735): | ||
display = st7735.ST7735(port=0, cs=0, dc=24, invert=False) | ||
del display | ||
def test_setup_no_invert(gpiodevice, gpiod, spidev, numpy, st7735): | ||
_ = st7735.ST7735(port=0, cs=0, dc="GPIO24", invert=False) | ||
|
||
|
||
def test_setup_with_backlight(GPIO, spidev, numpy, st7735): | ||
display = st7735.ST7735(port=0, cs=0, dc=24, backlight=4) | ||
GPIO.setup.assert_called_with(4, GPIO.OUT) | ||
def test_setup_with_backlight(gpiodevice, gpiod, spidev, numpy, st7735): | ||
display = st7735.ST7735(port=0, cs=0, dc="GPIO24", backlight="GPIO4") | ||
|
||
display.set_backlight(GPIO.HIGH) | ||
display.set_backlight(True) | ||
|
||
GPIO.output.assert_has_calls([ | ||
mock.call(4, GPIO.LOW), | ||
mock.call(4, GPIO.HIGH), | ||
# Dozens of falls with True/False here | ||
# due to _init() being called and the display | ||
# setup setting the command/data pin | ||
mock.call(4, GPIO.HIGH) | ||
gpiodevice.get_pin.assert_has_calls([ | ||
mock.call("GPIO4", "st7735-bl", st7735.OUTL) | ||
], any_order=True) | ||
|
||
|
||
def test_setup_with_reset(GPIO, spidev, numpy, st7735): | ||
display = st7735.ST7735(port=0, cs=0, dc=24, rst=4) | ||
GPIO.setup.assert_called_with(4, GPIO.OUT) | ||
del display | ||
def test_setup_with_reset(gpiodevice, gpiod, spidev, numpy, st7735): | ||
_ = st7735.ST7735(port=0, cs=0, dc=24, rst="GPIO4") | ||
|
||
gpiodevice.get_pin.assert_has_calls([ | ||
mock.call("GPIO4", "st7735-rst", st7735.OUTL) | ||
], any_order=True) |