|
| 1 | +# The MIT License (MIT) |
| 2 | +# |
| 3 | +# Copyright (c) 2020 Melissa LeBlanc-Williams, Foamyguy for Adafruit Industries LLC |
| 4 | +# |
| 5 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | +# of this software and associated documentation files (the "Software"), to deal |
| 7 | +# in the Software without restriction, including without limitation the rights |
| 8 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 | +# copies of the Software, and to permit persons to whom the Software is |
| 10 | +# furnished to do so, subject to the following conditions: |
| 11 | +# |
| 12 | +# The above copyright notice and this permission notice shall be included in |
| 13 | +# all copies or substantial portions of the Software. |
| 14 | +# |
| 15 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 21 | +# THE SOFTWARE. |
| 22 | +""" |
| 23 | +`adafruit_featherwing.tft_featherwing_24` |
| 24 | +==================================================== |
| 25 | +
|
| 26 | +Helper for using the `TFT FeatherWing 2.4"` |
| 27 | +<https://www.adafruit.com/product/3315>`_. |
| 28 | +
|
| 29 | +* Author(s): Melissa LeBlanc-Williams, Foamyguy |
| 30 | +
|
| 31 | +Requires: |
| 32 | +* adafruit_ili9341 |
| 33 | +* adafruit_stmpe610 |
| 34 | +""" |
| 35 | + |
| 36 | +__version__ = "0.0.0-auto.0" |
| 37 | +__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git" |
| 38 | + |
| 39 | +import board |
| 40 | +import digitalio |
| 41 | +import displayio |
| 42 | +import adafruit_ili9341 |
| 43 | +from adafruit_stmpe610 import Adafruit_STMPE610_SPI |
| 44 | +import sdcardio |
| 45 | +import storage |
| 46 | + |
| 47 | +# pylint: disable-msg=too-few-public-methods |
| 48 | +class TFTFeatherWing24: |
| 49 | + """Class representing an `TFT FeatherWing 2.4 |
| 50 | + <https://www.adafruit.com/product/3315>`_. |
| 51 | +
|
| 52 | + """ |
| 53 | + |
| 54 | + def __init__(self, spi=None, cs=None, dc=None): |
| 55 | + displayio.release_displays() |
| 56 | + if spi is None: |
| 57 | + spi = board.SPI() |
| 58 | + if cs is None: |
| 59 | + cs = board.D9 |
| 60 | + if dc is None: |
| 61 | + dc = board.D10 |
| 62 | + |
| 63 | + ts_cs = digitalio.DigitalInOut(board.D6) |
| 64 | + self.touchscreen = Adafruit_STMPE610_SPI(spi, ts_cs) |
| 65 | + |
| 66 | + display_bus = displayio.FourWire(spi, command=dc, chip_select=cs) |
| 67 | + self.display = adafruit_ili9341.ILI9341(display_bus, width=320, height=240) |
| 68 | + |
| 69 | + sd_cs = board.D5 |
| 70 | + self._sdcard = None |
| 71 | + try: |
| 72 | + self._sdcard = sdcardio.SDCard(spi, sd_cs) |
| 73 | + vfs = storage.VfsFat(self._sdcard) |
| 74 | + storage.mount(vfs, "/sd") |
| 75 | + except OSError as error: |
| 76 | + print("No SD card found:", error) |
0 commit comments