COSA
An Object-Oriented Platform for Arduino Programming
OffScreen< width, height > Class Template Reference

#include <OffScreen.hh>

Inheritance diagram for OffScreen< width, height >:
Inheritance graph
Collaboration diagram for OffScreen< width, height >:
Collaboration graph

Public Types

enum  {
  BLACK = 0x0000U, WHITE = 0xFFFFU, RED = 0xF800U, GREEN = 0x07E0U,
  BLUE = 0x001FU, YELLOW = RED + GREEN, CYAN = GREEN + BLUE, MAGENTA = RED + BLUE
}
 
enum  { PORTRAIT = 0, LANDSCAPE = 1 }
 
enum  {
  END_SCRIPT = 0, CALL_SCRIPT, SET_CANVAS_COLOR, SET_PEN_COLOR,
  SET_TEXT_COLOR, SET_TEXT_SCALE, SET_TEXT_FONT, SET_CURSOR,
  MOVE_CURSOR, DRAW_BITMAP, DRAW_ICON, DRAW_PIXEL,
  DRAW_LINE, DRAW_POLY, DRAW_STROKE, DRAW_RECT,
  FILL_RECT, DRAW_ROUNDRECT, FILL_ROUNDRECT, DRAW_CIRCLE,
  FILL_CIRCLE, DRAW_CHAR, DRAW_STRING, FILL_SCREEN
}
 

Public Member Functions

 OffScreen ()
 
uint8_t * bitmap ()
 
virtual bool begin ()
 
virtual void draw_pixel (uint16_t x, uint16_t y)
 
virtual void fill_screen ()
 
virtual bool end ()
 
Contextget_context () const
 
Contextset_context (Context *context)
 
color16_t get_canvas_color () const
 
color16_t set_canvas_color (color16_t color)
 
color16_t get_pen_color () const
 
color16_t set_pen_color (color16_t color)
 
color16_t get_text_color () const
 
color16_t set_text_color (color16_t color)
 
Fontget_text_font () const
 
Fontset_text_font (Font *font)
 
uint8_t get_text_scale () const
 
uint8_t set_text_scale (uint8_t scale)
 
void get_cursor (uint16_t &x, uint16_t &y) const
 
void set_cursor (uint16_t x, uint16_t y)
 
void move_cursor (int16_t dx, int16_t dy)
 
color16_t color (uint8_t red, uint8_t green, uint8_t blue)
 
virtual uint8_t get_orientation ()
 
virtual uint8_t set_orientation (uint8_t direction)
 
void draw_pixel ()
 
virtual void draw_bitmap (uint16_t x, uint16_t y, const uint8_t *bp, uint16_t width, uint16_t height, uint8_t scale=1)
 
void draw_bitmap (const uint8_t *bp, uint16_t width, uint16_t height, uint8_t scale=1)
 
virtual void draw_icon (uint16_t x, uint16_t y, const uint8_t *bp, uint16_t width, uint16_t height, uint8_t scale=1)
 
virtual void draw_icon (uint16_t x, uint16_t y, const uint8_t *bp, uint8_t scale=1)
 
void draw_icon (const uint8_t *bp, uint8_t scale=1)
 
virtual void draw_image (uint16_t x, uint16_t y, Image *image)
 
void draw_image (Image *image)
 
virtual void draw_line (uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1)
 
void draw_line (uint16_t x1, uint16_t y1)
 
virtual void draw_vertical_line (uint16_t x, uint16_t y, uint16_t length)
 
void draw_vertical_line (uint16_t length)
 
virtual void draw_horizontal_line (uint16_t x, uint16_t y, uint16_t length)
 
void draw_horizontal_line (uint16_t length)
 
virtual void draw_poly_P (const int8_t *poly, uint8_t scale=1)
 
virtual void draw_stroke_P (const int8_t *stroke, uint8_t scale=1)
 
virtual void draw_rect (uint16_t x, uint16_t y, uint16_t width, uint16_t height)
 
void draw_rect (uint16_t width, uint16_t height)
 
virtual void fill_rect (uint16_t x, uint16_t y, uint16_t width, uint16_t height)
 
void fill_rect (uint16_t width, uint16_t height)
 
virtual void draw_roundrect (uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t radius)
 
void draw_roundrect (uint16_t width, uint16_t height, uint16_t radius)
 
virtual void fill_roundrect (uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t radius)
 
void fill_roundrect (uint16_t width, uint16_t height, uint16_t radius)
 
virtual void draw_circle (uint16_t x, uint16_t y, uint16_t radius)
 
void draw_circle (uint16_t radius)
 
virtual void fill_circle (uint16_t x, uint16_t y, uint16_t radius)
 
void fill_circle (uint16_t radius)
 
virtual void draw_char (uint16_t x, uint16_t y, char c)
 
void draw_char (char c)
 
virtual void draw_string (char *s)
 
virtual void draw_string (str_P s)
 
void run (uint8_t ix, const void_P *tab, uint8_t max)
 

Static Public Member Functions

static color16_t shade (color16_t color, uint8_t scale)
 
static color16_t blend (color16_t c1, color16_t c2)
 

Public Attributes

uint16_t WIDTH
 
uint16_t HEIGHT
 

Protected Attributes

Contextm_context
 
uint8_t m_direction
 

Static Protected Attributes

static Context context
 

Detailed Description

template<uint16_t width, uint16_t height>
class OffScreen< width, height >

Off-screen canvas for drawing before copying to the canvas device. Supports monochrome, 1-bit, pixel in off-screen buffer. Minimum implementation; draw_pixel() only.

Parameters
[in]widthof canvas.
[in]heightof canvas.

Definition at line 34 of file OffScreen.hh.

Member Enumeration Documentation

anonymous enum
inherited

Basic color palette.

Enumerator
BLACK 
WHITE 
RED 
GREEN 
BLUE 
YELLOW 
CYAN 
MAGENTA 

Definition at line 100 of file Canvas.hh.

anonymous enum
inherited
Enumerator
PORTRAIT 
LANDSCAPE 

Definition at line 371 of file Canvas.hh.

anonymous enum
inherited

Canvas script instructions. See macro set below for arguments.

Enumerator
END_SCRIPT 
CALL_SCRIPT 
SET_CANVAS_COLOR 
SET_PEN_COLOR 
SET_TEXT_COLOR 
SET_TEXT_SCALE 
SET_TEXT_FONT 
SET_CURSOR 
MOVE_CURSOR 
DRAW_BITMAP 
DRAW_ICON 
DRAW_PIXEL 
DRAW_LINE 
DRAW_POLY 
DRAW_STROKE 
DRAW_RECT 
FILL_RECT 
DRAW_ROUNDRECT 
FILL_ROUNDRECT 
DRAW_CIRCLE 
FILL_CIRCLE 
DRAW_CHAR 
DRAW_STRING 
FILL_SCREEN 

Definition at line 970 of file Canvas.hh.

Constructor & Destructor Documentation

template<uint16_t width, uint16_t height>
OffScreen< width, height >::OffScreen ( )
inline

Construct off-screen canvas with given width and height.

Definition at line 39 of file OffScreen.hh.

Member Function Documentation

template<uint16_t width, uint16_t height>
virtual bool OffScreen< width, height >::begin ( )
inlinevirtual

Start interaction with off-screen canvas.

Returns
true(1) if successful otherwise false(0).

Implements Canvas.

Definition at line 55 of file OffScreen.hh.

template<uint16_t width, uint16_t height>
uint8_t* OffScreen< width, height >::bitmap ( )
inline

Get bitmap for the off-screen canvas.

Returns
bitmap pointer.

Definition at line 45 of file OffScreen.hh.

Canvas::color16_t Canvas::blend ( color16_t  c1,
color16_t  c2 
)
staticinherited

Blend the two colors.

Parameters
[in]c1.
[in]c2.
Returns
color blend.

Definition at line 39 of file Canvas.cpp.

color16_t Canvas::color ( uint8_t  red,
uint8_t  green,
uint8_t  blue 
)
inlineinherited

Create 16-bit color from primary colors (RGB).

Parameters
[in]red.
[in]green.
[in]blue.
Returns
color.

Definition at line 549 of file Canvas.hh.

void Canvas::draw_bitmap ( uint16_t  x,
uint16_t  y,
const uint8_t *  bp,
uint16_t  width,
uint16_t  height,
uint8_t  scale = 1 
)
virtualinherited

Draw bitmap with current pen color. The bitmap must be stored in program memory.

Parameters
[in]x.
[in]y.
[in]bp.
[in]width.
[in]height.
[in]scale.

Definition at line 69 of file Canvas.cpp.

void Canvas::draw_bitmap ( const uint8_t *  bp,
uint16_t  width,
uint16_t  height,
uint8_t  scale = 1 
)
inlineinherited

Draw bitmap at cursor position with current pen color. The bitmap must be stored in program memory.

Parameters
[in]bp.
[in]width.
[in]height.
[in]scale.

Definition at line 626 of file Canvas.hh.

void Canvas::draw_char ( uint16_t  x,
uint16_t  y,
char  c 
)
virtualinherited

Draw character with current text color, font and scale.

