A web server for monitoring and controlling a MakerBot Replicator over the USB host and ethernet.
Dependencies: IAP NTPClient RTC mbed-rtos mbed Socket lwip-sys lwip BurstSPI
Fork of LPC1768_Mini-DK by
SPI_TFT Class Reference
Class to use TFT displays with an ILI9320 controller using SPI mode. More...
#include <SPI_TFT_ILI9320.h>
Inherits GraphicsDisplay.
Public Member Functions | |
SPI_TFT (PinName mosi, PinName miso, PinName sclk, PinName cs, const char *name="TFT") | |
Create a SPI_TFT object connected to SPI and two pins. | |
void | wr_reg (unsigned char reg, unsigned short val) |
Write a value to the to a LCD register. | |
virtual int | width () |
Get the width of the screen in pixels. | |
virtual int | height () |
Get the height of the screen in pixels. | |
virtual void | pixel (int x, int y, int colour) |
Draw a pixel at x,y with color. | |
void | WindowMax (void) |
Set draw window region to whole screen. | |
void | line (int x0, int y0, int x1, int y1, int colour) |
draw a 1 pixel line | |
void | rect (int x0, int y0, int w, int h, int colour) |
draw a rect | |
void | fillrect (int x0, int y0, int w, int h, int colour) |
draw a filled rect | |
void | draw_ellipse (int xc, int yc, int a, int b, unsigned int color) |
draw an ellipse - source : http://enchantia.com/graphapp/doc/tech/ellipses.html | |
void | fill_ellipse (int xc, int yc, int a, int b, unsigned int color) |
draw a filled ellipse - source : http://enchantia.com/graphapp/doc/tech/ellipses.html | |
virtual void | locate (int x, int y) |
setup cursor position | |
virtual void | cls (void) |
Fill the screen with _background color. | |
unsigned short | Read_ID (void) |
Read ILI9320 ID. | |
virtual int | columns (void) |
calculate the max number of char in a line | |
virtual int | rows (void) |
calculate the max number of rows | |
virtual int | _putc (int value) |
put a char on the screen | |
virtual void | character (int x, int y, int c) |
draw a character on given position out of the active font to the TFT | |
void | Bitmap (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *Name_BMP) |
paint a bitmap on the TFT | |
int | Bitmap (unsigned int x, unsigned int y, const char *Name_BMP) |
paint a BMP (16/24 bit) from filesytem on the TFT (slow) | |
void | set_font (unsigned char *f) |
select the font to use | |
void | set_orientation (unsigned int o) |
Set the orientation of the screen x,y: 0,0 is always top left. | |
void | mod_orientation (void) |
Modify the orientation of the screen x,y: 0,0 is always top left. | |
int | fileToFlash (const char *Name_BMP) |
Move an image to the background buffer. | |
void | backgroundImage (bool active) |
Use the image on the flash memory as background. | |
virtual bool | claim (FILE *stream) |
redirect output from a stream (stoud, sterr) to display | |
Protected Member Functions | |
void | hline (int x0, int x1, int y, int colour) |
draw a horizontal line | |
void | vline (int y0, int y1, int x, int colour) |
draw a vertical line | |
virtual void | window (int x, int y, int w, int h) |
Set draw window region. | |
void | tft_reset () |
Init the ILI9320 controller. | |
void | wr_dat (unsigned short value) |
Write data to the LCD controller. | |
void | wr_dat_start (void) |
Start data sequence to the LCD controller. | |
void | wr_cmd (unsigned char value) |
Write a command the LCD controller. | |
unsigned short | rd_dat (void) |
Read data from the LCD controller. | |
unsigned short | rd_reg (unsigned char reg) |
Read a LCD register. | |
void | SetCursor (unsigned short Xpos, unsigned short Ypos) |
Set the cursor position. | |
bitmapData | getBitmapData (const char *Name_BMP) |
Get bitmap info. |
Detailed Description
Class to use TFT displays with an ILI9320 controller using SPI mode.
Definition at line 61 of file SPI_TFT_ILI9320.h.
Constructor & Destructor Documentation
SPI_TFT | ( | PinName | mosi, |
PinName | miso, | ||
PinName | sclk, | ||
PinName | cs, | ||
const char * | name = "TFT" |
||
) |
Create a SPI_TFT object connected to SPI and two pins.
- Parameters:
-
mosi,miso,sclk SPI cs pin connected to CS of display reset pin connected to RESET of display
Definition at line 21 of file SPI_TFT_ILI9320.cpp.
Member Function Documentation
int _putc | ( | int | value ) | [virtual] |
put a char on the screen
- Parameters:
-
value char to print
- Returns:
- printed char
Definition at line 578 of file SPI_TFT_ILI9320.cpp.
void backgroundImage | ( | bool | active ) |
Use the image on the flash memory as background.
- Parameters:
-
active - true to use the image, false to use static color
Definition at line 837 of file SPI_TFT_ILI9320.cpp.
int Bitmap | ( | unsigned int | x, |
unsigned int | y, | ||
const char * | Name_BMP | ||
) |
paint a BMP (16/24 bit) from filesytem on the TFT (slow)
The 16-bit format is RGB-565. Using 16-bit is faster than 24-bit, however every program can output 24 bit BMPs (including MS paint), while it is hard to get them in the correct 16-bit format.
- Parameters:
-
x,y : upper left corner *Name_BMP location of the BMP file (for example "/sd/test.bmp")
- Returns:
- 1 if bmp file was found and stored
- 0 if file was not found
- -1 if file was not a bmp
- -2 if bmp file is not 16/24bit
- -3 if bmp file is wrong for screen
- -4 if buffer malloc goes wrong
Definition at line 698 of file SPI_TFT_ILI9320.cpp.
void Bitmap | ( | unsigned int | x, |
unsigned int | y, | ||
unsigned int | w, | ||
unsigned int | h, | ||
unsigned char * | Name_BMP | ||
) |
paint a bitmap on the TFT
- Parameters:
-
x,y : upper left corner w width of bitmap h high of bitmap *bitmap pointer to the bitmap data
bitmap format: 16 bit R5 G6 B5
use Gimp to create / load , save as BMP, option 16 bit R5 G6 B5 use winhex to load this file and mark data stating at offset 0x46 to end use edit -> copy block -> C Source to export C array paste this array into your program
define the array as static const unsigned char to put it into flash memory cast the pointer to (unsigned char *) : tft.Bitmap(10,40,309,50,(unsigned char *)scala);
Definition at line 675 of file SPI_TFT_ILI9320.cpp.
void character | ( | int | x, |
int | y, | ||
int | c | ||
) | [virtual] |
draw a character on given position out of the active font to the TFT
- Parameters:
-
x x-position of char (top left) y y-position c char to print
Definition at line 592 of file SPI_TFT_ILI9320.cpp.
bool claim | ( | FILE * | stream ) | [virtual, inherited] |
redirect output from a stream (stoud, sterr) to display
- Parameters:
-
stream stream that shall be redirected to the TextDisplay
Definition at line 65 of file TextDisplay.cpp.
void cls | ( | void | ) | [virtual] |
Fill the screen with _background color.
Definition at line 277 of file SPI_TFT_ILI9320.cpp.
int columns | ( | void | ) | [virtual] |
calculate the max number of char in a line
- Returns:
- max columns depends on actual font size
Definition at line 568 of file SPI_TFT_ILI9320.cpp.
void draw_ellipse | ( | int | xc, |
int | yc, | ||
int | a, | ||
int | b, | ||
unsigned int | color | ||
) |
draw an ellipse - source : http://enchantia.com/graphapp/doc/tech/ellipses.html
- Parameters:
-
xc,yc center point a,b semi-major axis and semi-minor axis color 16 bit color
Definition at line 462 of file SPI_TFT_ILI9320.cpp.
int fileToFlash | ( | const char * | Name_BMP ) |
Move an image to the background buffer.
The image must fit exactly on the screen (240x320). This function takes quite some time, depending on source filesystem.
- Parameters:
-
*Name_BMP location of the BMP file (for example "/sd/test.bmp")
- Returns:
- 1 if bmp file was found and stored
- 0 if file was not found
- -1 if file was not a bmp
- -2 if bmp file is not 16/24bit
- -3 if bmp file is wrong for screen
- -4 if buffer malloc goes wrong
Definition at line 759 of file SPI_TFT_ILI9320.cpp.
void fill_ellipse | ( | int | xc, |
int | yc, | ||
int | a, | ||
int | b, | ||
unsigned int | color | ||
) |
draw a filled ellipse - source : http://enchantia.com/graphapp/doc/tech/ellipses.html
- Parameters:
-
xc,yc center point a,b semi-major axis and semi-minor axis color 16 bit color
Definition at line 496 of file SPI_TFT_ILI9320.cpp.
void fillrect | ( | int | x0, |
int | y0, | ||
int | w, | ||
int | h, | ||
int | colour | ||
) |
draw a filled rect
- Parameters:
-
x0,y0 top left corner w,h width and height color 16 bit color
Definition at line 435 of file SPI_TFT_ILI9320.cpp.
SPI_TFT::bitmapData getBitmapData | ( | const char * | Name_BMP ) | [protected] |
Get bitmap info.
- Parameters:
-
*Name_BMP Bitmap filename
- Returns:
- structure: return_code 1 if bmp file was found and stored 0 if file was not found -1 if file was not a bmp -2 if bmp file is not 16/24bit -3 if bmp file is wrong for screen width, height Bitmap size bits, pad BPP, padding (multiple of 4 bytes) start_data Starting address of the byte where the bitmap image data (pixel array) can be found *file Bitmap filename
Definition at line 843 of file SPI_TFT_ILI9320.cpp.
int height | ( | ) | [virtual] |
Get the height of the screen in pixels.
- Returns:
- height of screen in pixels
Definition at line 39 of file SPI_TFT_ILI9320.cpp.
void hline | ( | int | x0, |
int | x1, | ||
int | y, | ||
int | colour | ||
) | [protected] |
draw a horizontal line
- Parameters:
-
x0 horizontal start x1 horizontal stop y vertical position color 16 bit color
Definition at line 308 of file SPI_TFT_ILI9320.cpp.
void line | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
int | colour | ||
) |
draw a 1 pixel line
- Parameters:
-
x0,y0 start point x1,y1 stop point color 16 bit color
Definition at line 352 of file SPI_TFT_ILI9320.cpp.
void locate | ( | int | x, |
int | y | ||
) | [virtual] |
setup cursor position
- Parameters:
-
x x-position (top left) y y-position
Definition at line 562 of file SPI_TFT_ILI9320.cpp.
void mod_orientation | ( | void | ) |
Modify the orientation of the screen x,y: 0,0 is always top left.
- Parameters:
-
none ILI9320 limitation: The orientation can only be used with a window command (registers 0x50..0x53)
reg 03h (Entry Mode) : BGR = 1 - ORG = 1 - ID0, ID1 and AM are set according to the orientation variable. IMPORTANT : when ORG = 1, the GRAM writing direction follows the orientation (ID0, ID1, AM bits) AND we need to use the window command (reg 50h..53h) to write to an area on the display because we cannot change reg 20h and 21h to set the GRAM address (they both remain at 00h). This means that the pixel routine does not work when ORG = 1. Routines relying on the pixel routine first need to set reg 03h = 0x1030 (cls, circle and line do so) AND need to write the data according to the orientation variable.
Definition at line 51 of file SPI_TFT_ILI9320.cpp.
void pixel | ( | int | x, |
int | y, | ||
int | colour | ||
) | [virtual] |
Draw a pixel at x,y with color.
- Parameters:
-
x (horizontal position) y (vertical position) color (16 bit pixel color)
Definition at line 210 of file SPI_TFT_ILI9320.cpp.
unsigned short rd_dat | ( | void | ) | [protected] |
Read data from the LCD controller.
- Returns:
- data from LCD controller
Definition at line 95 of file SPI_TFT_ILI9320.cpp.
unsigned short rd_reg | ( | unsigned char | reg ) | [protected] |
Read a LCD register.
- Parameters:
-
reg register to be read
- Returns:
- value of the register
Definition at line 117 of file SPI_TFT_ILI9320.cpp.
unsigned short Read_ID | ( | void | ) |
void rect | ( | int | x0, |
int | y0, | ||
int | w, | ||
int | h, | ||
int | colour | ||
) |
draw a rect
- Parameters:
-
x0,y0 top left corner w,h width and height color 16 bit color *
Definition at line 425 of file SPI_TFT_ILI9320.cpp.
int rows | ( | void | ) | [virtual] |
calculate the max number of rows
- Returns:
- max rows depends on actual font size
Definition at line 573 of file SPI_TFT_ILI9320.cpp.
void set_font | ( | unsigned char * | f ) |
select the font to use
- Parameters:
-
f pointer to font array
font array can be created with GLCD Font Creator from http://www.mikroe.com you have to add 4 parameter at the beginning of the font array to use:
- the number of bytes / char
- the vertial size in pixels
- the horizontal size in pixels
- the number of bytes per vertical line you also have to change the array to char[]
Definition at line 669 of file SPI_TFT_ILI9320.cpp.
void set_orientation | ( | unsigned int | o ) |
Set the orientation of the screen x,y: 0,0 is always top left.
- Parameters:
-
o direction to use the screen (0-3) 90� Steps
Definition at line 45 of file SPI_TFT_ILI9320.cpp.
void SetCursor | ( | unsigned short | Xpos, |
unsigned short | Ypos | ||
) | [protected] |
Set the cursor position.
- Parameters:
-
x (horizontal position) y (vertical position)
Can only be used when reg 03h = 0x1030 (see note in mod_orientation).
Definition at line 143 of file SPI_TFT_ILI9320.cpp.
void tft_reset | ( | ) | [protected] |
Init the ILI9320 controller.
Definition at line 149 of file SPI_TFT_ILI9320.cpp.
void vline | ( | int | y0, |
int | y1, | ||
int | x, | ||
int | colour | ||
) | [protected] |
draw a vertical line
- Parameters:
-
x horizontal position y0 vertical start y1 vertical stop color 16 bit color
Definition at line 331 of file SPI_TFT_ILI9320.cpp.
int width | ( | ) | [virtual] |
Get the width of the screen in pixels.
- Parameters:
-
@returns width of screen in pixels
Definition at line 33 of file SPI_TFT_ILI9320.cpp.
void window | ( | int | x, |
int | y, | ||
int | w, | ||
int | h | ||
) | [protected, virtual] |
Set draw window region.
- Parameters:
-
x horizontal position y vertical position w window width in pixel h window height in pixels
Definition at line 235 of file SPI_TFT_ILI9320.cpp.
void WindowMax | ( | void | ) |
Set draw window region to whole screen.
Definition at line 271 of file SPI_TFT_ILI9320.cpp.
void wr_cmd | ( | unsigned char | value ) | [protected] |
Write a command the LCD controller.
- Parameters:
-
cmd,: command to be written
Definition at line 69 of file SPI_TFT_ILI9320.cpp.
void wr_dat | ( | unsigned short | value ) | [protected] |
Write data to the LCD controller.
- Parameters:
-
dat data written to LCD controller
Definition at line 78 of file SPI_TFT_ILI9320.cpp.
void wr_dat_start | ( | void | ) | [protected] |
Start data sequence to the LCD controller.
Definition at line 90 of file SPI_TFT_ILI9320.cpp.
void wr_reg | ( | unsigned char | reg, |
unsigned short | val | ||
) |
Write a value to the to a LCD register.
- Parameters:
-
reg register to be written val data to be written
Definition at line 111 of file SPI_TFT_ILI9320.cpp.
Generated on Tue Jul 12 2022 17:52:03 by 1.7.2