A bit-banged TFT library with a tiny footprint
This is a rework of the excellent bit-banged TFT library by "David Johnson-Davies - www.technoblogy.com" where I redefined a few things, tidied it up, and somehow made it more portable. You may use it with any microcontroller with just toggling GPIOs. literally all Arduino, AVR, STM8, STM32, PIC ... microcontrollers. Both files are quite self-explanatory and easy to understand.
For more info, read the original post.
- changed the
ints to a more restrict variable size ofint16_t, int8_t. - changed the function names so they won't interfere with other things.
every function/variable observable by the main program, starts with
ttft_. - added a fast
absfunction. you can get rid of thatstdlib.hif you don't like it, see the header file.
- the
ttft_init_disp_io()defers fromttft_init_dispnow; first one is optional since you can config them in your code and simply call the display routines only. - a
void ttft_clear_section(int16_t xx, int16_t yy)is added where a section of screen is deleted quickly using 12bit color data.
- Copy both the header and the source file to your project folder.
- Add the source file to your project's hierarchy to be compiled.
- Read the header file (.h file) carefully.
- Open source file, there is a SETUP area defined; set it according to your MCU and display
- Fire it up :)
- if your display has no cs pin, let it be. you don't have to do anything about it
- if your display has a reset pin, connect it to your MCUs, reset pin, or in some cases, reset it manually in your code before initialization
- there are 3 variable available to you to change: text size, fore color(brush color), back color. you can set them in your code, wherever you want.
ttft_init_disp_io (); //Optional, you can init the GPIOs in your code instead
ttft_init_disp(); //Call to initialize display itself.
ttft_clear_disp();
ttft_disp_on();
//...
Waterfall(); // this is a waterfall example from the original library used as a demo
//...
fore_color = ttft_get_color (150,50,100); //RGB color to set as brush color of a shape or text
back_color = ttft_get_color (150,50,100); //RGB color to set as back color of a shape or text
ttft_text_scale = 2; //from now on, text size would be 2
//...
//draw a few shapes
//...
//change the color or text scale if you like
