Unit tests for graphical drawing primitives.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <asf.h>
#include <conf_test.h>
Functions | |
int | main (void) |
Run gfx_mono unit tests. More... | |
static void | run_clear_display_test (const struct test_case *test) |
Test clearing the display. More... | |
static void | run_draw_circle_outline_test (const struct test_case *test) |
Test drawing the outline of a circle on a page. More... | |
static void | run_draw_diagonal_line_test (const struct test_case *test) |
Test drawing a line between to points. More... | |
static void | run_draw_filled_circle_test (const struct test_case *test) |
Test drawing a filled circle spanning two pages. More... | |
static void | run_draw_filled_rectangle_test (const struct test_case *test) |
Test drawing a filled rectangle inside a page. More... | |
static void | run_draw_flash_bitmap_test (const struct test_case *test) |
Test drawing a bitmap stored in FLASH. More... | |
static void | run_draw_horizontal_line_test (const struct test_case *test) |
Test drawing a horizontal line. More... | |
static void | run_draw_ram_bitmap_test (const struct test_case *test) |
Test drawing a bitmap stored in RAM. More... | |
static void | run_draw_rectangle_outline_test (const struct test_case *test) |
Test drawing the outline of a rectangle spanning two pages. More... | |
static void | run_draw_rectangle_two_pages_test (const struct test_case *test) |
Test drawing a filled rectangle spanning two pages. More... | |
static void | run_draw_rectangles_test (const struct test_case *test) |
Test drawing a filled rectangle to the every other page of the display. More... | |
static void | run_draw_vertical_line_test (const struct test_case *test) |
Test drawing a vertical line. More... | |
static void | run_set_display_test (const struct test_case *test) |
Test filling the display. More... | |
Helper functions, macros and bitmaps | |
#define | set_buffer(buffer, value) memset(buffer, value, sizeof(buffer)) |
Set all bytes in buffer to value. More... | |
#define | LCD_PAGE_HEIGHT 8 |
The height of one lcd page. More... | |
uint8_t | smiley_data [16] |
Bitmap of two 8x8 pixel smileyfaces on top of each other stored in RAM. More... | |
PROGMEM_DECLARE (gfx_mono_color_t, flash_bitmap[16]) | |
Bitmap of two 8x8 pixel smileyfaces on top of each other stored in FLASH. More... | |
static bool | is_page_correct (uint8_t *test_page, uint8_t *correct_page) |
Check if a page buffer is equal to another. More... | |
#define LCD_PAGE_HEIGHT 8 |
The height of one lcd page.
Referenced by run_draw_rectangles_test().
Set all bytes in buffer to value.
Referenced by run_clear_display_test(), run_draw_circle_outline_test(), run_draw_diagonal_line_test(), run_draw_filled_circle_test(), run_draw_filled_rectangle_test(), run_draw_flash_bitmap_test(), run_draw_horizontal_line_test(), run_draw_ram_bitmap_test(), run_draw_rectangle_outline_test(), run_draw_rectangle_two_pages_test(), run_draw_rectangles_test(), run_draw_vertical_line_test(), and run_set_display_test().
|
static |
Check if a page buffer is equal to another.
test | Current test case. |
true | If the page buffers are the same |
false | If the page buffers are not the same |
References GFX_MONO_LCD_WIDTH.
Referenced by run_clear_display_test(), run_draw_circle_outline_test(), run_draw_diagonal_line_test(), run_draw_filled_circle_test(), run_draw_filled_rectangle_test(), run_draw_flash_bitmap_test(), run_draw_horizontal_line_test(), run_draw_ram_bitmap_test(), run_draw_rectangle_outline_test(), run_draw_rectangle_two_pages_test(), run_draw_rectangles_test(), run_draw_vertical_line_test(), and run_set_display_test().
int main | ( | void | ) |
Run gfx_mono unit tests.
References usart_rs232_options::baudrate, board_init(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, gfx_mono_init, run_clear_display_test(), run_draw_circle_outline_test(), run_draw_diagonal_line_test(), run_draw_filled_circle_test(), run_draw_filled_rectangle_test(), run_draw_flash_bitmap_test(), run_draw_horizontal_line_test(), run_draw_ram_bitmap_test(), run_draw_rectangle_outline_test(), run_draw_rectangle_two_pages_test(), run_draw_rectangles_test(), run_draw_vertical_line_test(), run_set_display_test(), stdio_serial_init(), sysclk_init(), test_suite_run(), and usart_serial_options.
PROGMEM_DECLARE | ( | gfx_mono_color_t | , |
flash_bitmap | [16] | ||
) |
Bitmap of two 8x8 pixel smileyfaces on top of each other stored in FLASH.
|
static |
Test clearing the display.
This test clears the display, and then checks that each page is empty.
test | Current test case. |
References gfx_mono_draw_filled_rect, gfx_mono_get_page, GFX_MONO_LCD_HEIGHT, GFX_MONO_LCD_PAGES, GFX_MONO_LCD_WIDTH, GFX_PIXEL_CLR, is_page_correct(), set_buffer, and test_assert_true.
Referenced by main().
|
static |
Test drawing the outline of a circle on a page.
This test draws the outline of a circle and checks that this is done.
test | Current test case. |
References gfx_mono_draw_circle, gfx_mono_draw_filled_rect, gfx_mono_get_page, GFX_MONO_LCD_HEIGHT, GFX_MONO_LCD_PAGES, GFX_MONO_LCD_WIDTH, GFX_PIXEL_CLR, GFX_PIXEL_SET, GFX_WHOLE, is_page_correct(), set_buffer, and test_assert_true.
Referenced by main().
|
static |
Test drawing a line between to points.
This test draws a line between two points and checks that this is done.
test | Current test case. |
References gfx_mono_draw_filled_rect, gfx_mono_draw_line, gfx_mono_get_page, GFX_MONO_LCD_HEIGHT, GFX_MONO_LCD_PAGES, GFX_MONO_LCD_WIDTH, GFX_PIXEL_CLR, GFX_PIXEL_SET, is_page_correct(), set_buffer, and test_assert_true.
Referenced by main().
|
static |
Test drawing a filled circle spanning two pages.
This test draws a filled circle spanning two pages and checks that this is done.
test | Current test case. |
References gfx_mono_draw_filled_circle, gfx_mono_draw_filled_rect, gfx_mono_get_page, GFX_MONO_LCD_HEIGHT, GFX_MONO_LCD_PAGES, GFX_MONO_LCD_WIDTH, GFX_PIXEL_CLR, GFX_PIXEL_SET, GFX_WHOLE, is_page_correct(), set_buffer, and test_assert_true.
Referenced by main().
|
static |
Test drawing a filled rectangle inside a page.
This test draws a filled rectangle inside a page and checks that this is done.
test | Current test case. |
References gfx_mono_draw_filled_rect, gfx_mono_get_page, GFX_MONO_LCD_HEIGHT, GFX_MONO_LCD_PAGES, GFX_MONO_LCD_WIDTH, GFX_PIXEL_CLR, GFX_PIXEL_SET, is_page_correct(), set_buffer, and test_assert_true.
Referenced by main().
|
static |
Test drawing a bitmap stored in FLASH.
This test draws a bitmap to position x = 60, y = 9 and checks that it is aligned with display pages and that it is drawn correctly.
test | Current test case. |
References gfx_mono_bitmap::data, GFX_MONO_BITMAP_PROGMEM, gfx_mono_draw_filled_rect, gfx_mono_get_page, GFX_MONO_LCD_HEIGHT, GFX_MONO_LCD_PAGES, GFX_MONO_LCD_WIDTH, gfx_mono_put_bitmap, GFX_PIXEL_CLR, gfx_mono_bitmap::height, is_page_correct(), gfx_mono_bitmap::progmem, set_buffer, test_assert_true, gfx_mono_bitmap::type, and gfx_mono_bitmap::width.
Referenced by main().
|
static |
Test drawing a horizontal line.
This test draws a horizontal line and checks that this is done.
test | Current test case. |
References gfx_mono_draw_filled_rect, gfx_mono_draw_horizontal_line, gfx_mono_get_page, GFX_MONO_LCD_HEIGHT, GFX_MONO_LCD_PAGES, GFX_MONO_LCD_WIDTH, GFX_PIXEL_CLR, GFX_PIXEL_SET, is_page_correct(), set_buffer, and test_assert_true.
Referenced by main().
|
static |
Test drawing a bitmap stored in RAM.
This test draws a bitmap to position x = 50, y = 5 and checks that it is aligned with display pages and that it is drawn correctly.
test | Current test case. |
References gfx_mono_bitmap::data, GFX_MONO_BITMAP_RAM, gfx_mono_draw_filled_rect, gfx_mono_get_page, GFX_MONO_LCD_HEIGHT, GFX_MONO_LCD_PAGES, GFX_MONO_LCD_WIDTH, gfx_mono_put_bitmap, GFX_PIXEL_CLR, gfx_mono_bitmap::height, is_page_correct(), gfx_mono_bitmap::pixmap, set_buffer, smiley_data, test_assert_true, gfx_mono_bitmap::type, and gfx_mono_bitmap::width.
Referenced by main().
|
static |
Test drawing the outline of a rectangle spanning two pages.
This test draws the outline of a rectangle spanning two pages and checks that this is done.
test | Current test case. |
References gfx_mono_draw_filled_rect, gfx_mono_draw_rect, gfx_mono_get_page, GFX_MONO_LCD_HEIGHT, GFX_MONO_LCD_PAGES, GFX_MONO_LCD_WIDTH, GFX_PIXEL_CLR, GFX_PIXEL_SET, is_page_correct(), set_buffer, and test_assert_true.
Referenced by main().
|
static |
Test drawing a filled rectangle spanning two pages.
This test draws a filled rectangle spanning two pages and checks that this is done.
test | Current test case. |
References gfx_mono_draw_filled_rect, gfx_mono_get_page, GFX_MONO_LCD_HEIGHT, GFX_MONO_LCD_PAGES, GFX_MONO_LCD_WIDTH, GFX_PIXEL_CLR, GFX_PIXEL_SET, is_page_correct(), set_buffer, and test_assert_true.
Referenced by main().
|
static |
Test drawing a filled rectangle to the every other page of the display.
This test draws a filled rectangle to every other page of a display and checks that every other page is filled and the rest are empty.
test | Current test case. |
References gfx_mono_draw_filled_rect, gfx_mono_get_page, GFX_MONO_LCD_HEIGHT, GFX_MONO_LCD_PAGES, GFX_MONO_LCD_WIDTH, GFX_PIXEL_CLR, GFX_PIXEL_SET, is_page_correct(), LCD_PAGE_HEIGHT, set_buffer, and test_assert_true.
Referenced by main().
|
static |
Test drawing a vertical line.
This test draws a vertical line and checks that this is done.
test | Current test case. |
References gfx_mono_draw_filled_rect, gfx_mono_draw_vertical_line, gfx_mono_get_page, GFX_MONO_LCD_HEIGHT, GFX_MONO_LCD_PAGES, GFX_MONO_LCD_WIDTH, GFX_PIXEL_CLR, GFX_PIXEL_SET, is_page_correct(), set_buffer, and test_assert_true.
Referenced by main().
|
static |
Test filling the display.
This test fills the entire display and checks that this is done.
test | Current test case. |
References gfx_mono_draw_filled_rect, gfx_mono_get_page, GFX_MONO_LCD_HEIGHT, GFX_MONO_LCD_PAGES, GFX_MONO_LCD_WIDTH, GFX_PIXEL_CLR, GFX_PIXEL_SET, is_page_correct(), set_buffer, and test_assert_true.
Referenced by main().
uint8_t smiley_data[16] |
Bitmap of two 8x8 pixel smileyfaces on top of each other stored in RAM.