Test for graphic and bargraph for ST7735 160x80 tft display
Dependencies: mbed Adafruit_ST7735 Adafruit_GFX
Homepage
INTRO¶
This is a test for a China 0.96" (80x160) TFT screen with ST7735 controller, it uses the library developed by Justin Kim
Import libraryAdafruit_GFX
Adafruit GFX Library
adapted from Adafruit In this test you will find a short demonstration of the graphic capabilities and a double bargraph controlled by an analog input.
Wiring¶
A voltage divider (10k potentiometer between 3V3 and GND) is plugged on analog input A3, the screen is connected according the following table:
Screen | Function | Nucleo F411/F401 port |
GND | GND | GND |
VCC | 3V3 | 3V3 |
SCL | SPI Clock | D13 |
SDA | MOSI | D11 |
RES | - | D9 |
DC | - | D8 |
CS | Chip select | D10 |
AnalogIn analogIn(A3); // Potentiometer plugged as a voltage divider on the input A3 Adafruit_ST7735 tft(D11, D12, D13, D10, D8, D9); // MOSI, MISO, SCLK, SSEL, TFT_DC, TFT_RST
Colors definitions¶
The color definition is 16 bits based, it is possible to use a color generator as the following one:
http://www.barth-dev.de/online/rgb565-color-picker/
#define BACKCOLOR 0x0000 #define BARCOLOR 0x0620 #define SCALECOLOR 0xFFFF