Adafruit 2.
Overview This gorgeous IPS display breakout is the best way to add a small, colorful and bright display to any project, with excellent visibility from any angle. Since the display uses 4-wire SPI to communicate and has its own pixel-addressable frame buffer, it can be used with every kind of microcontroller. Even a very small one with low memory and few pins available! The 2.0" display has 320x240 color pixels.
color and high-angle visibility. The TFT driver (ST7789) can display full 18-bit color (262,144 shades), but almost all drivers will use just 16-bit color. The TFT will always come with the same driver chip so there's no worries that your code will not work from one to the other. The breakout has the TFT display soldered on (it uses a delicate flex-circuit connector) as well as a ultra-low-dropout 3.3V regulator, auto-reset circuitry, and a 3/5V level shifter so you can use it with 3.
library that can draw pixels, lines, rectangles, circles, text and bitmaps as well as example code (https://adafru.it/d4d). The code is written for Arduino but can be easily ported to your favorite microcontroller! Wiring is easy, we strongly encourage using the hardware SPI pins of your Arduino as software SPI is noticeably slower when dealing with this size display. © Adafruit Industries https://learn.adafruit.
Pinouts This color display uses SPI to receive image data. That means you need at least 4 pins - clock, data in, tft cs and d/c. If you'd like to have SD card usage too, add another 2 pins - data out and card cs. However, there's a couple other pins you may want to use, lets go thru them all! 3-5V / Vin - this is the power pin, connect to 3-5VDC - it has reverse polarity protection but try to wire it right! 3Vo - this is the 3.
Arduino Wiring & Test Basic Graphics Test Wiring Wiring up the display in SPI mode is pretty easy as there are not that many pins! We'll be using hardware SPI, but you can also use software SPI (any pins) later. Start by connecting the power pins 3-5V Vin connects to the microcontroller 5V pin GND connects to Arduino ground SCK connects to SPI clock. On Arduino Uno/Duemilanove/328-based, thats Digital 13.
https://adafru.it/FvT https://adafru.it/FvT Install Arduino Libraries We have example code ready to go for use with these TFTs. It's written for Arduino, which should be portable to any microcontroller by adapting the C++ source. Five libraries need to be installed using the Arduino Library Manager…this is the preferred and modern way.
Repeat the search and install steps, looking for the Adafruit Zero DMA, Adafruit ST7735 and ST7789, Adafruit SPIFlash, and SdFat - Adafruit Fork libraries. After restarting the Arduino software, you should see a new example folder called Adafruit_ST7735, and inside, an example called graphicstest. Since this example is written for several displays, there are two changes we need to make in order to use it with the 2.0" display. First, in the graphicstest source code, look for the lines as follows: // For 1.
// For 1.44" and 1.8" TFT with ST7735 (including HalloWing) use: //Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); // For 1.3", 1.54", and 2.0" TFT with ST7789: Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST); Second, we need to set the correct initializations sequence. In the graphicstest source code, look for the lines as follows: // Use this initializer if using a 1.8" TFT screen: tft.
Changing Pins Now that you have it working, there's a few things you can do to change around the pins. If you're using Hardware SPI, the CLOCK and MOSI pins are 'fixed' and can't be changed. But you can change to software SPI, which is a bit slower, and that lets you pick any pins you like. Find these lines: © Adafruit Industries https://learn.adafruit.
// // // // OPTION 1 (recommended) is to use the HARDWARE SPI pins, which are unique to each board and not reassignable. For Arduino Uno: MOSI = pin 11 and SCLK = pin 13. This is the fastest mode of operation and is required if using the breakout board's microSD card. #if defined(ADAFRUIT_PYBADGE_M4_EXPRESS) || defined(ADAFRUIT_PYGAMER_M4_EXPRESS) // For PyBadge and PyGamer Adafruit_ST7735 tft = Adafruit_ST7735(&SPI1, TFT_CS, TFT_DC, TFT_RST); #else // For 1.44" and 1.
Adafruit GFX library The Adafruit_GFX library for Arduino provides a common syntax and set of graphics functions for all of our TFT, LCD and OLED displays. This allows Arduino sketches to easily be adapted between display types with minimal fuss…and any new features, performance improvements and bug fixes will immediately apply across our complete offering of color displays. The GFX library is what lets you draw points, lines, rectangles, round-rects, triangles, text, etc.
Check out our detailed tutorial here http://learn.adafruit.com/adafruit-gfx-graphics-library (https://adafru.it/aPx) It covers the latest and greatest of the GFX library! © Adafruit Industries https://learn.adafruit.
Drawing Bitmaps There is a built in microSD card slot into the breakout, and we can use that to load bitmap images! You will need a microSD card formatted FAT16 or FAT32 (they almost always are by default). It's really easy to draw bitmaps! Let's start by downloading this image of purple flowers Copy purple.bmp into the base directory of a microSD card and insert it into the microSD socket in the breakout.
https://adafru.it/FvV https://adafru.it/FvV You may want to try the SD library examples before continuing, especially one that lists all the files on the SD card Open the File→examples→Adafruit ImageReader Library→BreakoutST7789 - 320x240 example: Now upload the example sketch to the Arduino. You should see purple flowers appear! If you have any problems, check the serial console for any messages such as not being able to initialize the microSD card or not finding the image.
To make new bitmaps, make sure they are less than 320 by 240 pixels and save them in 24-bit BMP format! They must be in 24-bit format, even if they are not 24-bit color as that is the easiest format for the Arduino. You can rotate images using the setRotation() procedure You can draw as many images as you want - don't forget the names must be less than 8 characters long. Just copy the BMP drawing routines below loop() and call bmpDraw(bmpfilename, x, y); For each bitmap.
CircuitPython Displayio Quickstart You will need a board capable of running CircuitPython such as the Metro M0 Express or the Metro M4 Express. You can also use boards such as the Feather M0 Express or the Feather M4 Express. We recommend either the Metro M4 or the Feather M4 Express because it's much faster and works better for driving a display. For this guide, we will be using a Feather M4 Express. The steps should be about the same for the Feather M0 Express or either of the Metros.
https://adafru.it/FiA https://adafru.it/FiA Go ahead and install this in the same manner as the driver library by copying the adafruit_display_text folder over to the lib folder on your CircuitPython device. CircuitPython Code Example © Adafruit Industries https://learn.adafruit.
""" This test will initialize the display using displayio and draw a solid green background, a smaller purple rectangle, and some yellow text. """ import board import displayio import terminalio from adafruit_display_text import label from adafruit_st7789 import ST7789 spi = board.SPI() while not spi.try_lock(): pass spi.configure(baudrate=24000000) # Configure SPI for 24MHz spi.unlock() tft_cs = board.D5 tft_dc = board.D6 displayio.release_displays() display_bus = displayio.
import board import displayio import terminalio from adafruit_display_text import label from adafruit_st7789 import ST7789 Next, we set the SPI object to the board's SPI with the easy shortcut function board.SPI() . By using this function, it finds the SPI module and initializes using the default SPI parameters. For the ST7789, because this is a nice zippy display, we'll change the baud rate to 24MHz. In order to do that, first we enter a loop until we can lock the SPI bus for our exclusive use.
Next we create a background splash image. We do this by creating a group that we can add elements to and adding that group to the display. In this example, we are limiting the maximum number of elements to 10, but this can be increased if you would like. The display will automatically handle updating the group. splash = displayio.Group(max_size=10) display.show(splash) Next we create a Bitmap which is like a canvas that we can draw on.
Next we will create a smaller purple square. The easiest way to do this is the create a new bitmap that is a little smaller than the full screen with a single color and place it in a specific location. In this case we will create a bitmap that is 20 pixels smaller on each side. The screen is 320x240, so we'll want to subtract 40 from each of those numbers. We'll also want to place it at the position (20, 20) so that it ends up centered. inner_bitmap = displayio.Bitmap(280, 200, 1) inner_palette = displayio.
Next let's add a label that says "Hello World!" on top of that. We're going to use the built-in Terminal Font and scale it up by a factor of three. To scale the label only, we will make use of a subgroup, which we will then add to the main group. Labels are centered vertically, so we'll place it at 120 for the Y coordinate, and around 57 pixels make it appear to be centered horizontally, but if you want to change the text, change this to whatever looks good to you.
Downloads Files 2.0" display EagleCAD files on GitHub (https://adafru.it/FvO) 2.0" display Fritzing object in the Adafruit Fritzing Library (https://adafru.it/FvP) Fab Print Schematic © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
© Adafruit Industries Last Updated: 2019-08-15 06:43:09 PM UTC Page 27 of 27