|
| 1 | +# The MIT License (MIT) |
| 2 | +# |
| 3 | +# Copyright (c) 2020 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.keyboard_featherwing` |
| 24 | +==================================================== |
| 25 | +
|
| 26 | +Helper for using the `Keyboard Featherwing` |
| 27 | +<https://www.tindie.com/products/arturo182/keyboard-featherwing-qwerty-keyboard-26-lcd/>`_. |
| 28 | +
|
| 29 | +* Author(s): 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 | +from bbq10keyboard import BBQ10Keyboard |
| 47 | +import neopixel |
| 48 | + |
| 49 | + |
| 50 | +# pylint: disable-msg=too-few-public-methods |
| 51 | +class KeyboardFeatherwing: |
| 52 | + """Class representing a `Keyboard Featherwing` |
| 53 | + <https://www.tindie.com/products/arturo182/keyboard-featherwing-qwerty-keyboard-26-lcd/>`_. |
| 54 | +
|
| 55 | + """ |
| 56 | + |
| 57 | + def __init__(self, spi=None, cs=None, dc=None, i2c=None): |
| 58 | + displayio.release_displays() |
| 59 | + if spi is None: |
| 60 | + spi = board.SPI() |
| 61 | + if cs is None: |
| 62 | + cs = board.D9 |
| 63 | + if dc is None: |
| 64 | + dc = board.D10 |
| 65 | + if i2c is None: |
| 66 | + i2c = board.I2C() |
| 67 | + |
| 68 | + ts_cs = digitalio.DigitalInOut(board.D6) |
| 69 | + self.touchscreen = Adafruit_STMPE610_SPI(spi, ts_cs) |
| 70 | + |
| 71 | + display_bus = displayio.FourWire(spi, command=dc, chip_select=cs) |
| 72 | + self.display = adafruit_ili9341.ILI9341(display_bus, width=320, height=240) |
| 73 | + self.neopixel = neopixel.NeoPixel(board.D11, 1) |
| 74 | + self.keyboard = BBQ10Keyboard(i2c) |
| 75 | + sd_cs = board.D5 |
| 76 | + self._sdcard = None |
| 77 | + try: |
| 78 | + self._sdcard = sdcardio.SDCard(spi, sd_cs) |
| 79 | + vfs = storage.VfsFat(self._sdcard) |
| 80 | + storage.mount(vfs, "/sd") |
| 81 | + except OSError as error: |
| 82 | + print("No SD card found:", error) |
0 commit comments