ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts  1.0
ESP8266ILI9341DisplayProject
Data Structures | Macros | Functions
ili9341.h File Reference

ili9341 driver inspired by Adafruit ili9341 code All code in this file has been rewritten by Mike Gore More...

#include "font.h"
#include "ili9341_adafruit.h"

Go to the source code of this file.

Data Structures

struct  window
 
struct  p2_int16_t
 2D display point - display coordinates are int16 More...
 
struct  p3_int16_t
 3D display point - display coordinates are int16 More...
 

Macros

#define MEMSPACE
 
#define WEAK_ATR   __attribute__((weak))
 
#define FONT_VAR   1
 
#define WRAP_H   2
 
#define WRAP_V   4
 
#define WRAP   (WRAP_H | WRAP_V)
 
#define TFT_W   (MAX_TFT_X-MIN_TFT_X+1)
 
#define TFT_H   (MAX_TFT_Y-MIN_TFT_Y+1)
 
#define TFT_XOFF   (MIN_TFT_X)
 
#define TFT_YOFF   (MIN_TFT_Y)
 
#define tft_RGBto565(r, g, b)   ((uint16_t) (((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >>3))
 Pass 8-bit (each) R,G,B, get back 16-bit packed color ILI9341 defaults to MSB/LSB data so we have to reverse it. More...
 
#define SWAP(a, b)   do { a ^= b; b ^= a; a ^= b; } while(0)
 
#define ABS(x)   ((x)<0 ? -(x) : (x))
 

Functions

int font_max (void)
 
int font_H (int font)
 Get font height used for line to line spacing. More...
 
int font_W (int font)
 Get font Width used for character to character spacing. More...
 
int font_attr (window *win, int c, _fontc *f)
 Get font attributes for a font. More...
 
int16_t sx (float scale, int16_t xoff, int16_t X)
 
int16_t sy (float scale, int16_t yoff, int16_t Y)
 
void drawSVG (window *win, int16_t x, int16_t y, int16_t c, float scale, uint16_t color, int16_t fill)
 
void tft_Cmd (uint8_t cmd)
 Transmit 8 bit command. More...
 
uint8_t tft_Data (uint8_t data)
 Transmit 8 bit data amd read 8bit data. More...
 
void tft_Cmd_Data_TX (uint8_t cmd, uint8_t *data, int bytes)
 Transmit 8 bit command and optionally send data buffer. More...
 
int32_t tft_abs_window (window *win, int16_t x, int16_t y, int16_t w, int16_t h)
 ============================================================= More...
 
int32_t tft_rel_window (window *win, int16_t x, int16_t y, int16_t w, int16_t h)
 Set the ili9341 working window by relative position and size Note: Function clips x,y,w,y. More...
 
MEMSPACE uint32_t tft_readRegister (uint8_t command, uint8_t parameter)
 ==================================== More...
 
MEMSPACE uint32_t tft_readId (void)
 Read ILI9341 device ID should be 9341 This does not work for really high SPI clock speeds Make sure that when called the clock speed in reduced. More...
 
void tft_bit_blit (window *win, uint8_t *ptr, int16_t x, int16_t y, int16_t w, int16_t h)
 

BLIT functions

More...
 
void tft_fillWin (window *win, uint16_t color)
 

Fill functions

More...
 
void tft_flood (window *win, int16_t x, int16_t y, uint16_t border, uint16_t fill)
 Flood fill. More...
 
int tft_push_xy (int16_t x, int16_t y)
 point push More...
 
int tft_pop_xy (int16_t *x, int16_t *y)
 point push More...
 
int tft_floodline (window *win, int16_t x, int16_t y, uint16_t border, uint16_t fill)
 Flood using line fill method. More...
 
int tft_FillPolyLine (window *win, int16_t x, int16_t y, int w, uint16_t color)
 
