Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
2832HSWEG04 graphic library abstraction

This module is an abstraction layer between the graphic library and the 2832HSWEG04 monochrome LCD display connected to a SSD1306 LCD controller.

As the controller does not provide any hardware accelerated graphic, all the graphic primitives are provided by the Generic monochrome graphic primitives service.

Note
Do not call the gfx_mono_ssd1306_ functions directly. use the gfx_mono names that are defined in this header and documented in Monochrome graphical display system . Ie. gfx_mono_draw_pixel() should be used, not gfx_mono_ssd1306_draw_pixel()

Macros

#define gfx_mono_draw_circle(x, y, radius, color, octant_mask)
 
#define gfx_mono_draw_filled_circle(x, y, radius, color, quadrant_mask)
 
#define gfx_mono_draw_filled_rect(x, y, width, height, color)
 
#define gfx_mono_draw_horizontal_line(x, y, length, color)   gfx_mono_generic_draw_horizontal_line(x, y, length, color)
 
#define gfx_mono_draw_line(x1, y1, x2, y2, color)   gfx_mono_generic_draw_line(x1, y1, x2, y2, color)
 
#define gfx_mono_draw_pixel(x, y, color)   gfx_mono_ssd1306_draw_pixel(x, y, color)
 
#define gfx_mono_draw_rect(x, y, width, height, color)   gfx_mono_generic_draw_rect(x, y, width, height, color)
 
#define gfx_mono_draw_vertical_line(x, y, length, color)   gfx_mono_generic_draw_vertical_line(x, y, length, color)
 
#define gfx_mono_get_byte(page, column)   gfx_mono_ssd1306_get_byte(page, column)
 
#define gfx_mono_get_page(data, page, column, width)   gfx_mono_ssd1306_get_page(data, page, column, width)
 
#define gfx_mono_get_pixel(x, y)   gfx_mono_ssd1306_get_pixel(x, y)
 
#define gfx_mono_init()   gfx_mono_ssd1306_init()
 
#define GFX_MONO_LCD_FRAMEBUFFER_SIZE
 
#define GFX_MONO_LCD_PAGES
 
#define GFX_MONO_LCD_PIXELS_PER_BYTE   8
 
#define GFX_MONO_LCD_WIDTH   128
 
#define gfx_mono_mask_byte(page, column, pixel_mask, color)   gfx_mono_ssd1306_mask_byte(page, column, pixel_mask, color)
 
#define gfx_mono_put_bitmap(bitmap, x, y)   gfx_mono_generic_put_bitmap(bitmap, x, y)
 
#define gfx_mono_put_byte(page, column, data)   gfx_mono_ssd1306_put_byte(page, column, data, false)
 
#define gfx_mono_put_framebuffer()   gfx_mono_ssd1306_put_framebuffer()
 
#define gfx_mono_put_page(data, page, column, width)   gfx_mono_ssd1306_put_page(data, page, column, width)
 

Functions

void gfx_mono_ssd1306_draw_pixel (gfx_coord_t x, gfx_coord_t y, gfx_mono_color_t color)
 Draw pixel to screen. More...
 
uint8_t gfx_mono_ssd1306_get_byte (gfx_coord_t page, gfx_coord_t column)
 Get a byte from the display controller RAM. More...
 
void gfx_mono_ssd1306_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 LCD controller. More...
 
uint8_t gfx_mono_ssd1306_get_pixel (gfx_coord_t x, gfx_coord_t y)
 Get the pixel value at x,y. More...
 
void gfx_mono_ssd1306_init (void)
 Initialize SSD1306 controller and LCD display. More...
 
void gfx_mono_ssd1306_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 on the display controller. More...
 
void gfx_mono_ssd1306_put_byte (gfx_coord_t page, gfx_coord_t column, uint8_t data, bool force)
 Put a byte to the display controller RAM. More...
 
void gfx_mono_ssd1306_put_framebuffer (void)
 
void gfx_mono_ssd1306_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 display controller. More...
 

