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_st7567_jhd12864.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_lcd_st7567_jhd12864.h"
24#include "px_log.h"
25
26/* _____LOCAL DEFINITIONS____________________________________________________ */
27PX_LOG_NAME("px_gfx_disp_st7567_jhd12864");
28
29/* _____MACROS_______________________________________________________________ */
30
31/* _____GLOBAL VARIABLES_____________________________________________________ */
32
33/* _____LOCAL VARIABLES______________________________________________________ */
34/// Allocate space for frame buffer [row(y)][col(x)]
35static uint8_t px_gfx_frame_buf[PX_GFX_DISP_SIZE_Y / 8][PX_GFX_DISP_SIZE_X];
36
37/* _____LOCAL FUNCTION DECLARATIONS__________________________________________ */
38
39/* _____LOCAL FUNCTIONS______________________________________________________ */
40
41/* _____GLOBAL FUNCTIONS_____________________________________________________ */
42void px_gfx_disp_buf_clear(void)
43{
44 // Clear frame buffer
45 memset(px_gfx_frame_buf, 0, sizeof(px_gfx_frame_buf));
46}
47
48void px_gfx_disp_buf_pixel(px_gfx_xy_t x,
50 px_gfx_color_t color)
51{
52 uint8_t * data;
53
54 // Calculate address in frame buffer
55 data = &px_gfx_frame_buf[y / 8][x];
56
57 switch(color)
58 {
59 case PX_GFX_COLOR_ON:
60 *data |= (0x01 << (y % 8));
61 break;
62 case PX_GFX_COLOR_OFF:
63 *data &= ~(0x01 << (y % 8));
64 break;
65 case PX_GFX_COLOR_INVERT:
66 *data ^= (0x01 << (y % 8));
67 break;
68 default:
69 break;
70 }
71}
72
73void px_gfx_disp_update(const px_gfx_area_t * area)
74{
75 uint8_t page;
76
77 // Update specified area of display
78 for(page = area->y1 / 8; page <= (area->y2 / 8); page++)
79 {
80 px_lcd_sel_page(page);
81 px_lcd_sel_col(area->x1);
82 px_lcd_wr_disp_data(&px_gfx_frame_buf[page][area->x1], area->x2 - area->x1 + 1);
83 }
84}
85
86void px_gfx_disp_log_report_buf(void)
87{
88 px_gfx_xy_t x, y;
89
90 for(y = 0; y < PX_GFX_DISP_SIZE_Y; y++)
91 {
92 for(x = 0; x < PX_GFX_DISP_SIZE_X; x++)
93 {
94 if(((px_gfx_frame_buf[y / 8][x]) & (1 << (y % 8))) != 0)
95 {
97 }
98 else
99 {
101 }
102 }
103 PX_LOG_TRACE_CHAR('\n');
104 }
105}
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_xy_t y2
Bottom.
Definition: px_gfx.h:136
px_gfx_xy_t x1
Left.
Definition: px_gfx.h:133
px_gfx_xy_t x2
Right.
Definition: px_gfx.h:135
px_gfx_xy_t y1
Top.
Definition: px_gfx.h:134
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
void px_lcd_wr_disp_data(uint8_t *data, size_t nr_of_bytes)
Write data to display.
void px_lcd_sel_page(uint8_t page)
Select LCD page (y) for display data.
void px_lcd_sel_col(uint8_t col)
Select LCD starting column (x) for display data.
#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