Parameters
[in]xposition.
[in]yposition.
[in]ccharacter.

Definition at line 378 of file Canvas.cpp.

void Canvas::draw_char ( char  c)
inlineinherited

Draw character with current text color, font and scale.

Parameters
[in]ccharacter.

Definition at line 933 of file Canvas.hh.

void Canvas::draw_circle ( uint16_t  x,
uint16_t  y,
uint16_t  radius 
)
virtualinherited

Draw circle with current pen color.

Parameters
[in]x.
[in]y.
[in]radius.

Definition at line 247 of file Canvas.cpp.

void Canvas::draw_circle ( uint16_t  radius)
inlineinherited

Draw circle at cursor position with current pen color.

Parameters
[in]radius.

Definition at line 893 of file Canvas.hh.

void Canvas::draw_horizontal_line ( uint16_t  x,
uint16_t  y,
uint16_t  length 
)
virtualinherited

Draw horizontal line with current pen color.

Parameters
[in]x.
[in]y.
[in]length.

Reimplemented in GDDRAM.

Definition at line 204 of file Canvas.cpp.

void Canvas::draw_horizontal_line ( uint16_t  length)
inlineinherited

Draw horizontal line with given length and current pen color. Update cursor to new position.

Parameters
[in]length.

Definition at line 757 of file Canvas.hh.

void Canvas::draw_icon ( uint16_t  x,
uint16_t  y,
const uint8_t *  bp,
uint16_t  width,
uint16_t  height,
uint8_t  scale = 1 
)
virtualinherited

Draw icon at given position with current pen color. The icon must be stored in program memory.

Parameters
[in]x.
[in]y.
[in]bp.
[in]width.
[in]height.
[in]scale.

Definition at line 105 of file Canvas.cpp.

void Canvas::draw_icon ( uint16_t  x,
uint16_t  y,
const uint8_t *  bp,
uint8_t  scale = 1 
)
virtualinherited

Draw icon at given position with current pen color. The icon must be stored in program memory.

Parameters
[in]x.
[in]y.
[in]bp.
[in]scale.

Definition at line 113 of file Canvas.cpp.

void Canvas::draw_icon ( const uint8_t *  bp,
uint8_t  scale = 1 
)
inlineinherited

Draw icon at cursor position with current pen color. The icon must be stored in program memory.

Parameters
[in]bp.
[in]scale.

Definition at line 668 of file Canvas.hh.

void Canvas::draw_image ( uint16_t  x,
uint16_t  y,
Image image 
)
virtualinherited

Draw image on canvas at given position.

Parameters
[in]x.
[in]y.
[in]image.

Reimplemented in GDDRAM.

Definition at line 121 of file Canvas.cpp.

void Canvas::draw_image ( Image image)
inlineinherited

Draw image on canvas at current position.

Parameters
[in]image.

Definition at line 691 of file Canvas.hh.

void Canvas::draw_line ( uint16_t  x0,
uint16_t  y0,
uint16_t  x1,
uint16_t  y1 
)
virtualinherited

Draw line with current pen color.

Parameters
[in]x0.
[in]y0.
[in]x1.
[in]y1.

Definition at line 167 of file Canvas.cpp.

void Canvas::draw_line ( uint16_t  x1,
uint16_t  y1 
)
inlineinherited

Draw line to given position with current color. Update cursor to new position.

Parameters
[in]x1.
[in]y1.

Definition at line 714 of file Canvas.hh.

template<uint16_t width, uint16_t height>
virtual void OffScreen< width, height >::draw_pixel ( uint16_t  x,
uint16_t  y 
)
inlinevirtual

Set pixel according to the current pen color.

Parameters
[in]x.
[in]y.

Reimplemented from Canvas.

Definition at line 67 of file OffScreen.hh.

void Canvas::draw_pixel ( )
inlineinherited

Set pixel at cursor position with current pen color.

Definition at line 596 of file Canvas.hh.

void Canvas::draw_poly_P ( const int8_t *  poly,
uint8_t  scale = 1 
)
virtualinherited

Draw polygon from program memory with current pen color. Vector of delta positions, terminate with 0, 0. Update cursor to end position.

Parameters
[in]poly.
[in]scale.

Definition at line 210 of file Canvas.cpp.

void Canvas::draw_rect ( uint16_t  x,
uint16_t  y,
uint16_t  width,
uint16_t  height 
)
virtualinherited

Draw rectangle with current pen color.

Parameters
[in]x.
[in]y.
[in]width.
[in]height.

Definition at line 142 of file Canvas.cpp.

void Canvas::draw_rect ( uint16_t  width,
uint16_t  height 
)
inlineinherited