#define gfx_mono_draw_circle (   x,
  y,
  radius,
  color,
  octant_mask 
)
Value:
gfx_mono_generic_draw_circle(x, y, radius, color, \
octant_mask)
void gfx_mono_generic_draw_circle(gfx_coord_t x, gfx_coord_t y, gfx_coord_t radius, enum gfx_mono_color color, uint8_t octant_mask)
Draw an outline of a circle or arc (generic implementation).
Definition: gfx_mono_generic.c:301
#define gfx_mono_draw_filled_circle (   x,
  y,
  radius,
  color,
  quadrant_mask 
)
Value:
color, quadrant_mask)
void gfx_mono_generic_draw_filled_circle(gfx_coord_t x, gfx_coord_t y, gfx_coord_t radius, enum gfx_mono_color color, uint8_t quadrant_mask)
Draw a filled circle or sector (generic implementation).
Definition: gfx_mono_generic.c:390
#define gfx_mono_draw_filled_rect (   x,
  y,
  width,
  height,
  color 
)
Value:
gfx_mono_generic_draw_filled_rect(x, y, width, height, \
color)
void gfx_mono_generic_draw_filled_rect(gfx_coord_t x, gfx_coord_t y, gfx_coord_t width, gfx_coord_t height, enum gfx_mono_color color)
Draw a filled rectangle (generic implementation).
Definition: gfx_mono_generic.c:269

Referenced by gfx_mono_draw_char(), gfx_mono_menu_init(), gfx_mono_spinctrl_draw(), gfx_mono_spinctrl_draw_button(), gfx_mono_spinctrl_draw_indicator(), gfx_mono_spinctrl_draw_spin_indicator(), gfx_mono_spinctrl_spincollection_show(), and menu_draw().

#define gfx_mono_draw_horizontal_line (   x,
  y,
  length,
  color 
)    gfx_mono_generic_draw_horizontal_line(x, y, length, color)
#define gfx_mono_draw_line (   x1,
  y1,
  x2,
  y2,
  color 
)    gfx_mono_generic_draw_line(x1, y1, x2, y2, color)
#define gfx_mono_draw_rect (   x,
  y,
  width,
  height,
  color 
)    gfx_mono_generic_draw_rect(x, y, width, height, color)
#define gfx_mono_draw_vertical_line (   x,
  y,
  length,
  color 
)    gfx_mono_generic_draw_vertical_line(x, y, length, color)
#define gfx_mono_get_page (   data,
  page,
  column,
  width 
)    gfx_mono_ssd1306_get_page(data, page, column, width)
#define gfx_mono_get_pixel (   x,
 
)    gfx_mono_ssd1306_get_pixel(x, y)
#define gfx_mono_init ( )    gfx_mono_ssd1306_init()
#define GFX_MONO_LCD_FRAMEBUFFER_SIZE
Value:
#define GFX_MONO_LCD_WIDTH
Definition: gfx_mono_ug_2832hsweg04.h:65
#define GFX_MONO_LCD_HEIGHT
Definition: gfx_mono_null.h:59
#define GFX_MONO_LCD_PIXELS_PER_BYTE
Definition: gfx_mono_ug_2832hsweg04.h:69
#define GFX_MONO_LCD_PAGES
Value:
#define GFX_MONO_LCD_HEIGHT
Definition: gfx_mono_null.h:59
#define GFX_MONO_LCD_PIXELS_PER_BYTE
Definition: gfx_mono_ug_2832hsweg04.h:69

Referenced by gfx_mono_ssd1306_init().

#define gfx_mono_mask_byte (   page,
  column,
  pixel_mask,
  color 
)    gfx_mono_ssd1306_mask_byte(page, column, pixel_mask, color)
#define gfx_mono_put_bitmap (   bitmap,
  x,
 
)    gfx_mono_generic_put_bitmap(bitmap, x, y)
#define gfx_mono_put_framebuffer ( )    gfx_mono_ssd1306_put_framebuffer()
#define gfx_mono_put_page (   data,
  page,
  column,
  width 
)    gfx_mono_ssd1306_put_page(data, page, column, width)

