Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages

This module provides read/write from and to a framebuffer in RAM.

This is needed when using a controller that does not provide a way to read back data from the LCD controller memory. In this case we need to buffer the data in a local framebuffer to allow manipulation on pixel level. It is generally not recommended to access the framebuffer directly; this is handled by the graphic driver when needed.

Functions

void gfx_mono_framebuffer_draw_pixel (gfx_coord_t x, gfx_coord_t y, gfx_mono_color_t color)
 Draw pixel to framebuffer. More...
 
uint8_t gfx_mono_framebuffer_get_byte (gfx_coord_t page, gfx_coord_t column)
 Get a byte from the framebuffer. More...
 
void gfx_mono_framebuffer_get_page (gfx_mono_color_t *data, gfx_coord_t page, gfx_coord_t page_offset, gfx_coord_t width)
 Read a page from the framebuffer. More...
 
uint8_t gfx_mono_framebuffer_get_pixel (gfx_coord_t x, gfx_coord_t y)
 Get the pixel value at x,y in framebuffer. More...
 
void gfx_mono_framebuffer_mask_byte (gfx_coord_t page, gfx_coord_t column, gfx_mono_color_t pixel_mask, gfx_mono_color_t color)
 Read/Modify/Write a byte in the framebuffer. More...
 
void gfx_mono_framebuffer_put_byte (gfx_coord_t page, gfx_coord_t column, uint8_t data)
 Put a byte to the framebuffer. More...
 
void gfx_mono_framebuffer_put_page (gfx_mono_color_t *data, gfx_coord_t page, gfx_coord_t page_offset, gfx_coord_t width)
 Put a page from RAM to the framebuffer. More...
 
void gfx_mono_set_framebuffer (uint8_t *framebuffer)
 Set the LCD framebuffer. More...
 

void gfx_mono_framebuffer_draw_pixel ( gfx_coord_t  x,
gfx_coord_t  y,
gfx_mono_color_t  color 
)

Draw pixel to framebuffer.

Parameters
[in]xX coordinate of the pixel
[in]yY coordinate of the pixel
[in]colorPixel operation

References gfx_mono_framebuffer_get_byte(), gfx_mono_framebuffer_put_byte(), GFX_MONO_LCD_HEIGHT, GFX_MONO_LCD_PIXELS_PER_BYTE, GFX_MONO_LCD_WIDTH, GFX_PIXEL_CLR, GFX_PIXEL_SET, and GFX_PIXEL_XOR.

uint8_t gfx_mono_framebuffer_get_byte ( gfx_coord_t  page,
gfx_coord_t  column 
)

Get a byte from the framebuffer.

Parameters
[in]pagePage address
[in]columnPage offset (x coordinate)
Returns
data from LCD controller or framebuffer.

The following code will read the first byte of the framebuffer

References fbpointer, and GFX_MONO_LCD_WIDTH.

Referenced by gfx_mono_framebuffer_draw_pixel(), gfx_mono_framebuffer_get_pixel(), gfx_mono_ssd1306_get_byte(), and gfx_mono_ssd1306_put_byte().

void gfx_mono_framebuffer_get_page ( gfx_mono_color_t data,
gfx_coord_t  page,
gfx_coord_t  column,
gfx_coord_t  width 
)

Read a page from the framebuffer.

Parameters
[in]dataPointer where to store the read data
[in]pagePage address
[in]columnOffset into page (x coordinate)
[in]widthNumber of bytes to be read

The following example will read back the first 128 bytes (first page) from the framebuffer:

References fbpointer, and GFX_MONO_LCD_WIDTH.

Referenced by gfx_mono_ssd1306_get_page().

uint8_t gfx_mono_framebuffer_get_pixel ( gfx_coord_t  x,
gfx_coord_t  y 
)

Get the pixel value at x,y in framebuffer.

Parameters
[in]xX coordinate of pixel
[in]yY coordinate of pixel
Returns
Non zero value if pixel is set.

References gfx_mono_framebuffer_get_byte(), GFX_MONO_LCD_HEIGHT, GFX_MONO_LCD_PIXELS_PER_BYTE, and GFX_MONO_LCD_WIDTH.

void gfx_mono_framebuffer_mask_byte ( gfx_coord_t  page,
gfx_coord_t  column,
gfx_mono_color_t  pixel_mask,
gfx_mono_color_t  color 
)

Read/Modify/Write a byte in the framebuffer.

This function will read the byte from the framebuffer and do a mask operation on the byte according to the pixel operation selected by the color argument and the pixel mask provided.

Parameters
[in]pagePage address
[in]columnPage offset (x coordinate)
[in]pixel_maskMask for pixel operation
[in]colorPixel operation

A small example that will XOR the first byte of the framebuffer with 0xAA

References gfx_mono_get_byte, gfx_mono_put_byte, GFX_PIXEL_CLR, GFX_PIXEL_SET, and GFX_PIXEL_XOR.

void gfx_mono_framebuffer_put_byte ( gfx_coord_t  page,
gfx_coord_t  column,
uint8_t  data 
)

Put a byte to the framebuffer.

Parameters
[in]pagePage address
[in]columnPage offset (x coordinate)
[in]dataData to be written

This example will put the value 0xFF to the first byte in the framebuffer

References data, fbpointer, and GFX_MONO_LCD_WIDTH.

Referenced by gfx_mono_framebuffer_draw_pixel(), and gfx_mono_ssd1306_put_byte().

void gfx_mono_framebuffer_put_page ( gfx_mono_color_t data,
gfx_coord_t  page,
gfx_coord_t  column,
gfx_coord_t  width 
)

Put a page from RAM to the framebuffer.

Parameters
[in]dataPointer to data to be written
[in]pagePage address
[in]columnOffset into page (x coordinate)
[in]widthNumber of bytes to be written.

The following example will write 32 bytes from data_buf to the page 0, column 10 (byte 10 to 42 in the framebuffer).

gfx_mono_framebuffer_put_page(data_buf, 0, 10, 32);

References data, fbpointer, and GFX_MONO_LCD_WIDTH.

Referenced by gfx_mono_ssd1306_put_page().

void gfx_mono_set_framebuffer ( uint8_t *  framebuffer)

Set the LCD framebuffer.

Parameters
[in]framebufferA pointer to an allocated area of RAM that can hold the framebuffer.

A small example:

uint8_t framebuffer[FRAMEBUFFER_SIZE];

References fbpointer, and framebuffer.

Referenced by gfx_mono_null_init(), and gfx_mono_ssd1306_init().