User Tools

Site Tools


arduino:displays_for_classic_arduinos:1.8_and_1.44_tft_displays_and_classic_arduinos

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
arduino:displays_for_classic_arduinos:1.8_and_1.44_tft_displays_and_classic_arduinos [2018/01/28 00:40] – [Summary opinion] mithatarduino:displays_for_classic_arduinos:1.8_and_1.44_tft_displays_and_classic_arduinos [2018/01/31 04:55] (current) – [Ucglib] mithat
Line 1: Line 1:
-====== 1.8" and 1.44" TFT Displays and Classic Arduinos ======+====== 1.8" and 1.44" TFT displays and classic Arduinos ======
  
 ===== Summary evaluation ===== ===== Summary evaluation =====
  
-Small 1.8" (160x128) and 1.44" (128x128) TFT displays with ST7735 controllers have been available for a while now. They are only slightly more expensive than the very inexpensive [[arduino:displays_for_classic_arduinos:nokia_5110_displays_and_classic_arduinos|Nokia 5110]], and are about the same size, though with greater resolution.+Small 1.8" (160x128) and 1.44" (128x128) TFT displays with ST7735 controllers have been [[https://www.ebay.com/sch/i.html?_odkw=1.8%22+tft+ST7735&_osacat=0&_from=R40&_trksid=p2045573.m570.l1313.TR0.TRC0.H0.X1.8%22+tft+display+ST7735.TRS0&_nkw=1.8%22+tft+display+ST7735&_sacat=0|available]] from Asian suppliers for a while now. They are only slightly more expensive than the very inexpensive [[arduino:displays_for_classic_arduinos:nokia_5110_displays_and_classic_arduinos|Nokia 5110]], and are about the same physical size but offer color and greater DPI.
  
-One of the concerns with with TFT displays is that they are data gluttons, meaning they put a lot of stress on piddly Uno/Nano/Pro Minis with regards to memory consumption, processing time, and data transfer time. However, it's not unreasonable to hope that a really small TFT display might still be workable, so I cobbled together some tests to see if that might be the case with these little displays. In the tests that follow, I am striving to answer first whether the rendering updates will be fast enough for reasonable use and second whether there will be any memory left to do anything interesting.+One of the concerns with with TFT displays is that they are data gluttons, which means they will put a lot of stress on piddly Uno/Nano/Pro Mini with regards to memory consumption, processing time, and data transfer time. However, it's not unreasonable to hope that a really small TFT display might still be workable, so I cobbled together some tests to see if that might be the case with these little displays. In the tests that follow, I am striving to answer first whether the rendering updates will be fast enough for reasonable use and second whether there will be any memory left to do anything interesting.
  
 Unfortunately, it looks like none of the available libraries work well enough with the Uno/Nano/Pro Mini to make these displays really appropriate for large text-based content that changes. The Ucglib library with solid font rendering and a 16 MHz processor comes very close though. However, a 3.3V 16 MHz Arduino isn't available, so this means you'll have to complicate things a bit by using level converters. Unfortunately, it looks like none of the available libraries work well enough with the Uno/Nano/Pro Mini to make these displays really appropriate for large text-based content that changes. The Ucglib library with solid font rendering and a 16 MHz processor comes very close though. However, a 3.3V 16 MHz Arduino isn't available, so this means you'll have to complicate things a bit by using level converters.
Line 11: Line 11:
 The results are a bit of a disappointment because the displays are otherwise incredibly charming. The results are a bit of a disappointment because the displays are otherwise incredibly charming.
  
-===== Libraries =====+===== Tests =====
  
-These are the libraries I know of that let you interface to a ST7735-based display. My tests were conducted with a 3.3V 8 MHz Arduino Pro Mini equivalent unless noted and a 1.44" (128x128) display that I bought through eBay from a vendor in China. +I ran a number of tests using all the libraries I know of that let you interface to a ST7735-based display. These tests were conducted with a 3.3V 8 MHz Arduino Pro Mini equivalent unless noted and a 1.44" (128x128) display that I bought through eBay from a vendor in China. 
  
 ==== Ucglib ==== ==== Ucglib ====
-Oli Kraus' [[https://github.com/olikraus/ucglib/wiki | Ucglib]] is designed to support a range of TFT displays with a common code base. This is the most appealing library for me because of the range of available fonts available out of the box.((Be sure to check the licenses for any fonts you use!))+Oli Kraus' [[https://github.com/olikraus/ucglib/wiki | Ucglib]] is designed to support a range of TFT displays with a common code base. This is the most appealing library for me because of the range of available fonts it has available out of the box.((Be sure to check the licenses for any fonts you use!))
  
-I ran two test cases: one using transparent font rendering and the other with solid. In both cases, faster hardware SPI was used over slower software SPI. I ran both test cases with both a 3.3V 8 MHz Pro Mini and a 5V 16 MHz Nano, for a total of four tests.+I ran two test cases: one using solid font rendering and the other with transparent. In both cases, faster hardware SPI was used over slower software SPI. I ran both test cases with both a 3.3V 8 MHz Pro Mini and a 5V 16 MHz Nano, for a total of four tests.
  
 As you can see from the videos, the speed isn't entirely acceptable. I am assuming this is mostly due to the burden placed by the pretty fonts' data. Frame rates with a 16 MHz processor are double those of an 8 Mhz processor (no surprise). Even though the transparent font rendering is technically faster, the solid rendering artifacts are less annoying. As you can see from the videos, the speed isn't entirely acceptable. I am assuming this is mostly due to the burden placed by the pretty fonts' data. Frame rates with a 16 MHz processor are double those of an 8 Mhz processor (no surprise). Even though the transparent font rendering is technically faster, the solid rendering artifacts are less annoying.
Line 24: Line 24:
 Solid rendering with a 16 MHz processor is //almost// good enough, but a 16 Mhz implementation requires level shifting since no 16 MHz 3.3V boards are available. Solid rendering with a 16 MHz processor is //almost// good enough, but a 16 Mhz implementation requires level shifting since no 16 MHz 3.3V boards are available.
  
-=== Solid mode === +=== Solid font rendering ===
-FIXME solid 8 MHz video+
  
-FIXME solid 16 MHz video+{{youtube>eqLvI47nUFI?560x315&rel=0}}
  
-<file c++ display_st7735_1.44_ucglib_solid.ino> +{{youtube>N029AvjZA6o?560x315&rel=0}}
-/* +
- * display_st7735_1.44_ucglib_solid.ino +
-   +
- * Test screen update speed with large solid fonts on  +
- * a 128x128 TFT screen that uses the ST7735 chip. +
- *  +
- * Consumes 56% of program storage space and +
- * 13% of dynamic memory on a Pro Mini. +
- *  +
- * Mithat Konar +
- */+
  
-#include "Ucglib.h"+[[display_st7735_1.44_ucglib_solid.ino | source code]]
  
-/* +=== Transparent font rendering ===
- * Pin assignments: +
- * RST: 8 +
- * CE/CS/SCE: 10 +
- * DC/"D/C"/A0:+
- * DIN/DN/MOSI/DATA: 11 (Arduino HW standard) +
- * CLK/SCLK/SCK: 13  (Arduino HW standard) +
- * VCC: 3.3V +
- * LIGHT/LED: ground through 1 ohm resistor (yields about 20mA) +
- * GND: ground +
- */+
  
-const unsigned int CLOCK_PIN 13, +{{youtube>CgSVboteLI8?560x315&rel=0}}
-                   DATA_PIN = 11, +
-                   CS_PIN = 10, +
-                   DC_PIN = 9, +
-                   RESET_PIN = 8;+
  
-Ucglib_ST7735_18x128x160_HWSPI ucg(DC_PIN, CS_PIN, RESET_PIN);+{{youtube>ALPgbvUr6Ao?560x315&rel=0}}
  
-unsigned int counter = 80; +[[display_st7735_1.44_ucglib_transparent.ino | source code]]
- +
-void setup(void) +
-+
-  delay(1000); +
-  ucg.begin(UCG_FONT_MODE_SOLID); +
-  ucg.clearScreen(); +
-+
- +
-void loop(void) +
-+
-  ucg.setColor(0, 255, 255, 255); // text foreground color +
-  ucg.setColor(1, 0, 0, 0);       // text background color +
- +
-  ucg.setFont(ucg_font_profont15_mr); +
-  ucg.setPrintPos(0, 12); +
-  ucg.print("Ucglib solid"); +
-   +
-  ucg.setFont(ucg_font_inr49_mr); +
-  counter++; +
-   +
-  // draw new value +
-  ucg.setPrintPos(0, 90); +
-  ucg.print(counter); +
- +
-  // inherent frame rate of this loop is about 1 fps (8Mhz) +
-  // and about 1.9 fps (16MHz) w/o added delay.  +
-  delay(500); +
-+
-</file> +
- +
-=== Transparent mode === +
-FIXME transparent 8 MHz video +
- +
-FIXME transparent 16 MHz video +
- +
-<file c++ display_st7735_1.44_ucglib_transparent+
-/* +
- * display_st7735_1.44_ucglib_transparent +
- *  +
- * Test screen update speed with large transparent fonts on  +
- * a 128x128 TFT screen that uses the ST7735 chip. +
-   +
- * Consumes 53% of program storage space and +
- * 13% of dynamic memory on a Pro Mini. +
- *  +
- * Mithat Konar +
- */ +
- +
-//#include <SPI.h> +
-#include "Ucglib.h" +
- +
-/* +
- * Pin assignments: +
- * RST: 8 +
- * CE/CS/SCE: 10 +
- * DC/"D/C"/A0:+
- * DIN/DN/MOSI/DATA: 11 (Arduino HW standard) +
- * CLK/SCLK/SCK: 13  (Arduino HW standard) +
- * VCC: 3.3V +
- * LIGHT/LED: ground through 1 ohm resistor (yields about 20mA) +
- * GND: ground +
- */ +
- +
-const unsigned int CLOCK_PIN = 13, +
-                   DATA_PIN = 11, +
-                   CS_PIN = 10, +
-                   DC_PIN = 9, +
-                   RESET_PIN = 8; +
- +
-Ucglib_ST7735_18x128x160_HWSPI ucg(DC_PIN, CS_PIN, RESET_PIN); +
- +
-unsigned int counter = 80; +
- +
-void setup(void) +
-+
-  delay(1000); +
-  ucg.begin(UCG_FONT_MODE_TRANSPARENT); +
-  ucg.clearScreen(); +
-+
- +
-void loop(void) +
-+
-  ucg.setFont(ucg_font_7x13_tf); +
-  ucg.setPrintPos(0, 12); +
-  ucg.setColor(255, 255, 255); // Draw new value +
-  ucg.print("Ucglib transparent"); +
-   +
-  ucg.setFont(ucg_font_logisoso58_tr); +
-   +
-  // because the font is rendered transparent, +
-  // you need to clear the screen +
-  // ucg.clearScreen(); +
- +
-  // or draw over previous glyphs in background color +
-  ucg.setColor(0, 0 ,0);   +
-  ucg.setPrintPos(0, 90); +
-  ucg.print(counter); +
- +
-  counter++; +
-   +
-  // draw new value +
-  ucg.setColor(255, 255, 255); +
-  ucg.setPrintPos(0, 90); +
-  ucg.print(counter); +
- +
-  /* With 8MHz processor, inherent frame rate of this loop  is about +
-     1.2 fps with ucg.clearScreen(), and 1.5 fps with drawing over previous glyphs,  +
-     With 16MHz processor, inherent frame rate of this loop  is about +
-     2.4 fps with ucg.clearScreen(), and 2.9 fps with drawing over previous glyphs,  +
-     w/o added delay. The ucg.clearScreen() approach results in unacceptable  +
-     flickers*/ +
-  delay(500); +
-+
-</file>+
  
 ==== Arduino TFT library==== ==== Arduino TFT library====
Line 186: Line 46:
 Overall, the results are fast, but you need to be OK with the blocky text rendering and integer font size scaling. While blocky fonts have a certain charm, it's not the right charm for most applications. Overall, the results are fast, but you need to be OK with the blocky text rendering and integer font size scaling. While blocky fonts have a certain charm, it's not the right charm for most applications.
  
-FIXME video+{{youtube>P_bLs5rMH5c?560x315&rel=0}}
  
-<file c++ display_st7735_1.44_TFT.ino+[[display_st7735_1.44_TFT.ino | source code]]
-/* +
- * display_st7735_1.44_TFT.ino +
-   +
- * Test screen update speed with large solid fonts on  +
- * a 128x128 TFT screen that uses the ST7735 chip. +
-   +
- * Consumes 26% of program storage space and +
- * 5% of dynamic memory on a Pro Mini. +
- *  +
- * Mithat Konar +
- */+
  
-#include <TFT.h>  // Arduino LCD library 
-#include <SPI.h> 
- 
-/* 
- * Pin assignments: 
- * RST: 8 
- * CE/CS/SCE: 10 
- * DC/"D/C"/A0: 9 
- * DIN/DN/MOSI/DATA: 11 (Arduino HW standard) 
- * CLK/SCLK/SCK: 13  (Arduino HW standard) 
- * VCC: 3.3V 
- * LIGHT/LED: ground through 1 ohm resistor (yields about 20mA) 
- * GND: ground 
- */ 
- 
-const unsigned int CLOCK_PIN = 13, 
-                   DATA_PIN = 11, 
-                   CS_PIN = 10, 
-                   DC_PIN = 9, 
-                   RESET_PIN = 8; 
- 
-const unsigned int LEFT_MARGIN = 32; // number of pixels you need to shift for 128x128 screen 
- 
- 
-TFT TFTscreen = TFT(CS_PIN, DC_PIN, RESET_PIN); 
-char dispStr[4];    // null terminated char array used to pass to TFT.text() 
-unsigned int counter = 80; 
- 
-void setup() { 
-  TFTscreen.begin(); 
-  TFTscreen.background(0, 0, 0);    // clear the screen 
- 
-  TFTscreen.stroke(255, 255, 255);  // set font color 
-  TFTscreen.setTextSize(1);         // set font size 
-  TFTscreen.text("TFT library", LEFT_MARGIN, 0); 
-   
-  TFTscreen.setTextSize(7); 
-} 
- 
-void loop() { 
-  // draw over what you wrote last time 
-  TFTscreen.stroke(0, 0, 0);    // background color 
-  String(counter).toCharArray(dispStr, 4); 
-  TFTscreen.text(dispStr, LEFT_MARGIN, 40);   
- 
-  // update and draw something new 
-  counter++; 
- 
-  TFTscreen.stroke(255, 255, 255);  // font color 
-  String(counter).toCharArray(dispStr, 4); 
-  TFTscreen.text(dispStr, LEFT_MARGIN, 40); 
- 
-  // inherent frame rate of this loop is about 15 fps w/o added delay (8 MHz processor). 
-  delay(500); 
-} 
- 
-</file> 
  
 ==== Adafruit ST7735 Library ==== ==== Adafruit ST7735 Library ====
Line 267: Line 59:
 The Adafruit library with its default font performs and looks almost the same as the Arduino TFT library. The Adafruit library with its default font performs and looks almost the same as the Arduino TFT library.
  
-FIXME video+{{youtube>E7Q2fDEZVyw?560x315&rel=0}}
  
-<file c++ display_st7735_1.44_adafruit_st7735.ino+[[display_st7735_1.44_adafruit_st7735.ino | source code]]
-/* +
- * display_st7735_1.44_adafruit_st7735.ino +
-   +
- * Test screen update speed with large default fonts on  +
- * a 128x128 TFT screen that uses the ST7735 chip. +
- *  +
- * Consumes 26% of program storage space and +
- * 6% of dynamic memory on a Pro Mini. +
- *  +
- * Mithat Konar +
- */ +
- +
-#include <Adafruit_GFX.h>    // Core graphics library +
-#include <Adafruit_ST7735.h> // Hardware-specific library +
-#include <SPI.h> +
- +
-/* +
- * Pin assignments: +
- * RST: 8 +
- * CE/CS/SCE: 10 +
- * DC/"D/C"/A0:+
- * DIN/DN/MOSI/DATA: 11 (Arduino HW standard) +
- * CLK/SCLK/SCK: 13  (Arduino HW standard) +
- * VCC: 3.3V +
- * LIGHT/LED: ground through 1 ohm resistor (yields about 20mA) +
- * GND: ground +
- */ +
- +
-const unsigned int CLOCK_PIN = 13, +
-                   DATA_PIN = 11, +
-                   TFT_CS = 10, +
-                   TFT_DC = 9, +
-                   TFT_RST = 8; +
- +
-const unsigned int TOP_MARGIN = 32;    // number of pixels you need to shift for 128x128 screen +
- +
-// Use hardware SPI. +
-Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST); // Use hardware SPI +
-unsigned int counter = 80; +
- +
-void setup(void) { +
-  // mfk note: neither initializer below works for the 128x128 +
-  tft.initR(INITR_BLACKTAB);   // 1.8"initialize a ST7735S chip, black tab +
-  // tft.initR(INITR_144GREENTAB);   // 1.44", initialize a ST7735S chip, black tab +
- +
-  tft.fillScreen(ST7735_BLACK);  // clear the screen +
-  tft.setTextWrap(false); +
- +
-  tft.setCursor(0, TOP_MARGIN); +
-  tft.setTextSize(1); +
-  tft.setTextColor(ST7735_WHITE); +
-  tft.setTextWrap(true); +
-  tft.print("Adafruit ST7735"); +
-+
- +
-void loop() { +
-  tft.setTextSize(7); +
- +
-  // draw over what you wrote last time +
-  tft.setCursor(0, TOP_MARGIN + 40); +
-  tft.setTextColor(ST7735_BLACK); +
-  tft.print(counter);     +
- +
-  // update and draw something new +
-  counter++; +
-  tft.setCursor(0, TOP_MARGIN + 40); +
-  tft.setTextColor(ST7735_WHITE); +
-  tft.print(counter); +
-   +
-  // inherent frame rate of this loop is about 15 fps w/o added delay (8 MHz processor). +
-  delay(500); +
-+
- +
-</file>+
  
 === Fancy large font === === Fancy large font ===
Line 349: Line 67:
 When a large fancy font is used, the performance between the Adafruit library and Uclib narrows. I suspect that with a font as large as that used in the Uclib examples, the results would be close to identical. Which is to say, not fast (or light?) enough. When a large fancy font is used, the performance between the Adafruit library and Uclib narrows. I suspect that with a font as large as that used in the Uclib examples, the results would be close to identical. Which is to say, not fast (or light?) enough.
  
-FIXME video +{{youtube>6VZFaBHWOzE?560x315&rel=0}}
- +
-<file c++ display_st7735_1.44_adafruit_st7735_fonts.ino> +
-/* +
- * display_st7735_1.44_adafruit_st7735_fonts.ino +
-   +
- * Test screen update speed with large fancy font on  +
- * a 128x128 TFT screen that uses the ST7735 chip. +
- *  +
- * Consumes 53% of program storage space and +
- * 6% of dynamic memory on a Pro Mini. +
- *  +
- * Mithat Konar +
- */ +
- +
-#include <Adafruit_GFX.h>    // Core graphics library +
-#include <Adafruit_ST7735.h> // Hardware-specific library +
-#include <SPI.h> +
-#include <Fonts/FreeSans24pt7b.h> +
- +
-/* +
- * Pin assignments: +
- * RST: 8 +
- * CE/CS/SCE: 10 +
- * DC/"D/C"/A0:+
- * DIN/DN/MOSI/DATA: 11 (Arduino HW standard) +
- * CLK/SCLK/SCK: 13  (Arduino HW standard) +
- * VCC: 3.3V +
- * LIGHT/LED: ground through 1 ohm resistor (yields about 20mA) +
- * GND: ground +
- */ +
- +
-const unsigned int CLOCK_PIN 13, +
-                   DATA_PIN = 11, +
-                   TFT_CS = 10, +
-                   TFT_DC = 9, +
-                   TFT_RST = 8; +
- +
-const unsigned int TOP_MARGIN = 32;    // number of pixels you need to shift for 128x128 screen +
- +
-// Use hardware SPI. +
-Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST); // Use hardware SPI +
-unsigned int counter = 80; +
- +
-void setup(void) { +
-  // mfk note: neither initializer below works for the 128x128 +
-  tft.initR(INITR_BLACKTAB);   // 1.8"initialize a ST7735S chip, black tab +
-  // tft.initR(INITR_144GREENTAB);   // 1.44", initialize a ST7735S chip, black tab +
- +
-  tft.fillScreen(ST7735_BLACK);  // clear the screen +
-  tft.setTextWrap(false); +
- +
-  tft.setCursor(0, TOP_MARGIN); +
-  tft.setTextSize(1); +
-  tft.setTextColor(ST7735_WHITE); +
-  tft.setTextWrap(true); +
-  tft.print("Adafruit ST7735 fonts"); +
- +
-  tft.setFont(&FreeSans24pt7b); +
-} +
- +
-void loop() { +
-  // draw over what you wrote last time +
-  tft.setCursor(0, TOP_MARGIN + 80); +
-  tft.setTextColor(ST7735_BLACK); +
-  tft.print(counter);    +
  
-  // update and draw something new +[[display_st7735_1.44_adafruit_st7735_fonts.ino | source code]]
-  counter++; +
-  tft.setCursor(0, TOP_MARGIN + 80); +
-  tft.setTextColor(ST7735_WHITE); +
-  tft.print(counter); +
-   +
-  // inherent frame rate of this loop is about 2.5 fps w/o added delay (8 MHz processor). +
-  delay(500); +
-}+
  
-</file> 
arduino/displays_for_classic_arduinos/1.8_and_1.44_tft_displays_and_classic_arduinos.1517100059.txt.gz · Last modified: 2018/01/28 00:40 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki