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.
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) |
Put framebuffer to LCD controller. More... | |
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_pixel | ( | x, | |
y, | |||
color | |||
) | gfx_mono_ssd1306_draw_pixel(x, y, 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() |
Referenced by main().
#define GFX_MONO_LCD_FRAMEBUFFER_SIZE |
#define GFX_MONO_LCD_PAGES |
Referenced by gfx_mono_ssd1306_init(), and gfx_mono_ssd1306_put_framebuffer().
#define GFX_MONO_LCD_PIXELS_PER_BYTE 8 |
#define GFX_MONO_LCD_WIDTH 128 |
Referenced by gfx_mono_framebuffer_draw_pixel(), gfx_mono_framebuffer_get_byte(), gfx_mono_framebuffer_get_page(), gfx_mono_framebuffer_get_pixel(), gfx_mono_framebuffer_put_byte(), gfx_mono_framebuffer_put_page(), gfx_mono_generic_draw_horizontal_line(), gfx_mono_ssd1306_draw_pixel(), gfx_mono_ssd1306_get_pixel(), gfx_mono_ssd1306_init(), and gfx_mono_ssd1306_put_framebuffer().
#define gfx_mono_mask_byte | ( | page, | |
column, | |||
pixel_mask, | |||
color | |||
) | gfx_mono_ssd1306_mask_byte(page, column, pixel_mask, color) |
Referenced by gfx_mono_generic_draw_vertical_line().
#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) |
Referenced by gfx_mono_generic_put_bitmap().
void gfx_mono_ssd1306_draw_pixel | ( | gfx_coord_t | x, |
gfx_coord_t | y, | ||
gfx_coord_t | color | ||
) |
Draw pixel to screen.
[in] | x | X coordinate of the pixel |
[in] | y | Y coordinate of the pixel |
[in] | color | Pixel 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_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.
[in] | page | Page address |
[in] | column | Page offset (x coordinate) |
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.
[in] | data | Pointer where to store the read data |
[in] | page | Page address |
[in] | column | Offset into page (x coordinate) |
[in] | width | Number 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.
[in] | x | X coordinate of pixel |
[in] | y | Y coordinate of pixel |
The following example will read the pixel value from x=10,y=10:
References gfx_mono_get_byte, 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.
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.
[in] | page | Page address |
[in] | column | Page offset (x coordinate) |
[in] | pixel_mask | Mask for pixel operation |
[in] | color | Pixel 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.
[in] | page | Page address |
[in] | column | Page offset (x coordinate) |
[in] | data | Data to be written |
[in] | force | Forces 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.
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 | ) |
Put framebuffer to LCD controller.
This function will output the complete framebuffer from RAM to the LCD controller.
References framebuffer, GFX_MONO_LCD_PAGES, GFX_MONO_LCD_WIDTH, gfx_mono_ssd1306_put_page(), ssd1306_set_column_address(), and ssd1306_set_page_address().
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.
[in] | data | Pointer to data to be written |
[in] | page | Page address |
[in] | column | Offset into page (x coordinate) |
[in] | width | Number 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):
References gfx_mono_framebuffer_put_page(), ssd1306_set_column_address(), ssd1306_set_page_address(), and ssd1306_write_data().
Referenced by gfx_mono_ssd1306_put_framebuffer().