forked from cskau/Python_ST7735
-
Notifications
You must be signed in to change notification settings - Fork 29
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
7 changed files
with
72 additions
and
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
from tools import force_reimport | ||
|
||
|
||
def test_128_64_0(GPIO, spidev, numpy): | ||
force_reimport('ST7735') | ||
import ST7735 | ||
def test_128_64_0(GPIO, 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 | ||
display.set_window(0, 0) | ||
|
||
|
||
def test_128_64_90(GPIO, spidev, numpy): | ||
force_reimport('ST7735') | ||
import ST7735 | ||
def test_128_64_90(GPIO, 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 | ||
display.set_window(0, 0) | ||
|
||
|
||
def test_128_64_180(GPIO, spidev, numpy, ST7735): | ||
display = ST7735.ST7735(port=0, cs=0, dc=24, width=128, height=64, rotation=180) | ||
assert display.width == 128 | ||
assert display.height == 64 | ||
display.set_window(0, 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,25 +1,53 @@ | ||
import mock | ||
from tools import force_reimport | ||
|
||
|
||
def test_display(GPIO, spidev, numpy): | ||
force_reimport('ST7735') | ||
import ST7735 | ||
def test_display(GPIO, 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()) | ||
image = mock.MagicMock() | ||
image.convert.return_value = [ | ||
[255, 0, 0], | ||
[0, 255, 0], | ||
[0, 0, 255] | ||
] | ||
spidev.reset_mock() | ||
display.display(image) | ||
|
||
spidev.SpiDev().xfer3.assert_called_with([0xff, 0x00, 0xff, 0x00]) | ||
spidev.SpiDev().xfer3.assert_has_calls( | ||
(mock.call([0xf8, 0x00, 0x07, 0xe0, 0x00, 0x1f]),) | ||
) | ||
|
||
|
||
def test_color565(GPIO, spidev, numpy): | ||
force_reimport('ST7735') | ||
import ST7735 | ||
assert ST7735.color565(255, 255, 255) == 0xFFFF | ||
def test_image_to_data_uint8(GPIO, spidev, numpy, ST7735): | ||
display = ST7735.ST7735(port=0, cs=0, dc=24) | ||
image = numpy.array([ | ||
[255, 0, 0], | ||
[0, 255, 0], | ||
[0, 0, 255] | ||
]) | ||
spidev.reset_mock() | ||
display.display(image) | ||
|
||
spidev.SpiDev().xfer3.assert_has_calls( | ||
(mock.call([0xf8, 0x00, 0x07, 0xe0, 0x00, 0x1f]),) | ||
) | ||
|
||
|
||
def test_image_to_data_uint16(GPIO, spidev, numpy, ST7735): | ||
display = ST7735.ST7735(port=0, cs=0, dc=24) | ||
image = numpy.array([ | ||
[255, 0, 0], | ||
[0, 255, 0], | ||
[0, 0, 255] | ||
], dtype='uint16') | ||
spidev.reset_mock() | ||
display.display(image) | ||
|
||
spidev.SpiDev().xfer3.assert_has_calls( | ||
(mock.call([0xf8, 0x00, 0x07, 0xe0, 0x00, 0x1f]),) | ||
) | ||
|
||
|
||
def test_image_to_data(GPIO, spidev, numpy): | ||
force_reimport('ST7735') | ||
numpy.dstack().flatten().tolist.return_value = [] | ||
import ST7735 | ||
assert ST7735.image_to_data(mock.MagicMock()) == [] | ||
def test_image_to_data(GPIO, spidev, numpy, ST7735): | ||
image = mock.MagicMock() | ||
image.convert.return_value = [255, 0, 255] | ||
assert ST7735.image_to_data(image) == b"\xf8\x1f" |
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 was deleted.
Oops, something went wrong.
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