void tft_fillRectWH (window *win, int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
 Partial window Fill with color We clip the window to the current view. More...
 
void tft_fillRectXY (window *win, int16_t x, int16_t y, int16_t xl, int16_t yl, uint16_t color)
 Fill rectangle with color We clip the window to the current view. More...
 
void tft_drawPixel (window *win, int16_t x, int16_t y, int16_t color)
 

Pixel functions

More...
 
void tft_writeRect (window *win, int16_t x, int16_t y, int16_t w, int16_t h, uint16_t *color)
 Write a rectangle pixel array. More...
 
void tft_readRect (window *win, int16_t x, int16_t y, int16_t w, int16_t h, uint16_t *color)
 
void tft_Vscroll (window *win, int dir)
 Scroll window up by dir lines We start at the top of the window and move down. More...
 
uint16_t tft_readPixel (window *win, int16_t x, int16_t y)
 Read one pixel and return color in 1bit 565 RGB format We clip the window to the current view Note: Read Memory must be done in a continious write/read operation Chip select can not be deactivated for the transaction. More...
 
MEMSPACE void tft_setRotation (uint8_t m)
 Set Display rotation, applies to the master window only Set hardware display rotation and memory fill option bits Update software display limits FIXME Work in progress. More...
 
void tft_565toRGB (uint16_t color, uint8_t *r, uint8_t *g, uint8_t *b)
 

Color conversions

More...
 
MEMSPACE void tft_invertDisplay (int flag)
 Invert the display. More...
 
MEMSPACE int tft_window_clip (window *win)
 Clip window structure to TFT limits. More...
 
MEMSPACE void tft_clip_xy (window *win, int16_t *X, int16_t *Y)
 Clip X,Y to fix inside specifiied window. More...
 
MEMSPACE int tft_window_clip_args (window *win, int16_t *x, int16_t *y, int16_t *w, int16_t *h)
 clip arguments to window limits Arguments position x,y width w and height h to be clipped More...
 
MEMSPACE void tft_window_init (window *win, int16_t x, int16_t y, int16_t w, int16_t h)
 Initialize window structure we default values FIXME check x+w, y+h absolute limits against TFT limuts. More...
 
MEMSPACE void tft_setTextColor (window *win, uint16_t fg, uint16_t bg)
 ==================================== More...
 
MEMSPACE void tft_setpos (window *win, int16_t x, int16_t y)
 Set current window text pointer in pixels (per current rotation) More...
 
MEMSPACE void tft_set_textpos (window *win, int16_t x, int16_t y)
 Set current window text pointer in characters (per current rotation) - overall font bounding box. More...
 
MEMSPACE void tft_set_font (window *win, uint16_t index)
 Set current font size (per current rotation) More...
 
MEMSPACE void tft_font_fixed (window *win)
 
MEMSPACE void tft_font_var (window *win)
 Set current font type to variable. More...
 
int tft_get_font_height (window *win)
 Get font height. More...
 
void tft_drawFastVLine (window *win, int16_t x, int16_t y, int16_t h, uint16_t color)
 Fast virtical line drawing. More...
 
void tft_drawFastHLine (window *win, int16_t x, int16_t y, int16_t w, uint16_t color)
 Fast virtical line drawing. More...
 
void tft_drawLine (window *win, int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color)
 Draw line From my blit test code testit.c 1984 - 1985 Mike Gore. More...
 
int tft_Bezier2 (window *win, p2_int16_t S, p2_int16_t C, p2_int16_t T, int steps, uint16_t color)
 Draw lines between points along Quadratic Bézier curve Quadratic Bézier with respect to t, see https://en.wikipedia.org/wiki/Bézier_curve B(t) = (1-t)*(1-t)*S + 2*(1-t)*t*C + t*t*T, 0 <= t <= 1. More...
 
int tft_Bezier3 (window *win, p2_int16_t S, p2_int16_t C1, p2_int16_t C2, p2_int16_t T, int steps, uint16_t color)
 Draw lines between points along Cubic Bézier curve Quadratic Bézier with respect to t, see https://en.wikipedia.org/wiki/Bézier_curve B(t) = (1-t)(1-t)*(1-t)*S + 3*(1-t)(1-t)*t*C1 + 3(1-t)*t*t*C2 + t*t*t*T, 0 <= t <= 1. More...
 
MEMSPACE void tft_cleareol (window *win)
 

Character and String functions

More...
 
MEMSPACE void tft_clearline (window *win)
 Clear display text line. More...
 
void tft_putch (window *win, int c)
 put character in current winoow More...
 
void tft_spi_init (uint32_t prescale)
 
void tft_spi_begin (void)
 Obtain SPI bus for TFT display, assert chip select return: void. More...
 
void tft_spi_end (void)
 Release SPI bus from TFT display, deassert chip select return: void. More...
 
void tft_reset_init (void)
 Initialize ILI9341 reset GPIO return: void. More...
 
void tft_reset_enable (void)
 enable ILI9341 reset return: void More...
 
void tft_addr_init (void)
 Initialize ILI9341 command/data GPIO return: void. More...
 
void tft_reset_disable (void)
 disnable ILI9341 reset return: void More...
 
void tft_spi_TX (uint8_t *data, int bytes, uint8_t command)
 Transmit 8 bit data array. More...
 
void tft_spi_TXRX (uint8_t *data, int bytes, uint8_t command)
 Transmit and read 8 bit data array. More...
 
void tft_spi_RX (uint8_t *data, int bytes, uint8_t command)
 read 8 bit data array More...
 
MEMSPACE windowtft_init (void)
 Initialize TFT. More...
 

Detailed Description

ili9341 driver inspired by Adafruit ili9341 code All code in this file has been rewritten by Mike Gore

Copyright © 2015 Mike Gore, GPL License
You are free to use this code under the terms of GPL
please retain a copy of this notice in any code you use it in.
Copyright © 2013 Adafruit Industries. All rights reserved.
See also
https://github.com/adafruit/Adafruit-GFX-Library
Line drawing function CERTS
See also
https://github.com/CHERTS/esp8266-devkit/tree/master/Espressif/examples/esp8266_ili9341

This is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file ili9341.h.

Macro Definition Documentation

#define ABS (   x)    ((x)<0 ? -(x) : (x))

Definition at line 96 of file ili9341.h.

Referenced by tft_drawFastHLine().

#define FONT_VAR   1

Definition at line 78 of file ili9341.h.

Referenced by font_attr(), tft_font_fixed(), and tft_font_var().

#define MEMSPACE

Definition at line 66 of file ili9341.h.

#define SWAP (   a,
 
)    do { a ^= b; b ^= a; a ^= b; } while(0)

