Basically i glued Peter Drescher and Simon Ford libs in a GraphicsDisplay class, then derived TFT or LCD class (which inherits Protocols class), then the most derived ones (Inits), which are per-display and are the only part needed to be adapted to diff hw.
Fork of UniGraphic by
GraphicsDisplay Class Reference
A common base class for Graphics displays. More...
#include <GraphicsDisplay.h>
Inherits TextDisplay.
Inherited by LCD, TFT, and TFT932x.
Public Member Functions | |
GraphicsDisplay (const char *name) | |
Create a GraphicsDisplay interface. | |
virtual void | pixel (int x, int y, unsigned short color)=0 |
Draw a pixel in the specified color. | |
virtual void | window (int x, int y, int w, int h)=0 |
Set the window, which controls where items are written to the screen. | |
virtual void | window_pushpixel (unsigned short color)=0 |
Push a single pixel into the window and increment position. | |
virtual void | window_pushpixel (unsigned short color, unsigned int count)=0 |
Push some pixels of the same color into the window and increment position. | |
virtual void | window_pushpixelbuf (unsigned short *color, unsigned int lenght)=0 |
Push array of pixel colors into the window and increment position. | |
virtual void | copy_to_lcd ()=0 |
If framebuffer is used, it needs to be sent to LCD from time to time. | |
virtual void | WindowMax (void) |
Set window to max possible size May be overridden in a derived class. | |
virtual void | cls () |
clear the entire screen Basically it sets windomax then fill with background color May be overridden in a derived class. | |
virtual void | circle (int x, int y, int r, unsigned short color) |
draw a circle | |
virtual void | fillcircle (int x, int y, int r, unsigned short color) |
draw a filled circle | |
virtual void | line (int x0, int y0, int x1, int y1, unsigned short color) |
draw a 1 pixel line | |
void | hline (int x0, int x1, int y, unsigned short color) |
draw a horizontal line | |
void | vline (int y0, int y1, int x, unsigned short color) |
draw a vertical line | |
virtual void | rect (int x0, int y0, int x1, int y1, unsigned short color) |
draw a rect | |
virtual void | fillrect (int x0, int y0, int x1, int y1, unsigned short color) |
draw a filled rect | |
virtual void | locate (int x, int y) |
setup cursor position for text | |
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 (int x, int y, int w, int h, unsigned char *bitmap) |
paint a bitmap on the TFT | |
void | Bitmap_BW (Bitmap_s bm, int x, int y) |
paint monochrome bitmap to screen | |
int | BMP_16 (int x, int y, const char *Name_BMP) |
paint a 16 bit BMP from filesytem on the TFT (slow) | |
void | set_font (unsigned char *f, unsigned char firstascii=32, unsigned char lastascii=127, bool proportional=true) |
select the font to use | |
virtual int | columns () |
Get the number of columns based on the currently active font. | |
virtual int | rows () |
Get the number of rows based on the currently active font. | |
int | width () |
get the current oriented screen width in pixels | |
int | height () |
get the current oriented screen height in pixels | |
void | set_width (int width) |
set the current oriented screen width in pixels | |
void | set_height (int height) |
set the current oriented screen height in pixels | |
void | set_auto_up (bool up) |
setup auto update of screen | |
bool | get_auto_up (void) |
get status of the auto update function | |
virtual bool | claim (FILE *stream) |
redirect output from a stream (stoud, sterr) to display | |
virtual void | foreground (uint16_t colour) |
set the foreground color | |
virtual void | background (uint16_t colour) |
set the background color |
Detailed Description
A common base class for Graphics displays.
Definition at line 53 of file GraphicsDisplay.h.
Constructor & Destructor Documentation
GraphicsDisplay | ( | const char * | name ) |
Create a GraphicsDisplay interface.
- Parameters:
-
name The name used by the parent class to access the interface
Definition at line 27 of file GraphicsDisplay.cpp.
Member Function Documentation
int _putc | ( | int | value ) | [virtual] |
put a char on the screen
- Parameters:
-
value char to print
- Returns:
- printed char
Reimplemented from TextDisplay.
Definition at line 248 of file GraphicsDisplay.cpp.
void background | ( | uint16_t | colour ) | [virtual, inherited] |
set the background color
- Note:
- this method may be overridden in a derived class.
- Parameters:
-
color is color to use for background drawing.
Definition at line 61 of file TextDisplay.cpp.
void Bitmap | ( | int | x, |
int | y, | ||
int | w, | ||
int | h, | ||
unsigned char * | bitmap | ||
) |
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 334 of file GraphicsDisplay.cpp.
void Bitmap_BW | ( | Bitmap_s | bm, |
int | x, | ||
int | y | ||
) |
paint monochrome bitmap to screen
- Parameters:
-
bm Bitmap in flash x x start y y start
Definition at line 309 of file GraphicsDisplay.cpp.
int BMP_16 | ( | int | x, |
int | y, | ||
const char * | Name_BMP | ||
) |
paint a 16 bit BMP from filesytem on the TFT (slow)
- Parameters:
-
x,y : position of upper left corner *Name_BMP name of the BMP file with drive: "/local/test.bmp"
- Returns:
- 1 if bmp file was found and painted
- 0 if bmp file was found not found
- -1 if file is no bmp
- -2 if bmp file is no 16 bit bmp
- -3 if bmp file is to big for screen
- -4 if buffer malloc go wrong
bitmap format: 16 bit R5 G6 B5
use Gimp to create / load , save as BMP, option 16 bit R5 G6 B5 copy to internal file system or SD card
Definition at line 360 of file GraphicsDisplay.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
Implements TextDisplay.
Definition at line 262 of file GraphicsDisplay.cpp.
void circle | ( | int | x, |
int | y, | ||
int | r, | ||
unsigned short | color | ||
) | [virtual] |
draw a circle
- Parameters:
-
x0,y0 center r radius color 16 bit color *
Definition at line 58 of file GraphicsDisplay.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
- Note:
- this method may be overridden in a derived class.
- Returns:
- true if the claim succeeded.
Definition at line 65 of file TextDisplay.cpp.
void cls | ( | void | ) | [virtual] |
clear the entire screen Basically it sets windomax then fill with background color May be overridden in a derived class.
Reimplemented from TextDisplay.
Reimplemented in LCD, TFT, and TFT932x.
Definition at line 442 of file GraphicsDisplay.cpp.
int columns | ( | ) | [virtual] |
Get the number of columns based on the currently active font.
- Returns:
- number of columns.
- Note:
- this method may be overridden in a derived class.
Implements TextDisplay.
Definition at line 226 of file GraphicsDisplay.cpp.
virtual void copy_to_lcd | ( | ) | [pure virtual] |
void fillcircle | ( | int | x, |
int | y, | ||
int | r, | ||
unsigned short | color | ||
) | [virtual] |
draw a filled circle
- Parameters:
-
x0,y0 center r radius color 16 bit color *
Definition at line 75 of file GraphicsDisplay.cpp.
void fillrect | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
unsigned short | color | ||
) | [virtual] |
draw a filled rect
- Parameters:
-
x0,y0 top left corner x1,y1 down right corner color 16 bit color
Definition at line 207 of file GraphicsDisplay.cpp.
void foreground | ( | uint16_t | colour ) | [virtual, inherited] |
set the foreground color
- Note:
- this method may be overridden in a derived class.
- Parameters:
-
color is color to use for foreground drawing.
Definition at line 57 of file TextDisplay.cpp.
bool get_auto_up | ( | void | ) |
get status of the auto update function
- Returns:
- if auto update is on
Definition at line 456 of file GraphicsDisplay.cpp.
int height | ( | ) |
get the current oriented screen height in pixels
- Returns:
- screen height in pixels.
Definition at line 54 of file GraphicsDisplay.cpp.
void hline | ( | int | x0, |
int | x1, | ||
int | y, | ||
unsigned short | color | ||
) |
draw a horizontal line
- Parameters:
-
x0 horizontal start x1 horizontal stop y vertical position color 16 bit color
Definition at line 96 of file GraphicsDisplay.cpp.
void line | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
unsigned short | color | ||
) | [virtual] |
draw a 1 pixel line
- Parameters:
-
x0,y0 start point x1,y1 stop point color 16 bit color
Definition at line 114 of file GraphicsDisplay.cpp.
void locate | ( | int | x, |
int | y | ||
) | [virtual] |
setup cursor position for text
- Parameters:
-
x x-position (top left) y y-position
Reimplemented from TextDisplay.
Definition at line 221 of file GraphicsDisplay.cpp.
virtual void pixel | ( | int | x, |
int | y, | ||
unsigned short | color | ||
) | [pure virtual] |
void rect | ( | int | x0, |
int | y0, | ||
int | x1, | ||
int | y1, | ||
unsigned short | color | ||
) | [virtual] |
draw a rect
- Parameters:
-
x0,y0 top left corner x1,y1 down right corner color 16 bit color *
Definition at line 185 of file GraphicsDisplay.cpp.
int rows | ( | ) | [virtual] |
Get the number of rows based on the currently active font.
- Returns:
- number of rows.
- Note:
- this method may be overridden in a derived class.
Implements TextDisplay.
Definition at line 230 of file GraphicsDisplay.cpp.
void set_auto_up | ( | bool | up ) |
setup auto update of screen
- Parameters:
-
up 1 = on , 0 = off if switched off the program has to call copy_to_lcd() to update screen from framebuffer
Definition at line 451 of file GraphicsDisplay.cpp.
void set_font | ( | unsigned char * | f, |
unsigned char | firstascii = 32 , |
||
unsigned char | lastascii = 127 , |
||
bool | proportional = true |
||
) |
select the font to use
- Parameters:
-
f pointer to font array firstascii first ascii code present in font array, default 32 (space) lastascii last ascii code present in font array, default 127 (DEL) proportional enable/disable variable font width (default enabled)
font array can 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 byte / char (not used in this revision, set to whatever)
- the vertial size in pixel
- the horizontal size in pixel
- the number of byte per vertical line (not used in this revision, set to whatever) you also have to change the array to cont unsigned char[] and __align(2)
Definition at line 234 of file GraphicsDisplay.cpp.
void set_height | ( | int | height ) |
set the current oriented screen height in pixels
- Parameters:
-
height screen height in pixels.
Definition at line 46 of file GraphicsDisplay.cpp.
void set_width | ( | int | width ) |
set the current oriented screen width in pixels
- Parameters:
-
width screen width in pixels.
Definition at line 42 of file GraphicsDisplay.cpp.
void vline | ( | int | y0, |
int | y1, | ||
int | x, | ||
unsigned short | color | ||
) |
draw a vertical line
- Parameters:
-
x horizontal position y0 vertical start y1 vertical stop color 16 bit color
Definition at line 105 of file GraphicsDisplay.cpp.
int width | ( | ) |
get the current oriented screen width in pixels
- Returns:
- screen width in pixels.
Definition at line 50 of file GraphicsDisplay.cpp.
virtual void window | ( | int | x, |
int | y, | ||
int | w, | ||
int | h | ||
) | [pure virtual] |
Set the window, which controls where items are written to the screen.
When something hits the window width, it wraps back to the left side and down a row. If the initial write is outside the window, it will be captured into the window when it crosses a boundary.
- Parameters:
-
x is the left edge in pixels. y is the top edge in pixels. w is the window width in pixels. h is the window height in pixels.
- Note:
- this method must be overridden in a derived class.
virtual void window_pushpixel | ( | unsigned short | color, |
unsigned int | count | ||
) | [pure virtual] |
virtual void window_pushpixel | ( | unsigned short | color ) | [pure virtual] |
virtual void window_pushpixelbuf | ( | unsigned short * | color, |
unsigned int | lenght | ||
) | [pure virtual] |
void WindowMax | ( | void | ) | [virtual] |
Set window to max possible size May be overridden in a derived class.
Definition at line 38 of file GraphicsDisplay.cpp.
Generated on Wed Jul 13 2022 21:19:23 by 1.7.2