void gfx_mono_ssd1306_draw_pixel ( gfx_coord_t  x,
gfx_coord_t  y,
gfx_coord_t  color 
)

Draw pixel to screen.

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

The following will set the pixel at x=10,y=10:

The following example will clear the pixel at x=10,y=10:

And the following will toggle the pixel at x=10,y=10:

References gfx_mono_get_byte, GFX_MONO_LCD_HEIGHT, GFX_MONO_LCD_PIXELS_PER_BYTE, GFX_MONO_LCD_WIDTH, gfx_mono_put_byte, GFX_PIXEL_CLR, GFX_PIXEL_SET, and GFX_PIXEL_XOR.

uint8_t gfx_mono_ssd1306_get_byte ( gfx_coord_t  page,
gfx_coord_t  column 
)

Get a byte from the display controller RAM.

If the LCD controller is accessed by the SPI interface we cannot read the data. In this case return the data from the local framebuffer instead.

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

The following code will read the first byte from the display memory or the local framebuffer if direct read is not possible. The data represents the pixels from x = 0 and y = 0 to y = 7.

References gfx_mono_framebuffer_get_byte(), ssd1306_read_data(), ssd1306_set_column_address(), and ssd1306_set_page_address().

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

Read a page from the LCD controller.

If the LCD controller is accessed by the SPI interface we cannot read data directly from the controller. In that case we will read the data from the local framebuffer instead.

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 display memory:

References gfx_mono_framebuffer_get_page(), ssd1306_read_data(), ssd1306_set_column_address(), and ssd1306_set_page_address().

uint8_t gfx_mono_ssd1306_get_pixel ( gfx_coord_t  x,
gfx_coord_t  y 
)

Get the pixel value at x,y.

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

The following example will read the pixel value from x=10,y=10:

pixelval = gfx_mono_ssd1306_get_pixel(10,10);

References gfx_mono_get_byte, GFX_MONO_LCD_HEIGHT, GFX_MONO_LCD_PIXELS_PER_BYTE, and GFX_MONO_LCD_WIDTH.

void gfx_mono_ssd1306_init ( void  )

Initialize SSD1306 controller and LCD display.

It will also write the graphic controller RAM to all zeroes.

Note
This function will clear the contents of the display.

References framebuffer, GFX_MONO_LCD_PAGES, GFX_MONO_LCD_WIDTH, gfx_mono_set_framebuffer(), gfx_mono_ssd1306_put_byte(), ssd1306_init(), and ssd1306_set_display_start_line_address().

void gfx_mono_ssd1306_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 on the display controller.

This function will read the byte from the display controller (or the framebuffer if we cannot read directly from the controller) 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 display memory with 0xAA

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

void gfx_mono_ssd1306_put_byte ( gfx_coord_t  page,
gfx_coord_t  column,
uint8_t  data,
bool  force 
)

Put a byte to the display controller RAM.

If the LCD controller is accessed by the SPI interface we will also put the data to the local framebuffer.

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

This example will put the value 0xFF to the first byte in the display memory setting a 8 pixel high column of pixels in the upper left corner of the display.

gfx_mono_ssd1306_put_byte(0, 0, 0xFF, false);

References gfx_mono_framebuffer_get_byte(), gfx_mono_framebuffer_put_byte(), ssd1306_set_column_address(), ssd1306_set_page_address(), and ssd1306_write_data().

Referenced by gfx_mono_ssd1306_init().

void gfx_mono_ssd1306_put_framebuffer ( void  )
void gfx_mono_ssd1306_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 display controller.

If the controller is accessed by the SPI interface, we can not read back data from the LCD controller RAM. Because of this all data that is written to the LCD controller in this mode is also written to a framebuffer in MCU RAM.

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. This will place data_buf in the rectangle x1=10,y1=0,x2=42,y2=8 (10 pixels from the upper left corner of the screen):

gfx_mono_ssd1306_put_page(data_buf, 0, 10, 32);

References gfx_mono_framebuffer_put_page(), ssd1306_set_column_address(), ssd1306_set_page_address(), and ssd1306_write_data().