|
| 1 | +# SPDX-FileCopyrightText: 2020 Melissa LeBlanc-Williams for Adafruit Industries |
| 2 | +# SPDX-FileCopyrightText: 2020 Foamyguy for Adafruit Industries |
| 3 | +# |
| 4 | +# SPDX-License-Identifier: MIT |
| 5 | + |
| 6 | +""" |
| 7 | +`adafruit_featherwing.tft_featherwing_35` |
| 8 | +==================================================== |
| 9 | +
|
| 10 | +Helper for using the `TFT FeatherWing 3.5"` |
| 11 | +<https://www.adafruit.com/product/3651>`_. |
| 12 | +
|
| 13 | +* Author(s): Melissa LeBlanc-Williams, Foamyguy |
| 14 | +
|
| 15 | +Requires: |
| 16 | +* adafruit_hx8357 |
| 17 | +* adafruit_stmpe610 |
| 18 | +""" |
| 19 | + |
| 20 | +__version__ = "0.0.0-auto.0" |
| 21 | +__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_FeatherWing.git" |
| 22 | + |
| 23 | +import board |
| 24 | +import digitalio |
| 25 | +import displayio |
| 26 | +from adafruit_hx8357 import HX8357 |
| 27 | +from adafruit_stmpe610 import Adafruit_STMPE610_SPI |
| 28 | +import sdcardio |
| 29 | +import storage |
| 30 | + |
| 31 | +# pylint: disable-msg=too-few-public-methods |
| 32 | +class TFTFeatherWing35: |
| 33 | + """Class representing an `TFT FeatherWing 3.5 |
| 34 | + <https://www.adafruit.com/product/3651>`_. |
| 35 | +
|
| 36 | + """ |
| 37 | + |
| 38 | + def __init__(self, spi=None, cs=None, dc=None): |
| 39 | + displayio.release_displays() |
| 40 | + if spi is None: |
| 41 | + spi = board.SPI() |
| 42 | + if cs is None: |
| 43 | + cs = board.D9 |
| 44 | + if dc is None: |
| 45 | + dc = board.D10 |
| 46 | + |
| 47 | + ts_cs = digitalio.DigitalInOut(board.D6) |
| 48 | + self.touchscreen = Adafruit_STMPE610_SPI(spi, ts_cs) |
| 49 | + |
| 50 | + display_bus = displayio.FourWire(spi, command=dc, chip_select=cs) |
| 51 | + self.display = HX8357(display_bus, width=480, height=320) |
| 52 | + |
| 53 | + sd_cs = board.D5 |
| 54 | + self._sdcard = None |
| 55 | + try: |
| 56 | + self._sdcard = sdcardio.SDCard(spi, sd_cs) |
| 57 | + vfs = storage.VfsFat(self._sdcard) |
| 58 | + storage.mount(vfs, "/sd") |
| 59 | + except OSError as error: |
| 60 | + print("No SD card found:", error) |
0 commit comments