There are many examples on MBED for ST7735 controlled LCDs, but they're mostly for the AdaFruit LCD. This is a working example of the library used for the cheap-as-dirt KMR-1.8 SPI 128x160 TFT LCD, on a "Black Pill" STM32F407VE developement board.
Dependencies: 24_TFT_STMNUCLEO mbed
main.cpp
- Committer:
- katbar
- Date:
- 2018-09-28
- Revision:
- 0:368cfb35a89a
File content as of revision 0:368cfb35a89a:
// WORKS with KMR-1.8 128x160 TFT LCD // // Hookup: // VCC, LED+ - 3.3V // CS - PC_4 // SCLK - PA_5 // SDA - PA_7 // A0 - PC_5 // RESET - PA_4 #include "mbed.h" #include "st7735.h" #include "terminus.h" // create the lcd instance // ST7735_LCD( PinName CS, PinName RESET, PinName RS, PinName SCL, PinName SDA, PinName BL = NC, backlight_t blType = Constant, float defaultBackLightLevel = 1.0 ); ST7735_LCD lcd( PC_4, PA_4, PC_5, PA_5, PA_7 ); // control pins int main() { // initialize display - place it in standard portrait mode and set background to black and lcd.Initialize( LANDSCAPE_REV, RGB16 ); lcd.ClearScreen(); // various graphics primitives lcd.DrawPixel(1,1,0xFF9FFF); lcd.DrawLine(10,10,150,10,0xFF29A9); lcd.FillCircle(70,60,10,0x00FF00); lcd.DrawRect(30,80,50,100,0x0000FF); lcd.DrawRect(60,80,80,100,0xFF00FF); // any RGB mix XX-XX-XX lcd.DrawRect(90,80,110,100,0x00FFFF); // any RGB mix XX-XX-XX lcd.DrawRect(120,80,140,100,0xFFFF00); // any RGB mix XX-XX-XX lcd.SetFont( &TerminusFont ); // print something on the screen lcd.Print( "Hello, World!", CENTER, 25 ); // align text to center horizontally and use starndard colors while ( 1 ) { } }