Code Monkey home page Code Monkey logo

abhra0897 / stm32f1_ili9341_parallel Goto Github PK

View Code? Open in Web Editor NEW
13.0 3.0 5.0 18.56 MB

This is a fast display driver for interfacing ILI9341 LCD display with STM32F1 microcontroller over an 8bit parallel (8080-II/I) bus. Mainly made for my personal usage.

License: MIT License

C 92.81% Makefile 1.76% HTML 0.01% C++ 2.41% Assembly 0.08% Perl 2.09% Python 0.79% Shell 0.05%
ili9341 stm32 stm32f103 display-driver driver libopencm3 gpios bus

stm32f1_ili9341_parallel's Introduction

ILI9341 Parallel Display Driver for STM32F1

Codacy Badge

This is a fast display driver for interfacing ILI9341 LCD display with STM32F1 microcontroller over an 8bit parallel (8080-II/I) bus. It's mainly written for my personal usage.

Vitasam added support for JYETech DSO138 oscilloscope.

GPIOs are handled by direct register manipulation for faster performance. This driver now configures the used GPIOs, so user need not do it anymore.

This driver needs libopencm3 library. The library is provided with this repository. You may get the latest version of libopencm3 from here, but that may or may not work depending on the changes made in libopencm3 latest version.

In order to be able to program smt32 devices st-flash is needed.

Download

Download this repository using git:

git clone https://github.com/abhra0897/stm32f1_ili9341_parallel.git

Wiring

Connections between STM32F1 and ILI9341 parallel display.

ILI9341 STM32F1
8080-I 8-bit 8080-II 8-bit
D0 D10 PA0
D1 D11 PA1
D2 D12 PA2
D3 D13 PA3
D4 D14 PA4
D5 D15 PA5
D6 D16 PA6
D7 D17 PA7
RESX PB0
CSX PB1
D/CX PB5
WRX PB4
RDX PB3

Benchmarks

Screen fill speed is tested in crazy_fast. This is not a proper "benchmark", rather a code to satisfy my lust for high fps.

Example

Example code (main.c) is in example directory. To compile using the provided Makefile, keep the directory structure as it is. If you change the directory structure, edit the SRCS, INCLS, and LIBS in the Makefile accordingly. Example is compiled and tested on STM32F103 (overclocked to 128MHz). Note: To compile for DSO138, comment out CFLAGS += -DUSER_DEFAULT_PLATFORM and uncomment CFLAGS += -DDSO138_PLATFORM in the Makefile.

Output of example code

Making Fonts

To know how to make more fonts as per your need, check my fonts_embedded repository.

Important API Methods

/**
 * Initialize the display driver
 */
void ili_init();

/**
 * Set an area for drawing on the display with start row,col and end row,col.
 * User don't need to call it usually, call it only before some functions who don't call it by default.
 * @param x1 start column address.
 * @param y1 start row address.
 * @param x2 end column address.
 * @param y2 end row address.
 */
void ili_set_address_window(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);

/**
 * Fills `len` number of pixels with `color`.
 * Call ili_set_address_window() before calling this function.
 * @param color 16-bit RGB565 color value
 * @param len 32-bit number of pixels
 */
void ili_fill_color(uint16_t color, uint32_t len);

/**
 * Draw a line from (x0,y0) to (x1,y1) with `width` and `color`.
 * @param x0 start column address.
 * @param y0 start row address.
 * @param x1 end column address.
 * @param y1 end row address.
 * @param width width or thickness of the line
 * @param color 16-bit RGB565 color of the line
 */
void ili_draw_line(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t width, uint16_t color);

/**
 * Rotate the display clockwise or anti-clockwie set by `rotation`
 * @param rotation Type of rotation. Supported values 0, 1, 2, 3
 */
void ili_rotate_display(uint8_t rotation);

/**
 * Fills a rectangular area with `color`.
 * Before filling, performs area bound checking
 * @param x Start col address
 * @param y Start row address
 * @param w Width of rectangle
 * @param h Height of rectangle
 * @param color 16-bit RGB565 color
 */
void ili_fill_rect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color);

/*
 * Same as `ili_fill_rect()` but does not do bound checking, so it's slightly faster
 */
void ili_fill_rect_fast(uint16_t x1, uint16_t y1, uint16_t w, uint16_t h, uint16_t color);

/**
 * Fill the entire display (screen) with `color`
 * @param color 16-bit RGB565 color
 */
void ili_fill_screen(uint16_t color);

/**
 * Experimental
 * Draw a rectangle without filling it
 * @param x start column address.
 * @param y start row address
 * @param w Width of rectangle
 * @param h height of rectangle
 */
void ili_draw_rectangle(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color);

/**
 * Draws a character at a given position, fore color, back color.
 * @param x Start col address
 * @param y Start row address
 * @param character the ASCII character to be drawn
 * @param fore_color foreground color
 * @param back_color background color
 * @param font Pointer to the font of the character
 * @param is_bg Defines if character has background or not (transparent)
 */
void ili_draw_char(uint16_t x, uint16_t y, char character, uint16_t fore_color, uint16_t back_color, const tFont *font, uint8_t is_bg)

/**
 * Draws a string on the display with `font` and `color` at given position.
 * Background of this string is transparent
 * @param x Start col address
 * @param y Start y address
 * @param str pointer to the string to be drawn
 * @param color 16-bit RGB565 color of the string
 * @param font Pointer to the font of the string
 */
void ili_draw_string(uint16_t x, uint16_t y, char *str, uint16_t color, tFont *font);

/**
 * Draws a string on the display with `font`, `fore_color`, and `back_color` at given position.
 * The string has background color
 * @param x Start col address
 * @param y Start y address
 * @param str pointer to the string to be drawn
 * @param foe_color 16-bit RGB565 color of the string
 * @param back_color 16-bit RGB565 color of the string's background
 * @param font Pointer to the font of the string
 */
void ili_draw_string_withbg(uint16_t x, uint16_t y, char *str, uint16_t fore_color, uint16_t back_color, tFont *font);

/**
 * Draw a bitmap image on the display
 * @param x Start col address
 * @param y Start row address
 * @param bitmap Pointer to the image data to be drawn
 */
void ili_draw_bitmap(uint16_t x, uint16_t y, const tImage *bitmap);

/**
 * Draw a pixel at a given position with `color`
 * @param x Start col address
 * @param y Start row address
 */
void ili_draw_pixel(uint16_t x, uint16_t y, uint16_t color);

TO DO

  • Add example code(s) and write some docs
  • Write better comments
  • Explain how to create fonts
  • Optimize driver for speed and size. Speed is the first priority (improved speed)

License

libopencm3 and any derivative of the same are licensed under the terms of the GNU Lesser General Public License (LGPL), version 3 or later. The binaries generated after compilation will also be licensed under the same. See this and this for the LGPL3 and GPL3 licenses.

All other source codes of the root directory and example directory are licensed under MIT License, unless the source file has no other license asigned for it. See MIT License.

stm32f1_ili9341_parallel's People

Contributors

abhra0897 avatar codacy-badger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

stm32f1_ili9341_parallel's Issues

Write a character on top of previously written character

Hi,
what happens when a character goes on top of previously written character?

Assuming monospace front, it will be the same rectangle - should one take care about cleaning the rectangle manually or the driver takes care about it?

CS_ACTIVE is commented out

Hi,

just noticed that CS_ACTIVE is commented out - what is a reason?

__attribute__((always_inline)) static inline void _ili_write_command_8bit(uint8_t cmd)
{
	//CS_ACTIVE;
	ILI_DC_CMD;
	ILI_WRITE_8BIT(cmd);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.