px-fwlib 0.10.0
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers generated with Doxygen 1.9.2
px_gfx_disp_sim.c
1/* =============================================================================
2 ____ ___ ____ ___ _ _ ___ __ __ ___ __ __ TM
3 | _ \ |_ _| / ___| / _ \ | \ | | / _ \ | \/ | |_ _| \ \/ /
4 | |_) | | | | | | | | | | \| | | | | | | |\/| | | | \ /
5 | __/ | | | |___ | |_| | | |\ | | |_| | | | | | | | / \
6 |_| |___| \____| \___/ |_| \_| \___/ |_| |_| |___| /_/\_\
7
8 Copyright (c) 2019 Pieter Conradie <https://piconomix.com>
9
10 License: MIT
11 https://github.com/piconomix/px-fwlib/blob/master/LICENSE.md
12
13 Title: px_gfx_disp.h : Glue layer to physical display
14 Author(s): Pieter Conradie
15 Creation Date: 2019-05-28
16
17============================================================================= */
18
19/* _____STANDARD INCLUDES____________________________________________________ */
20
21/* _____PROJECT INCLUDES_____________________________________________________ */
22#include "px_gfx_disp.h"
23#include "px_log.h"
24
25/* _____LOCAL DEFINITIONS____________________________________________________ */
26PX_LOG_NAME("px_gfx_disp_sim");
27
28/* _____MACROS_______________________________________________________________ */
29
30/* _____GLOBAL VARIABLES_____________________________________________________ */
31/// Allocate space for frame buffer [row(y)][col(x)]
32uint8_t px_gfx_frame_buf[PX_GFX_DISP_SIZE_Y][PX_GFX_DISP_SIZE_X];
33
34extern void px_gfx_disp_sim_draw(const px_gfx_area_t * area);
35
36/* _____LOCAL VARIABLES______________________________________________________ */
37
38/* _____LOCAL FUNCTION DECLARATIONS__________________________________________ */
39
40/* _____LOCAL FUNCTIONS______________________________________________________ */
41
42/* _____GLOBAL FUNCTIONS_____________________________________________________ */
43void px_gfx_disp_buf_clear(void)
44{
45 // Clear display buffer
46 memset(px_gfx_frame_buf, 0, sizeof(px_gfx_frame_buf));
47}
48
49void px_gfx_disp_buf_pixel(px_gfx_xy_t x,
51 px_gfx_color_t color)
52{
53 uint8_t * data;
54
55 // Calculate address in display buffer
56 data = &px_gfx_frame_buf[y][x];
57
58 switch(color)
59 {
60 case PX_GFX_COLOR_ON:
61 *data = 1;
62 break;
63 case PX_GFX_COLOR_OFF:
64 *data = 0;
65 break;
66 case PX_GFX_COLOR_INVERT:
67 *data ^= 1;
68 break;
69 default:
70 break;
71 }
72}
73
74void px_gfx_disp_update(const px_gfx_area_t * area)
75{
76 px_gfx_disp_sim_draw(area);
77}
78
79void px_gfx_disp_log_report_buf(void)
80{
81 px_gfx_xy_t x, y;
82
83 for(y = 0; y < PX_GFX_DISP_SIZE_Y; y++)
84 {
85 for(x = 0; x < PX_GFX_DISP_SIZE_X; x++)
86 {
87 if(px_gfx_frame_buf[y][x])
88 {
90 }
91 else
92 {
94 }
95 }
97 }
98}
99
uint8_t px_gfx_frame_buf[PX_GFX_DISP_SIZE_Y][PX_GFX_DISP_SIZE_X]
Allocate space for frame buffer [row(y)][col(x)].
px_gfx_color_t
Foreground and background color definitions.
Definition: px_gfx.h:85
int16_t px_gfx_xy_t
Size definition of an X or Y coordinate.
Definition: px_gfx.h:71
Area definition.
Definition: px_gfx.h:132
#define PX_LOG_NAME(name)
Macro to declare a log name string once for each file to reduce code size.
Definition: px_log.h:349
#define PX_LOG_TRACE_CHAR(c)
Macro to output a char if PX_LOG=1.
Definition: px_log.h:465