orcus
Enumerations | Functions
rgb.h File Reference

RGB. More...

#include <stdint.h>

Enumerations

enum  BlendingMode { NO_BLENDING = 0 , COLOUR_KEY = 1 , ALPHA = 2 }
 Blending modes for combining regions on-screen. More...
 
enum  RgbFormat {
  P4BPP = 0 , P8BPP = 1 , RGB565 = 2 , RGB888 = 3 ,
  B1BPP = 4
}
 Bit formats in RGB region. More...
 
enum  RgbRegion {
  REGION1 = 1 , REGION2 = 2 , REGION3 = 3 , REGION4 = 4 ,
  REGION5 = 5
}
 Regions available in RGB hardware. More...
 

Functions

void rgbColourKey (uint8_t r, uint8_t g, uint8_t b)
 Set global colour key for blending. More...
 
void rgbPrintf (uint16_t *fb, int x, int y, uint16_t colour, const char *format,...)
 printf directly to RGB565 framebuffer. More...
 
void rgbPrintfBg (uint16_t *fb, int x, int y, uint16_t colour, uint16_t bgColour, const char *format,...)
 printf directly to RGB565 framebuffer with a background colour. More...
 
void rgbPutc (uint16_t *fb, int x, int y, uint16_t colour, char c)
 Render a font character on the screen. More...
 
void rgbPutcBg (uint16_t *fb, int x, int y, uint16_t colour, uint16_t bgColour, char c)
 Render a font character on the screen with a background colour. More...
 
void rgbRegionBlendAlpha (RgbRegion region, uint4_t alpha)
 Enable alpha blending for this region. More...
 
void rgbRegionBlendColourKey (RgbRegion region)
 Enable colour key blending for region. More...
 
void rgbRegionNoBlend (RgbRegion region)
 Disable blending for a region. More...
 
void rgbSetFbAddress (void *fb)
 Set RGB framebuffer address. More...
 
void rgbSetFont (uint16_t *font, int charWidth, int charHeight)
 Set font data to use. More...
 
void rgbSetPalette (uint32_t *colours, int count, uint8_t startIdx)
 Set colour palette for 4 or 8 bit modes. More...
 
void rgbSetPixelFormat (RgbFormat format)
 Configure RGB pixel format for all regions. More...
 
void rgbSetRegionPosition (RgbRegion region, int x, int y, int width, int height)
 Set region coordinates and size. More...
 
void rgbSetScale (int srcW, int srcH)
 Set source with for scaling region. More...
 
void rgbToggleRegion (RgbRegion region, bool onOff)
 Enable or disable an RGB region. More...
 

Enumeration Type Documentation

◆ BlendingMode

Enumerator
NO_BLENDING 

No blending between regions.

COLOUR_KEY 

Exclude pixels of a particular colour.

ALPHA 

Alpha blending.

◆ RgbFormat

enum RgbFormat
Enumerator
P4BPP 

4-bit palette mode, each 4 bit value (X, Y) is an index into the palette 0xXY

P8BPP 

8-bit palette mode, each byte is an index into the palette

RGB565 

16-bit RGB565 mode

RGB888 

24-bit RGB888 mode

B1BPP 

1-bit B/W mode

◆ RgbRegion

enum RgbRegion
Enumerator
REGION1 

First RGB region.

REGION2 

Second RGB region.

REGION3 

Third RGB region.

REGION4 

Fourth RGB region.

REGION5 

Fifth RGB region.

Function Documentation

◆ rgbColourKey()

void rgbColourKey ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

Set global colour key for blending RGB regions (all regions share the same key).

Parameters
rRed value to match
gGreen value to match
bBlue value to match

◆ rgbPrintf()

void rgbPrintf ( uint16_t *  fb,
int  x,
int  y,
uint16_t  colour,
const char *  format,
  ... 
)

printf directly to RGB565 framebuffer. Must have configured font first using rgbSetFont.

Note
This only works in RGB565 mode.
This has a maximum output buffer of 256 bytes.
Parameters
fbPointer to RGB565 framebuffer in which to render character
xX-coordinate at which to draw font
yY-coordinate at which to draw font
colourRGB565 colour to draw character
See also
rgbSetFont
rgbPrintfBg

◆ rgbPrintfBg()