Draw rectangle at cursor position with current pen color.

Parameters
[in]width.
[in]height.

Definition at line 799 of file Canvas.hh.

void Canvas::draw_roundrect ( uint16_t  x,
uint16_t  y,
uint16_t  width,
uint16_t  height,
uint16_t  radius 
)
virtualinherited

Draw round corner rectangle with current pen color.

Parameters
[in]x.
[in]y.
[in]width.
[in]height.
[in]radius.

Definition at line 301 of file Canvas.cpp.

void Canvas::draw_roundrect ( uint16_t  width,
uint16_t  height,
uint16_t  radius 
)
inlineinherited

Draw round corner rectangle at cursor position with current pen color.

Parameters
[in]width.
[in]height.
[in]radius.

Definition at line 847 of file Canvas.hh.

void Canvas::draw_string ( char *  s)
virtualinherited

Draw string in current text color, font and scale.

Parameters
[in]sstring.

Definition at line 389 of file Canvas.cpp.

void Canvas::draw_string ( str_P  s)
virtualinherited

Draw string from program memory with current text color and font.

Parameters
[in]sstring in program memory (PSTR).

Definition at line 397 of file Canvas.cpp.

void Canvas::draw_stroke_P ( const int8_t *  stroke,
uint8_t  scale = 1 
)
virtualinherited

Draw stroke from program memory with current pen color. Vector of delta positions, terminated with 0, 0. The cursor is moved for when both dx and dy are zero or negative. Update cursor to new position.

Parameters
[in]stroke.
[in]scale.

Definition at line 226 of file Canvas.cpp.

void Canvas::draw_vertical_line ( uint16_t  x,
uint16_t  y,
uint16_t  length 
)
virtualinherited

Draw vertical line with current pen color.

Parameters
[in]x.
[in]y.
[in]length.

Reimplemented in GDDRAM.

Definition at line 198 of file Canvas.cpp.

void Canvas::draw_vertical_line ( uint16_t  length)
inlineinherited

Draw vertical line with given length and current pen color. Update cursor to new position.

Parameters
[in]length.

Definition at line 736 of file Canvas.hh.

template<uint16_t width, uint16_t height>
virtual bool OffScreen< width, height >::end ( )
inlinevirtual

Stop sequence of interaction with off-screen device.

Returns
true(1) if successful otherwise false(0).

Implements Canvas.

Definition at line 92 of file OffScreen.hh.

void Canvas::fill_circle ( uint16_t  x,
uint16_t  y,
uint16_t  radius 
)
virtualinherited

Fill circle with current pen color.

Parameters
[in]x.
[in]y.
[in]radius.

Definition at line 280 of file Canvas.cpp.

void Canvas::fill_circle ( uint16_t  radius)
inlineinherited

Fill circle at cursor position with current pen color.

Parameters
[in]radius.

Definition at line 913 of file Canvas.hh.

void Canvas::fill_rect ( uint16_t  x,
uint16_t  y,
uint16_t  width,
uint16_t  height 
)
virtualinherited

Fill rectangle with current pen color. Must override.

Parameters
[in]x.
[in]y.
[in]width.
[in]height.

Reimplemented in GDDRAM.

Definition at line 151 of file Canvas.cpp.

void Canvas::fill_rect ( uint16_t  width,
uint16_t  height 
)
inlineinherited

Fill rectangle at cursor position with current pen color.

Parameters
[in]width.
[in]height.

Definition at line 821 of file Canvas.hh.

void Canvas::fill_roundrect ( uint16_t  x,
uint16_t  y,
uint16_t  width,
uint16_t  height,
uint16_t  radius 
)
virtualinherited

Fill round corner rectangle with current pen color.

Parameters
[in]x.
[in]y.
[in]width.
[in]height.
[in]radius.

Definition at line 346 of file Canvas.cpp.

void Canvas::fill_roundrect ( uint16_t  width,
uint16_t  height,
uint16_t  radius 
)
inlineinherited

Fill round corner rectangle at cursor position with current pen color.

Parameters
[in]width.
[in]height.
[in]radius.

Definition at line 873 of file Canvas.hh.

template<uint16_t width, uint16_t height>
virtual void OffScreen< width, height >::fill_screen ( )
inlinevirtual

Fill offscreen buffer with canvas background color.

Reimplemented from Canvas.

Definition at line 82 of file OffScreen.hh.

color16_t Canvas::get_canvas_color ( ) const
inlineinherited

Get current canvas color.

Returns
color.

Definition at line 422 of file Canvas.hh.

Context* Canvas::get_context ( ) const
inlineinherited

