API for generic bitmap graphics library
Method | Description |
---|---|
bgcolor() |
Set background color for subsequent drawing |
bitmap() |
Copy a bitmap to the display buffer |
box() |
Draw a box |
char_attrs() |
Set attributes for text rendering |
circle() |
Draw a circle |
clear() |
Clear the display buffer |
copy() |
Copy from one screen location to another |
cut() |
Copy from one screen location to another and clear the origin to the background color |
fgcolor() |
Set foreground color of subsequent drawing operations |
font_addr() |
Set address of font definition |
font_height() |
Return the set font height |
font_sz() |
Set expected dimension of font, in pixels |
font_width() |
Return the set font width |
line() |
Draw line |
plot() |
Plot pixel |
point() |
Get color of pixel |
pos_xy() |
Set text draw position, in character-cell col and row |
putchar() |
Write a character to the display |
rgbw8888_rgb32() |
Return 32-bit long from discrete Red, Green, Blue, White color components |
rgbw8888_rgb32_brightness() |
Return 32-bit long from discrete Red, Green, Blue, White color components, and clamp brightness |
rgb565_r5() |
Return 5-bit red component of 16-bit RGB color |
rgb565_g6() |
Return 6-bit green component of 16-bit RGB color |
rgb565_b5() |
Return 5-bit blue component of 16-bit RGB color |
scale() |
Scale a region of the display up by size |
scroll_down() |
Scroll a region of the display down by one pixel |
scroll_left() |
Scroll a region of the display left by one pixel |
scroll_right() |
Scroll a region of the display right by one pixel |
scroll_up() |
Scroll a region of the display up by one pixel |
text_cols() |
Get number of displayable text columns, based on set display width and set font width |
text_rows() |
Get number of displayable text rows, based on set display height and set font height |
NOTE: In addition to the above, all terminal output-type methods are available for text
rendering, through the use of terminal.common.spinh
Set background color for subsequent drawing
- Parameters:
c
: background color
- Returns: none
- Affects:
clear()
,cut()
,putchar()
Copy a bitmap to the display buffer
- Parameters:
ptr_bmap
: address of/pointer to buffer containing bitmap data(xs, ys)
: screen location to copy bitmap to, in pixelsbm_wid
: width of bitmap, in pixelsbm_lns
: total number of lines in bitmap
- Returns: none
- NOTE: If the preprocessor symbol
GFX_DIRECT
is defined at build-time, a driver-specific implementation will be used, instead.
Draw a box
- Parameters:
(sx, sy)
: starting (upper-left) screen location of box(ex, ey)
: ending (lower-right) screen location of boxc
: color of boxf
: flag to set if box should be filled (boolean)
- Returns: none
- NOTE: If the preprocessor symbol
GFX_DIRECT
is defined at build-time, a driver-specific implementation will be used, instead.
Set attributes for text rendering
- Parameters:
attrs
: bitmask of attributes
- Returns: none
- Available symbols:
DRAW_BG
: draw the background when drawing text (warning: slower)
- Aliases:
charattrs()
Draw a circle
- Parameters:
(cx, cy)
: screen location to draw circle (center)r
: radius of circlec
: color of circlef
: flag to set if circle should be filled (boolean)
- Returns: none
Clear the display
- Parameters: none
- Returns: none
- NOTE: The display will be cleared to the color currently set by
bgcolor()
.
Copy rectangular region from one screen location to another
- Parameters:
(sx, sy)
: starting (upper-left) screen location to copy(ex, ey)
: ending (lower-right) screen location to copy(dx, dy)
: destination screen location to copy to
- Returns: none
- NOTE: This functionality depends on being able to read the current display contents, so is only
usable when a buffered display is being used. If
GFX_DIRECT
is defined at build time, this method won't be available.
Copy rectangular region from one screen location to another and clear the origin to the background color
- Parameters:
(sx, sy)
: starting (upper-left) screen location to copy(ex, ey)
: ending (lower-right) screen location to copy(dx, dy)
: destination screen location to copy to
- Returns: none
- NOTE: The region copied from will be cleared to the color set by
bgcolor()
- NOTE: This functionality depends on being able to read the current display contents, so is only
usable when a buffered display is being used. If
GFX_DIRECT
is defined at build time, this method won't be available.
Set foreground color of subsequent drawing operations
- Parameters:
c
: background color
- Returns: none
- Affects:
putchar()
Set address of font definition
- Parameters:
ptr_fnt
: address of/pointer to start of font table
- Returns: none
- Aliases:
fontaddress()
Get the currently set font height
- Parameters: none
- Returns: current font height, in pixels
- Aliases:
fontheight()
Set font rendering scale
- Parameters:
s
: factor to scale up font width and height rendering by
- Returns: none
- Aliases:
fontscale()
Set expected dimension of font
- Parameters:
w
: width of font glyphs, in pixelsh
: height of font glyphs, in pixels
- Returns: none
- Aliases:
fontsize()
Set spacing between character cells
- Parameters:
h
: horizontal space, in pixelsv
: vertical space, in pixels
- Returns: none
- Aliases:
fontspacing()
Get the currently set font width
- Parameters: none
- Returns: current font width, in pixels
- Aliases:
fontwidth()
Draw line
- Parameters:
(sx, sy)
: starting screen location of line(ex, ey)
: ending screen location of linec
: color of line
- Returns: none
- NOTE: If the preprocessor symbol
GFX_DIRECT
is defined at build time, a driver-specific implementation will be used, instead.
Plot pixel
- Parameters:
(x, y)
: screen location to draw pixelc
: color of pixel
- Returns: none
- NOTE: This method appears in the display driver, since it is implementation-specific.
Get color of pixel
- Parameters:
(x, y)
: screen location of pixel
- Returns: color of the pixel at the given screen location
- NOTE: This functionality depends on being able to read the current display contents, so is only
usable when a buffered display is being used. If
GFX_DIRECT
is defined at build time, this method won't be available.
Set text draw position, in character-cell col and row
- Parameters:
(x, y)
: screen location to position next text display, in character cell columns and rows
- Returns: none
Write a character to the display
- Parameters:
ch
: character to display
- Returns: none
- Aliases:
tx()
,char()
- NOTE: If the preprocessor symbol
GFX_DIRECT
is defined at build-time, a driver-specific implementation will be used, instead (some implementations may have limitations)
Return 32-bit long from discrete Red, Green, Blue, White color components
- Parameters:
r
: 8-bit red color componentg
: 8-bit green color componentb
: 8-bit blue color componentw
: 8-bit white color component
- Returns: 32-bit packed long comprised of the given color components
Return 32-bit long from discrete Red, Green, Blue, White color components, and clamp brightness
- Parameters:
r
: 8-bit red color componentg
: 8-bit green color componentb
: 8-bit blue color componentw
: 8-bit white color componentlevel
: brightness level, in percent
- Returns: 32-bit packed long comprised of the given color components
Get 5-bit red component of 16-bit RGB color
- Parameters:
rgb565
: 16-bit color word
- Returns: 5-bit red color component of word
Get 6-bit green component of 16-bit RGB color
- Parameters:
rgb565
: 16-bit color word
- Returns: 6-bit green color component of word
Get 5-bit blue component of 16-bit RGB color
- Parameters:
rgb565
: 16-bit color word
- Returns: 5-bit blue color component of word
Copy a region of the display to another location, and scale it up
- Parameters:
(sx, sy)
: starting screen location to copy(ex, ey)
: ending screen location to copy(dx, dy)
: destination screen location to copy toscl
: factor to scale up copied region by
- Returns: none
- NOTE: This functionality depends on being able to read the current display contents, so is only
usable when a buffered display is being used. If
GFX_DIRECT
is defined at build time, this method won't be available.
Scroll a region of the display down by 1 pixel
- Parameters:
(sx, sy)
: starting screen location to scroll(ex, ey)
: ending screen location to srcoll
- Returns: none
- NOTE: This functionality depends on being able to read the current display contents, so is only
usable when a buffered display is being used. If
GFX_DIRECT
is defined at build time, this method won't be available. - Aliases:
scrolldown()
Scroll a region of the display left by 1 pixel
- Parameters:
(sx, sy)
: starting screen location to scroll(ex, ey)
: ending screen location to srcoll
- Returns: none
- NOTE: This functionality depends on being able to read the current display contents, so is only
usable when a buffered display is being used. If
GFX_DIRECT
is defined at build time, this method won't be available. - Aliases:
scrollleft()
Scroll a region of the display right by 1 pixel
- Parameters:
(sx, sy)
: starting screen location to scroll(ex, ey)
: ending screen location to srcoll
- Returns: none
- NOTE: This functionality depends on being able to read the current display contents, so is only
usable when a buffered display is being used. If
GFX_DIRECT
is defined at build time, this method won't be available. - Aliases:
scrollright()
Scroll a region of the display up by 1 pixel
- Parameters:
(sx, sy)
: starting screen location to scroll(ex, ey)
: ending screen location to srcoll
- Returns: none
- NOTE: This functionality depends on being able to read the current display contents, so is only
usable when a buffered display is being used. If
GFX_DIRECT
is defined at build time, this method won't be available. - Aliases:
scrollup()
Get number of displayable text columns
- Parameters: none
- Returns: number of columns
- NOTE: This value depends on the display dimensions and currently set font width.
- Aliases:
textcols()
Get number of displayable text rows
- Parameters: none
- Returns: number of rows
- NOTE: This value depends on the display dimensions and currently set font height.
- Aliases:
textrows()