diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 8ee6e44..7ca3a1d 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -41,7 +41,7 @@ Examples of unacceptable behavior by participants include: The goal of the standards and moderation guidelines outlined here is to build and maintain a respectful community. We ask that you don’t just aim to be -"technically unimpeachable", but rather try to be your best self. +"technically unimpeachable", but rather try to be your best self. We value many things beyond technical expertise, including collaboration and supporting others within our community. Providing a positive experience for @@ -72,7 +72,7 @@ You may report in the following ways: In any situation, you may send an email to . On the Adafruit Discord, you may send an open message from any channel -to all Community Helpers by tagging @community helpers. You may also send an +to all Community Helpers by tagging @community moderators. You may also send an open message from any channel, or a direct message to @kattni#1507, @tannewt#4653, @Dan Halbert#1614, @cater#2442, @sommersoft#0222, or @Andon#8175. diff --git a/README.rst b/README.rst index 18c1870..1104b2d 100644 --- a/README.rst +++ b/README.rst @@ -29,27 +29,40 @@ Usage Example ============= .. code-block:: python - import adafruit_st7735 + import board - import busio import displayio - import time - - displayio.release_displays() + from adafruit_st7735 import ST7735 - spi = busio.SPI(board.SCL, board.SDA) - bus = displayio.FourWire(spi, chip_select=board.D9, command=board.D7, reset=board.D8) - display = adafruit_st7735.ST7735(bus, width=128, height=128) + spi = board.SPI() + tft_cs = board.D5 + tft_dc = board.D6 - s = displayio.Shape(10, 10) - p = displayio.Palette(2) - p[1] = 0xff0000 - s = displayio.Sprite(s, pixel_shader=p, position=(0,0)) - everything = displayio.Group(max_size=10) - everything.append(s) - display.show(everything) - - time.sleep(10) + displayio.release_displays() + display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9) + + display = ST7735(display_bus, width=128, height=128) + + # Make the display context + splash = displayio.Group(max_size=10) + display.show(splash) + + color_bitmap = displayio.Bitmap(128, 128, 1) + color_palette = displayio.Palette(1) + color_palette[0] = 0xFF0000 + + try: + bg_sprite = displayio.TileGrid(color_bitmap, + pixel_shader=color_palette, + position=(0, 0)) + except TypeError: + bg_sprite = displayio.TileGrid(color_bitmap, + pixel_shader=color_palette, + x=0, y=0) + splash.append(bg_sprite) + + while True: + pass Contributing ============ diff --git a/adafruit_st7735.py b/adafruit_st7735.py old mode 100644 new mode 100755 index beb0f04..9e9862c --- a/adafruit_st7735.py +++ b/adafruit_st7735.py @@ -1,6 +1,7 @@ # The MIT License (MIT) # -# Copyright (c) 2019 Scott Shawcroft for Adafruit Industries LLC +# Copyright (c) 2019 Scott Shawcroft and Melissa LeBlanc-Williams +# for Adafruit Industries LLC # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -20,21 +21,18 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. """ -`adafruit_ST7735` +`adafruit_st7735` ==================================================== Displayio driver for ST7735 based displays. -* Author(s): Scott Shawcroft +* Author(s): Melissa LeBlanc-Williams Implementation Notes -------------------- **Hardware:** -.. todo:: Add links to any specific hardware product page(s), or category page(s). Use unordered list & hyperlink rST - inline format: "* `Link Text `_" - **Software and Dependencies:** * Adafruit CircuitPython firmware for the supported boards: @@ -47,35 +45,28 @@ __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_ST7735.git" - _INIT_SEQUENCE = ( - b"\x01\x80\x96" # SWRESET - b"\x11\x80\xff" # SLPOUT - b"\xb1\x03\x01\x2C\x2D" # _FRMCTR1 - b"\xb2\x03\x01\x2C\x2D" # - b"\xb3\x06\x01\x2C\x2D\x01\x2C\x2D" - b"\xb4\x01\x07" # _INVCTR line inversion - b"\xc0\x03\xa2\x02\x84" # _PWCTR1 GVDD = 4.7V, 1.0uA - b"\xc1\x01\xc5" # _PWCTR2 VGH=14.7V, VGL=-7.35V - b"\xc2\x02\x0a\x00" # _PWCTR3 Opamp current small, Boost frequency - b"\xc3\x02\x8a\x2a" - b"\xc4\x02\x8a\xee" - b"\xc5\x01\x0e" # _VMCTR1 VCOMH = 4V, VOML = -1.1V - b"\x2a\x00" # _INVOFF - b"\x36\x01\x18" # _MADCTL bottom to top refresh - # 1 clk cycle nonoverlap, 2 cycle gate rise, 3 sycle osc equalie, - # fix on VTL - b"\x3a\x01\x05" # COLMOD - 16bit color - b"\xe0\x10\x02\x1c\x07\x12\x37\x32\x29\x2d\x29\x25\x2B\x39\x00\x01\x03\x10" # _GMCTRP1 Gamma - b"\xe1\x10\x03\x1d\x07\x06\x2E\x2C\x29\x2D\x2E\x2E\x37\x3F\x00\x00\x02\x10" # _GMCTRN1 - b"\x2a\x03\x02\x00\x81" # _CASET XSTART = 2, XEND = 129 - b"\x2b\x03\x02\x00\x81" # _RASET XSTART = 2, XEND = 129 + b"\x01\x80\x32" # _SWRESET and Delay 50ms + b"\x11\x80\xFF" # _SLPOUT + b"\x3A\x81\x05\x0A" # _COLMOD + b"\xB1\x83\x00\x06\x03\x0A" # _FRMCTR1 + b"\x36\x01\x08" # _MADCTL + b"\xB6\x02\x15\x02" # _DISSET5 + #1 clk cycle nonoverlap, 2 cycle gate, rise, 3 cycle osc equalize, Fix on VTL + b"\xB4\x01\x00" # _INVCTR line inversion + b"\xC0\x82\x02\x70\x0A" # _PWCTR1 GVDD = 4.7V, 1.0uA, 10 ms delay + b"\xC1\x01\x05" # _PWCTR2 VGH = 14.7V, VGL = -7.35V + b"\xC2\x02\x01\x02" # _PWCTR3 Opamp current small, Boost frequency + b"\xC5\x82\x3C\x38\x0A" # _VMCTR1 + b"\xFC\x02\x11\x15" # _PWCTR6 + b"\xE0\x10\x09\x16\x09\x20\x21\x1B\x13\x19\x17\x15\x1E\x2B\x04\x05\x02\x0E" # _GMCTRP1 Gamma + b"\xE1\x90\x0B\x14\x08\x1E\x22\x1D\x18\x1E\x1B\x1A\x24\x2B\x06\x06\x02\x0F\x0A" # _GMCTRN1 b"\x13\x80\x0a" # _NORON - b"\x29\x80\x64" # _DISPON + b"\x29\x80\xFF" # _DISPON ) +# pylint: disable=too-few-public-methods class ST7735(displayio.Display): - """ST7735 driver for ST7735R Green tabs""" - # TODO(tannewt): Add support for Red tabs and non-R chips. https://github.com/adafruit/Adafruit-ST7735-Library/blob/master/Adafruit_ST7735.cpp - def __init__(self, bus, *, width, height): - super().__init__(bus, _INIT_SEQUENCE, width=width, height=height, colstart=2) + """ST7735 driver""" + def __init__(self, bus, **kwargs): + super().__init__(bus, _INIT_SEQUENCE, **kwargs) diff --git a/docs/api.rst b/docs/api.rst index 1edfad7..c795cf6 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -5,4 +5,4 @@ .. use this format as the module name: "adafruit_foo.foo" .. automodule:: adafruit_st7735 - :members: + :members: diff --git a/docs/conf.py b/docs/conf.py index b453b45..49c0703 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -21,7 +21,7 @@ # digitalio, micropython and busio. List the modules you use. Without it, the # autodoc module docs will fail to generate with a warning. # autodoc_mock_imports = ["digitalio", "busio"] - +autodoc_mock_imports = ["displayio"] intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)} diff --git a/docs/index.rst b/docs/index.rst index b05cb7a..247238d 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -23,14 +23,14 @@ Table of Contents .. toctree:: :caption: Tutorials -.. todo:: Add any Learn guide links here. If there are none, then simply delete this todo and leave - the toctree above for use later. - .. toctree:: :caption: Related Products -.. todo:: Add any product links here. If there are none, then simply delete this todo and leave - the toctree above for use later. + 1.8" SPI TFT display, 160x128 18-bit color + Adafruit 0.96" 160x80 Color TFT Display w/ MicroSD Card Breakout + 1.8" Color TFT LCD display with MicroSD Card Breakout + Adafruit 1.44" Color TFT LCD Display with MicroSD Card breakout + Adafruit Mini Color TFT with Joystick FeatherWing .. toctree:: :caption: Other Links diff --git a/examples/st7735_simpletest.py b/examples/st7735_simpletest.py index 20d8b4a..9f0711b 100644 --- a/examples/st7735_simpletest.py +++ b/examples/st7735_simpletest.py @@ -1,21 +1,38 @@ -import adafruit_st7735 +""" +This test will initialize the display using displayio +and draw a solid red background +""" + import board -import busio import displayio -import time +from adafruit_st7735 import ST7735 + +spi = board.SPI() +tft_cs = board.D5 +tft_dc = board.D6 displayio.release_displays() +display_bus = displayio.FourWire(spi, command=tft_dc, chip_select=tft_cs, reset=board.D9) + +display = ST7735(display_bus, width=128, height=128) + +# Make the display context +splash = displayio.Group(max_size=10) +display.show(splash) -spi = busio.SPI(board.SCL, board.SDA) -bus = displayio.FourWire(spi, chip_select=board.D9, command=board.D7, reset=board.D8) -display = adafruit_st7735.ST7735(bus, width=128, height=128) +color_bitmap = displayio.Bitmap(128, 128, 1) +color_palette = displayio.Palette(1) +color_palette[0] = 0xFF0000 -s = displayio.Shape(10, 10) -p = displayio.Palette(2) -p[1] = 0xff0000 -s = displayio.Sprite(s, pixel_shader=p, position=(0,0)) -everything = displayio.Group(max_size=10) -everything.append(s) -display.show(everything) +try: + bg_sprite = displayio.TileGrid(color_bitmap, + pixel_shader=color_palette, + position=(0, 0)) +except TypeError: + bg_sprite = displayio.TileGrid(color_bitmap, + pixel_shader=color_palette, + x=0, y=0) +splash.append(bg_sprite) -time.sleep(10) +while True: + pass