void rgbPrintfBg ( uint16_t *  fb,
int  x,
int  y,
uint16_t  colour,
uint16_t  bgColour,
const char *  format,
  ... 
)

printf directly to RGB565 framebuffer with a background colour. Must have configured font first using rgbSetFont.

Note
This only works in RGB565 mode.
This has a maximum output buffer of 256 bytes.
Parameters
fbPointer to RGB565 framebuffer in which to render character
xX-coordinate at which to draw font
yY-coordinate at which to draw font
colourRGB565 colour to draw character
bgColourRGB565 colour to use for background
See also
rgbSetFont
rgbPrintf

◆ rgbPutc()

void rgbPutc ( uint16_t *  fb,
int  x,
int  y,
uint16_t  colour,
char  c 
)

Render a font character on the screen. Must have configured font first using rgbSetFont.

Note
This only works in RGB565 mode.
Parameters
fbPointer to RGB565 framebuffer in which to render character
xX-coordinate at which to draw font
yY-coordinate at which to draw font
colourRGB565 colour to draw character
cCharacter to draw
See also
rgbSetFont
rgbPutcBg

◆ rgbPutcBg()

void rgbPutcBg ( uint16_t *  fb,
int  x,
int  y,
uint16_t  colour,
uint16_t  bgColour,
char  c 
)

Render a font character on the screen with a background colour. Must have configured font first using rgbSetFont.

Note
This only works in RGB565 mode.
Parameters
fbPointer to RGB565 framebuffer in which to render character
xX-coordinate at which to draw font
yY-coordinate at which to draw font
colourRGB565 colour to draw character
bgColourRGB565 colour to use for background
cCharacter to draw
See also
rgbSetFont
rgbPutc

◆ rgbRegionBlendAlpha()

void rgbRegionBlendAlpha ( RgbRegion  region,
uint4_t  alpha 
)

Enable alpha blending for this region, and set alpha value.

Parameters
regionRegion to alter
alphaAlpha value (0 - 16)

◆ rgbRegionBlendColourKey()

void rgbRegionBlendColourKey ( RgbRegion  region)

Enable colour key blending for region.

Parameters
regionRegion to alter

◆ rgbRegionNoBlend()

void rgbRegionNoBlend ( RgbRegion  region)

Disable blending for a region.

Parameters
regionRegion to alter

◆ rgbSetFbAddress()

void rgbSetFbAddress ( void *  fb)

Set RGB framebuffer address. The regions all share the same base pointer and are accessed sequentially from that location.

Parameters
fbPointer to memory region which should be used as source of RGB data

◆ rgbSetFont()

void rgbSetFont ( uint16_t *  font,
int  charWidth,
int  charHeight 
)

Set font data to use for text drawing utility functions.

Note
This only works in RGB565 mode.
Parameters
fontPointer to font graphic data
charWidthWidth of font character in pixels
charHeightHeight of font character in pixels

◆ rgbSetPalette()

void rgbSetPalette ( uint32_t *  colours,
int  count,
uint8_t  startIdx 
)

Set colour palette for 4 or 8 bit modes. A palette can be up to 256 entries long (only the first 16 are used in 4bpp mode).

Parameters
coloursPointer to array of colour data in RGB888x format
countNumber of palette entries to set
startIdxFirst palette index to set

◆ rgbSetPixelFormat()

void rgbSetPixelFormat ( RgbFormat  format)

Configure RGB pixel format for all regions.

Parameters
formatFormat to use when interpreting RGB data

◆ rgbSetRegionPosition()

void rgbSetRegionPosition ( RgbRegion  region,
int  x,
int  y,
int  width,
int  height 
)

Set region coordinates and size.

Note
REGION5 cannot be moved or resized, it is always 320x240 starting at (0, 0).
Parameters
regionRegion to alter
xX-coordinate of start of region
yY-coordinate of start of region
widthWidth in pixels of region
heightHeight in pixels of region

◆ rgbSetScale()

void rgbSetScale ( int  srcW,
int  srcH 
)

Sets source width for scaling region.

Parameters
srcWSource width in pixels, scaling in X dimension disabled if set to 0
srcHSource height in pixels, scaling in Y dimension disabled if set to 0

◆ rgbToggleRegion()

void rgbToggleRegion ( RgbRegion  region,
bool  onOff 
)

Enable or disable an RGB region.

Parameters
regionRegion to alter
onOfftrue to enable a region, false to disable it