Definition at line 95 of file ili9341.h.

Referenced by tft_fillRectXY(), and tft_fillTriangle().

#define TFT_H   (MAX_TFT_Y-MIN_TFT_Y+1)

Definition at line 84 of file ili9341.h.

Referenced by tft_init(), and tft_setRotation().

#define tft_RGBto565 (   r,
  g,
 
)    ((uint16_t) (((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >>3))

Pass 8-bit (each) R,G,B, get back 16-bit packed color ILI9341 defaults to MSB/LSB data so we have to reverse it.

Parameters
[in]rred data
[in]bblue data
[in]ggreen data

Definition at line 93 of file ili9341.h.

Referenced by test_types(), tft_FillPolyLine(), tft_readPixel(), tft_readRect(), and user_loop().

#define TFT_W   (MAX_TFT_X-MIN_TFT_X+1)

Definition at line 83 of file ili9341.h.

Referenced by tft_init(), tft_setRotation(), and tft_Vscroll().

#define TFT_XOFF   (MIN_TFT_X)

Definition at line 85 of file ili9341.h.

Referenced by tft_init(), and tft_setRotation().

#define TFT_YOFF   (MIN_TFT_Y)

Definition at line 86 of file ili9341.h.

Referenced by tft_init(), and tft_setRotation().

#define WEAK_ATR   __attribute__((weak))

Definition at line 71 of file ili9341.h.

#define WRAP   (WRAP_H | WRAP_V)

Definition at line 81 of file ili9341.h.

#define WRAP_H   2

Definition at line 79 of file ili9341.h.

Referenced by tft_drawChar(), tft_putch(), and tft_window_init().

#define WRAP_V   4

Definition at line 80 of file ili9341.h.

Referenced by tft_drawChar().

Function Documentation

void drawSVG ( window win,
int16_t  x,
int16_t  y,
int16_t  c,
float  scale,
uint16_t  color,
int16_t  fill 
)

Referenced by user_tests().

int font_attr ( window win,
int  c,
_fontc f 
)

Get font attributes for a font.

Parameters
[in]*winWindow Structure
[in]ccharacter
[in]*ffont structure
Returns
font number

Definition at line 94 of file font.c.

Referenced by tft_cleareol(), tft_clearline(), tft_drawChar(), tft_get_font_height(), and tft_putch().

int font_H ( int  font)

Get font height used for line to line spacing.

Parameters
[in]fontfont number
Returns
Height in pixels

Definition at line 70 of file font.c.

Referenced by test_types(), and tft_set_textpos().

int font_max ( void  )

Definition at line 59 of file font.c.

Referenced by tft_set_font().

int font_W ( int  font)

Get font Width used for character to character spacing.

Parameters
[in]fontfont number
Returns
Width in pixels

Definition at line 80 of file font.c.

Referenced by tft_set_textpos().

int16_t sx ( float  scale,
int16_t  xoff,
int16_t  X 
)

Referenced by tft_drawFastHLine().

int16_t sy ( float  scale,
int16_t  yoff,
int16_t  Y 
)

Referenced by tft_drawFastHLine().

void tft_565toRGB ( uint16_t  color,
uint8_t r,
uint8_t g,
uint8_t b 
)

Color conversions

====================================Convert 16bit colr into 8-bit (each) R,G,B ILI9341 defaults to MSB/LSB data so we have to reverse it

Parameters
[in]color16bit color
[out]*rred data
[out]*bblue data
[out]*ggreen data

Definition at line 1033 of file ili9341.c.

int32_t tft_abs_window ( window win,
int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h 
)

=============================================================

====================================

window limits

Set the ili9341 working window by absolute position and size Note: Function clips x,y,w,y

Parameters
[in]xStarting X offset
[in]yStarting Y offset
[in]wWidth
[in]hHeight
Returns
(w * h) after clipping

Definition at line 101 of file ili9341.c.

Referenced by tft_rel_window().

void tft_addr_init ( void  )

Initialize ILI9341 command/data GPIO return: void.

Definition at line 112 of file ili9341_hal.c.

Referenced by tft_init().

int tft_Bezier2 ( window win,
p2_int16_t  S,
p2_int16_t  C,
p2_int16_t  T,
int  steps,
uint16_t  color 
)

Draw lines between points along Quadratic Bézier curve Quadratic Bézier with respect to t, see https://en.wikipedia.org/wiki/Bézier_curve B(t) = (1-t)*(1-t)*S + 2*(1-t)*t*C + t*t*T, 0 <= t <= 1.

====================================

Interpolation functions

The path traced by the function B(t), given points S, C, and T, S = initial points C = control points T = target points

Derivative of the Bézier curve with respect to t B'(t) = 2*(1-t)*(C-S) + 2*t*(T-C)

Second derivative of the Bézier curve with respect to t is B"(t) = 2*(T-2*C+S)

As t increases from 0 to 1, the curve departs from S in the direction of C, then bends to arrive at T from the direction of C. The tangents to the curve at S and T intersect at C.

Parameters
[in]*winWindow Structure of active window
[in]SStart
[in]CControl
[in]TTarget
[in]stepsline segments along curve (1..N)
[in]colorLine color
Returns
count of line segments

Definition at line 1474 of file ili9341.c.

int tft_Bezier3 ( window win,
p2_int16_t  S,
p2_int16_t  C1,
p2_int16_t  C2,
p2_int16_t  T,
int  steps,
uint16_t  color 
)

Draw lines between points along Cubic Bézier curve Quadratic Bézier with respect to t, see https://en.wikipedia.org/wiki/Bézier_curve B(t) = (1-t)(1-t)*(1-t)*S + 3*(1-t)(1-t)*t*C1 + 3(1-t)*t*t*C2 + t*t*t*T, 0 <= t <= 1.

The path traced by the function B(t), given points S, C, and T, S = initial points C1 = control point 1 C2 = control point 2 T = target points

Derivative of the Bézier curve with respect to t B'(t) = 3(1-t)*(1-t)*(C1-S) + 6*(1-t)*t*(C2-C1) + 3*t*t*(T-C2)

Second derivative of the Bézier curve with respect to t is B"(t) = 6*(1-t)*(C2-2*C1+S) + 6*t*(T-2*C2+C1)

The curve starts at S and moves toward C1 and on to T from the direction of C2. Points C1 and C2 provide directional information and the distance between them determines "how far" and "how fast" the curve moves towards C1 before turning towards C2.

Parameters
[in]*winWindow Structure of active window
[in]SStart
[in]C1Control 1
[in]C2Control 2
[in]TTarget
[in]stepsline segments along curve (1..N)
[in]colorLine color
Returns
count of line segments

Definition at line 1545 of file ili9341.c.

void tft_bit_blit ( window win,
uint8_t ptr,
int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h 
)

BLIT functions

BLIT a bit array to the display

Parameters
[in]win*window structure
[in]*ptrbit array w * h in size
[in]xBLITX offset
[in]yBLIT Y offset
[in]wBLIT Width
[in]hBLIT Height
Returns
void TODO CLIP window - depends on blit array

Definition at line 234 of file ili9341.c.

Referenced by tft_drawChar().

MEMSPACE void tft_cleareol ( window win)

Character and String functions

====================================Clear display to end of line

Parameters
[in]win*window structure return: void, win->x = win->w

Definition at line 1601 of file ili9341.c.

Referenced by tft_putch(), and user_loop().

MEMSPACE void tft_clearline ( window win)

Clear display text line.

Parameters
[in]win*window structure return: void, win->x = 0

Definition at line 1621 of file ili9341.c.

MEMSPACE void tft_clip_xy ( window win,
int16_t *  X,
int16_t *  Y 
)

Clip X,Y to fix inside specifiied window.

Parameters
[in]*winwindow structure
[in]*XX position in window
[in]*YY position is window return: void

Definition at line 1114 of file ili9341.c.

void tft_Cmd ( uint8_t  cmd)

Transmit 8 bit command.

=============================================================

Parameters
[in]cmddisplay command return: void status is in data array - bytes in size

Definition at line 53 of file ili9341.c.

Referenced by tft_bit_blit(), tft_Cmd_Data_TX(), tft_FillPolyLine(), tft_fillRectWH(), tft_invertDisplay(), tft_readPixel(), tft_readRect(), tft_readRegister(), and tft_writeRect().

void tft_Cmd_Data_TX ( uint8_t  cmd,
uint8_t data,
int  bytes 
)

Transmit 8 bit command and optionally send data buffer.

Parameters
[in]cmddisplay command
[in]*datadata buffer to send after command
[in]bytesdata buffer size return: void status is in data array - bytes in size

Definition at line 72 of file ili9341.c.

Referenced by tft_abs_window(), tft_configRegister(), tft_drawPixel(), and tft_setRotation().

uint8_t tft_Data ( uint8_t  data)

Transmit 8 bit data amd read 8bit data.

Parameters
[in]datadisplay command return: read result

Definition at line 61 of file ili9341.c.

Referenced by tft_readRegister().

void tft_drawFastHLine ( window win,
int16_t  x,
int16_t  y,
int16_t  w,
uint16_t  color 
)

Fast virtical line drawing.

Parameters
[in]*winwindow structure
[in]xX offset
[in]yY offset
[in]wWidth of line
[in]colorColor
Returns
void

Definition at line 1329 of file ili9341.c.

Referenced by tft_drawRect(), tft_drawRoundRect(), tft_FillPolyLine(), and tft_fillTriangle().

void tft_drawFastVLine ( window win,
int16_t  x,
int16_t  y,
int16_t  h,
uint16_t  color 
)

Fast virtical line drawing.

Parameters
[in]*winwindow structure
[in]xX offset
[in]yY offset
[in]hHeight of line
[in]colorColor
Returns
void

Definition at line 1314 of file ili9341.c.

Referenced by tft_drawRect(), tft_drawRoundRect(), tft_fillCircle(), and tft_fillCircleHelper().

void tft_drawLine ( window win,
int16_t  x0,
int16_t  y0,
int16_t  x1,
int16_t  y1,
uint16_t  color 
)

Draw line From my blit test code testit.c 1984 - 1985 Mike Gore.

Parameters
[in]win*window structure
[in]x0X Start
[in]y0Y Start
[in]x1X End
[in]y1Y End
[in]colorcolor to set
Returns
void Draw line Draw line from CERTS https://github.com/CHERTS/esp8266-devkit/tree/master/Espressif/examples/esp8266_ili9341
Parameters
[in]win*window structure
[in]x0X Start
[in]y0Y Start
[in]x1X End
[in]y1Y End
[in]colorcolor to set
Returns
void

Definition at line 1389 of file ili9341.c.

Referenced by tft_Bezier2(), tft_Bezier3(), tft_drawFastHLine(), tft_drawTriangle(), and wire_draw().

void tft_drawPixel ( window win,
int16_t  x,
int16_t  y,
int16_t  color 
)

Pixel functions

====================================Draw one pixel set to color in 16bit 565 RGB format We clip the window to the current view

Parameters
[in]win*window structure
[in]xX Start
[in]yY Start
[in]colorcolor to set
Returns
void

Definition at line 717 of file ili9341.c.

Referenced by tft_bit_blit(), tft_drawCircle(), tft_drawCircleHelper(), tft_drawFastHLine(), tft_flood(), tft_floodline(), tft_writeRect(), and user_tests().

int tft_FillPolyLine ( window win,
int16_t  x,
int16_t  y,
int  w,
uint16_t  color 
)

Definition at line 510 of file ili9341.c.

void tft_fillRectWH ( window win,
int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h,
uint16_t  color 
)

Partial window Fill with color We clip the window to the current view.

Parameters
[in]win*window structure
[in]xX Start
[in]yY Start
[in]wWidth
[in]hHeight
[in]colorFill color
Returns
void

Definition at line 627 of file ili9341.c.

Referenced by tft_cleareol(), tft_clearline(), tft_drawChar(), tft_drawFastHLine(), tft_drawFastVLine(), tft_fillRectXY(), tft_fillRoundRect(), tft_fillWin(), tft_putch(), and tft_Vscroll().

void tft_fillRectXY ( window win,
int16_t  x,
int16_t  y,
int16_t  xl,
int16_t  yl,
uint16_t  color 
)

Fill rectangle with color We clip the window to the current view.

Parameters
[in]win*window structure
[in]xX Start
[in]yY Start
[in]xlX End
[in]ylY End
[in]colorFill color
Returns
void

Definition at line 690 of file ili9341.c.

Referenced by tft_drawFastHLine().

void tft_fillWin ( window win,
uint16_t  color 
)

Fill functions

====================================Fill window

Parameters
[in]win*window structure
[in]colorFill color

Definition at line 334 of file ili9341.c.

Referenced by test_types(), tft_init(), and tft_putch().

void tft_flood ( window win,
int16_t  x,
int16_t  y,
uint16_t  border,
uint16_t  fill 
)

Flood fill.

See also
https://en.wikipedia.org/wiki/Flood_fill This method can eat all your ram with "busy" images and could crash
Parameters
[in]win*window structure
[in]borderborder color
[in]fillFill color

Definition at line 346 of file ili9341.c.

Referenced by tft_flood().

int tft_floodline ( window win,
int16_t  x,
int16_t  y,
uint16_t  border,
uint16_t  fill 
)

Flood using line fill method.

See also
https://en.wikipedia.org/wiki/Flood_fill FIXME: not tested yet
Parameters
[in]win*window structure
[in]xX position to fill from
[in]yY position to fill from
[in]borderborder color
[in]fillFill color @ return true one success, 0 of stack overflow

Definition at line 416 of file ili9341.c.

MEMSPACE void tft_font_fixed ( window win)

Only works if font is proportional type

Parameters
[in]win*window structure return: void

Definition at line 1278 of file ili9341.c.

Referenced by user_loop().

MEMSPACE void tft_font_var ( window win)

Set current font type to variable.

Parameters
[in]win*window structure return: void

Definition at line 1288 of file ili9341.c.

Referenced by test_types().

int tft_get_font_height ( window win)

Get font height.

Parameters
[in]win*window structure return: font Height or zero on error

Definition at line 1296 of file ili9341.c.

MEMSPACE window* tft_init ( void  )

Initialize TFT.

Returns
diplay ID 9341

Definition at line 178 of file ili9341_hal.c.

Referenced by setup().

MEMSPACE void tft_invertDisplay ( int  flag)

Invert the display.

Parameters
[in]flagtrue or false
Returns
void

Definition at line 1045 of file ili9341.c.

int tft_pop_xy ( int16_t *  x,
int16_t *  y 
)

point push

Parameters
[in]xX
[in]yY @ return true if data exists, 0 of none

Definition at line 397 of file ili9341.c.

Referenced by tft_floodline().

int tft_push_xy ( int16_t  x,
int16_t  y 
)

point push

Parameters
[in]xX
[in]yY @ return true on success, 0 of stack overflow

Definition at line 380 of file ili9341.c.

Referenced by tft_floodline().

void tft_putch ( window win,
int  c 
)

put character in current winoow

Parameters
[in]win*window structure
[in]ccharacter return: void

Definition at line 1643 of file ili9341.c.

Referenced by _putc_win(), and _putc_win_len().

MEMSPACE uint32_t tft_readId ( void  )

Read ILI9341 device ID should be 9341 This does not work for really high SPI clock speeds Make sure that when called the clock speed in reduced.

See also
tft_init
Returns
32bit value with DIPLAY ID

Paramter 0 is unused See Read ID4 Command ( 0xd3 ) for a description of the parameters

Definition at line 206 of file ili9341.c.

Referenced by tft_init().

uint16_t tft_readPixel ( window win,
int16_t  x,
int16_t  y 
)

Read one pixel and return color in 1bit 565 RGB format We clip the window to the current view Note: Read Memory must be done in a continious write/read operation Chip select can not be deactivated for the transaction.

Parameters
[in]win*window structure
[in]xX Start
[in]yY Start
Returns
color in 565 format

Definition at line 952 of file ili9341.c.

Referenced by tft_flood(), tft_floodline(), and user_tests().

void tft_readRect ( window win,
int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h,
uint16_t color 
)

Definition at line 837 of file ili9341.c.

Referenced by loop(), and tft_Vscroll().

MEMSPACE uint32_t tft_readRegister ( uint8_t  command,
uint8_t  parameter 
)

====================================

====================================================================== SPIRead parameters on SPI bus ILI9341 displays For those displays that do not have the EXTC pin asserted. This undocumented command overrides the restriction for reading command parameters. Notes: SPI configurations See M:[0-3] control bits in ILI9341 documenation

  • Refer to interface I and II modes. Most ILI9341 displays are using interface I, (Rather the interface II mode)
    Parameters
    [in]commandcommand whose parameters we want to read
    [in]parameterparameter number
    Returns
    16bit value

Definition at line 166 of file ili9341.c.

Referenced by tft_readId().

int32_t tft_rel_window ( window win,
int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h 
)

Set the ili9341 working window by relative position and size Note: Function clips x,y,w,y.

Parameters
[in]win*window structure
[in]xStarting X offset
[in]yStarting Y offset
[in]wWidth
[in]hHeight
Returns
bytes w * h after clipping, 0 on error

Definition at line 140 of file ili9341.c.

Referenced by tft_bit_blit(), tft_drawPixel(), tft_FillPolyLine(), tft_fillRectWH(), tft_readPixel(), tft_readRect(), and tft_writeRect().

void tft_reset_disable ( void  )

disnable ILI9341 reset return: void

Definition at line 120 of file ili9341_hal.c.

Referenced by tft_init().

void tft_reset_enable ( void  )

enable ILI9341 reset return: void

Definition at line 103 of file ili9341_hal.c.

Referenced by tft_init().

void tft_reset_init ( void  )

Initialize ILI9341 reset GPIO return: void.

Definition at line 94 of file ili9341_hal.c.

Referenced by tft_init().

MEMSPACE void tft_set_font ( window win,
uint16_t  index 
)

Set current font size (per current rotation)

Parameters
[in]win*window structure
[in]indexfont index (for array of fonts) return: void

Definition at line 1267 of file ili9341.c.

Referenced by test_types(), and user_loop().

MEMSPACE void tft_set_textpos ( window win,
int16_t  x,
int16_t  y 
)

Set current window text pointer in characters (per current rotation) - overall font bounding box.

Parameters
[in]win*window structure
[in]xx offset
[in]yy oofset return: void

Definition at line 1254 of file ili9341.c.

Referenced by test_types(), and user_loop().

MEMSPACE void tft_setpos ( window win,
int16_t  x,
int16_t  y 
)

Set current window text pointer in pixels (per current rotation)

Parameters
[in]win*window structure
[in]xx offset
[in]yy oofset return: void

Definition at line 1241 of file ili9341.c.

MEMSPACE void tft_setRotation ( uint8_t  m)

Set Display rotation, applies to the master window only Set hardware display rotation and memory fill option bits Update software display limits FIXME Work in progress.

  • do we want to handle exchanging min/max values - rather then set them ?
    Returns
    void

Definition at line 982 of file ili9341.c.

Referenced by test_types(), tft_init(), and user_tests().

MEMSPACE void tft_setTextColor ( window win,
uint16_t  fg,
uint16_t  bg 
)

====================================

Set text forground and background color

Parameters
[in]win*window structure
[in]fgforground color
[in]bgbackground color
Returns
void

Definition at line 1228 of file ili9341.c.

Referenced by test_types().

void tft_spi_begin ( void  )

Obtain SPI bus for TFT display, assert chip select return: void.

Definition at line 80 of file ili9341_hal.c.

Referenced by tft_bit_blit(), tft_Cmd_Data_TX(), tft_FillPolyLine(), tft_fillRectWH(), tft_invertDisplay(), tft_readPixel(), tft_readRect(), tft_readRegister(), and tft_writeRect().

void tft_spi_end ( void  )

Release SPI bus from TFT display, deassert chip select return: void.

Definition at line 87 of file ili9341_hal.c.

Referenced by tft_bit_blit(), tft_Cmd_Data_TX(), tft_FillPolyLine(), tft_fillRectWH(), tft_invertDisplay(), tft_readPixel(), tft_readRect(), tft_readRegister(), and tft_writeRect().

void tft_spi_init ( uint32_t  prescale)
void tft_spi_RX ( uint8_t data,
int  bytes,
uint8_t  command 
)

read 8 bit data array

Parameters
[in]*datadata buffer to send
[in]bytesdata buffer size
[in]command1 = command, 0 = data return: void

Definition at line 165 of file ili9341_hal.c.

Referenced by tft_FillPolyLine(), tft_readPixel(), and tft_readRect().

void tft_spi_TX ( uint8_t data,
int  bytes,
uint8_t  command 
)

Transmit 8 bit data array.

Parameters
[in]*datadata buffer to send
[in]bytesdata buffer size
[in]command1 = command, 0 = data return: void

Definition at line 134 of file ili9341_hal.c.

Referenced by tft_bit_blit(), tft_Cmd(), tft_Cmd_Data_TX(), tft_fillRectWH(), and tft_writeRect().

void tft_spi_TXRX ( uint8_t data,
int  bytes,
uint8_t  command 
)

Transmit and read 8 bit data array.

Parameters
[in]*datadata buffer to send
[in]bytesdata buffer size
[in]command1 = command, 0 = data return: void

Definition at line 149 of file ili9341_hal.c.

Referenced by tft_Data().

void tft_Vscroll ( window win,
int  dir 
)

Scroll window up by dir lines We start at the top of the window and move down.

Parameters
[in]win*window structure
[in]dirdirection and count TODO +/- scroll direction TODO +/- Horizontal scroll functions

Definition at line 903 of file ili9341.c.

Referenced by tft_drawChar().

MEMSPACE int tft_window_clip ( window win)

Clip window structure to TFT limits.

Parameters
[in]win*window structure
Returns
0 - or - count of clipped values FIXME check negitive offsets, etc

Definition at line 1059 of file ili9341.c.

MEMSPACE int tft_window_clip_args ( window win,
int16_t *  x,
int16_t *  y,
int16_t *  w,
int16_t *  h 
)

clip arguments to window limits Arguments position x,y width w and height h to be clipped

Parameters
[in]*winwindow structure we will use to clip arguments to.
[in]*xX argument offset
[in]*yY argument offset
[in]*wW argument width
[in]*hH argument height
Returns
void FIXME check negitive offsets, etc

Definition at line 1145 of file ili9341.c.

Referenced by tft_abs_window(), tft_bit_blit(), and tft_window_init().

MEMSPACE void tft_window_init ( window win,
int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h 
)

Initialize window structure we default values FIXME check x+w, y+h absolute limits against TFT limuts.

Parameters
[in]win*window structure
[in]xX offset to window start - absolute
[in]yY offset to window start - absolute
[in]wWindow width
[in]hWindow Height
Returns
void

Definition at line 1198 of file ili9341.c.

Referenced by test_types(), and tft_init().

void tft_writeRect ( window win,
int16_t  x,
int16_t  y,
int16_t  w,
int16_t  h,
uint16_t color 
)

Write a rectangle pixel array.

Parameters
[in]win*window structure
[in]xX offset
[in]yY offset
[in]wWidth
[in]hHeight
[in]*colorpixel array in 565 format
Returns
void

Definition at line 745 of file ili9341.c.

Referenced by tft_drawBitmap(), and tft_Vscroll().