Get current canvas context.

Returns
context.

Definition at line 401 of file Canvas.hh.

void Canvas::get_cursor ( uint16_t &  x,
uint16_t &  y 
) const
inlineinherited

Get current cursor position.

Parameters
[out]x.
[out]y.

Definition at line 517 of file Canvas.hh.

uint8_t Canvas::get_orientation ( )
virtualinherited

Get screen orientation.

Returns
direction (Canvas::LANDSCAPE/PORTRAIT).

Definition at line 49 of file Canvas.cpp.

color16_t Canvas::get_pen_color ( ) const
inlineinherited

Get current drawing color.

Returns
color.

Definition at line 441 of file Canvas.hh.

color16_t Canvas::get_text_color ( ) const
inlineinherited

Get current text color.

Returns
color.

Definition at line 460 of file Canvas.hh.

Font* Canvas::get_text_font ( ) const
inlineinherited

Get current text font.

Definition at line 478 of file Canvas.hh.

uint8_t Canvas::get_text_scale ( ) const
inlineinherited

Get current text scale.

Returns
text scale.

Definition at line 497 of file Canvas.hh.

void Canvas::move_cursor ( int16_t  dx,
int16_t  dy 
)
inlineinherited

Move current cursor to delta position.

Parameters
[in]dx.
[in]dy.

Definition at line 537 of file Canvas.hh.

void Canvas::run ( uint8_t  ix,
const void_P tab,
uint8_t  max 
)
inherited

Run canvas drawing script. Table may contain sub-scripts, strings and icons. All should be in program memory. Use the support macro set to write scripts.

Parameters
[in]ixscript to run.
[in]tabscript table in program memory.
[in]maxsize of script table.

Definition at line 414 of file Canvas.cpp.

color16_t Canvas::set_canvas_color ( color16_t  color)
inlineinherited

Set current canvas color. Return previous color.

Parameters
[in]color.
Returns
previous color.

Definition at line 432 of file Canvas.hh.

Context* Canvas::set_context ( Context context)
inlineinherited

Set current canvas context. Return previous context.

Parameters
[in]context.
Returns
previous context.

Definition at line 411 of file Canvas.hh.

void Canvas::set_cursor ( uint16_t  x,
uint16_t  y 
)
inlineinherited

Set current cursor position.

Parameters
[in]x.
[in]y.

Definition at line 527 of file Canvas.hh.

uint8_t Canvas::set_orientation ( uint8_t  direction)
virtualinherited

Set screen orientation. Return previous orientation.

Parameters
[in]direction(Canvas::LANDSCAPE/PORTRAIT).
Returns
previous orientation.

Reimplemented in ILI9163, ST7735, and GDDRAM.

Definition at line 55 of file Canvas.cpp.

color16_t Canvas::set_pen_color ( color16_t  color)
inlineinherited

Set current drawing color. Return previous color.

Parameters
[in]color.
Returns
previous color.

Definition at line 451 of file Canvas.hh.

color16_t Canvas::set_text_color ( color16_t  color)
inlineinherited

Set current text color. Return previous color.

Parameters
[in]color.
Returns
previous color.

Definition at line 470 of file Canvas.hh.

Font* Canvas::set_text_font ( Font font)
inlineinherited

Set current text font. Return previous font.

Parameters
[in]font.
Returns
previous font.

Definition at line 488 of file Canvas.hh.

uint8_t Canvas::set_text_scale ( uint8_t  scale)
inlineinherited

Set current text scale (1..n). Return previous scale.

Parameters
[in]scale.
Returns
previous scale.

Definition at line 507 of file Canvas.hh.

Canvas::color16_t Canvas::shade ( color16_t  color,
uint8_t  scale 
)
staticinherited

Create color shade (0..100%).

Parameters
[in]color.
[in]scale.
Returns
color shade.

Definition at line 28 of file Canvas.cpp.

Member Data Documentation

Canvas::Context Canvas::context
staticprotectedinherited

Default Canvas context (Factory pattern).

Definition at line 1009 of file Canvas.hh.

uint16_t Canvas::HEIGHT
inherited

Definition at line 370 of file Canvas.hh.

Context* Canvas::m_context
protectedinherited

Current Canvas context (Delegation pattern).

Definition at line 1012 of file Canvas.hh.

uint8_t Canvas::m_direction
protectedinherited

Canvas direction (LANDSCAPE/PORTRAIT).

Definition at line 1015 of file Canvas.hh.

uint16_t Canvas::WIDTH
inherited

Screen size; width/height and orientation.

Definition at line 369 of file Canvas.hh.


The documentation for this class was generated from the following file: