LCDGFX LCD display driver
1.2.0
Lightweight graphics library for SSD1306, SSD1325, SSD1327, SSD1331, SSD1351, SH1106, SH1107, IL9163, ST7735, ST7789, ILI9341, PCD8544 displays over I2C/SPI
canvas_types.h
Go to the documentation of this file.
1
/*
2
MIT License
3
4
Copyright (c) 2017-2020, Alexey Dynda
5
6
Permission is hereby granted, free of charge, to any person obtaining a copy
7
of this software and associated documentation files (the "Software"), to deal
8
in the Software without restriction, including without limitation the rights
9
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
copies of the Software, and to permit persons to whom the Software is
11
furnished to do so, subject to the following conditions:
12
13
The above copyright notice and this permission notice shall be included in all
14
copies or substantial portions of the Software.
15
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
SOFTWARE.
23
*/
28
#pragma once
29
30
#include "
canvas/UserSettings.h
"
31
32
#if defined(ARDUINO)
33
#include <Arduino.h>
34
#elif defined(__AVR__)
35
#include <avr/pgmspace.h>
36
#else
37
#endif
38
39
#include <stdint.h>
40
#include <stddef.h>
41
43
#define SSD1306_MORE_CHARS_REQUIRED 0xffff
44
45
#ifndef DOXYGEN_SHOULD_SKIP_THIS
46
#ifndef PROGMEM
47
#define PROGMEM
48
#endif
49
#endif
50
52
#define RGB_COLOR8(r, g, b) ((r & 0xE0) | ((g >> 3) & 0x1C) | (b >> 6))
53
55
#define GRAY_COLOR4(gray) (((gray >> 4) & 0x0F) | (gray & 0xF0))
56
58
#define RGB_COLOR4(r, g, b) ((r >> 2) + (g >> 1) + (b >> 2))
59
61
#define RGB8_TO_GRAY4(rgb) ((rgb >> 6) + ((rgb >> 2) & 0x07) + (rgb & 0x03))
62
64
#define RGB_COLOR16(r, g, b) (((r << 8) & 0xF800) | ((g << 3) & 0x07E0) | (b >> 3))
65
67
#define RGB8_TO_RGB16(c) \
68
((((uint16_t)c & 0b11100000) << 8) | (((uint16_t)c & 0b00011100) << 6) | (((uint16_t)c & 0b00000011) << 3))
69
71
#define RGB16_TO_RGB8(c) \
72
(((uint16_t)(c >> 8) & 0b11100000) | ((uint16_t)(c >> 6) & 0b00011100) | ((uint16_t)(c >> 3) & 0b00000011))
73
74
#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || \
75
defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
76
77
typedef
int8_t
lcdint_t
;
79
typedef
uint8_t
lcduint_t
;
80
#else
81
82
typedef
int
lcdint_t
;
84
typedef
unsigned
int
lcduint_t
;
85
#endif
86
88
typedef
enum
89
{
90
STYLE_NORMAL,
91
STYLE_BOLD,
92
STYLE_ITALIC,
93
}
EFontStyle
;
94
95
enum
96
{
97
CANVAS_MODE_BASIC = 0x00,
99
CANVAS_TEXT_WRAP
= 0x01,
101
CANVAS_MODE_TRANSPARENT
= 0x02,
103
CANVAS_TEXT_WRAP_LOCAL
= 0x04,
104
};
105
107
typedef
enum
108
{
109
FONT_SIZE_NORMAL = 0,
110
FONT_SIZE_2X = 1,
111
FONT_SIZE_4X = 2,
112
FONT_SIZE_8X = 3,
113
}
EFontSize
;
114
115
#pragma pack(push, 1)
116
117
typedef
struct
118
{
119
uint8_t
type
;
120
uint8_t
width
;
121
uint8_t
height
;
122
uint8_t
ascii_offset
;
123
}
SFontHeaderRecord
;
124
#pragma pack(pop)
125
127
typedef
struct
128
{
129
SFontHeaderRecord
h
;
130
uint8_t
count
;
131
uint8_t
pages
;
132
uint8_t
glyph_size
;
133
uint8_t
spacing
;
134
const
uint8_t *
primary_table
;
135
#ifdef CONFIG_SSD1306_UNICODE_ENABLE
136
const
uint8_t *
secondary_table
;
137
#endif
138
}
SFixedFontInfo
;
139
141
typedef
struct
142
{
143
uint8_t
width
;
144
uint8_t
height
;
145
uint8_t
spacing
;
146
const
uint8_t *
glyph
;
147
}
SCharInfo
;
148
152
typedef
struct
153
{
155
const
char
**
items
;
157
uint8_t
count
;
159
uint8_t
selection
;
161
uint8_t
oldSelection
;
163
uint8_t
scrollPosition
;
165
lcdint_t
top
;
167
lcdint_t
left
;
169
lcduint_t
width
;
171
lcduint_t
height
;
172
}
SAppMenu
;
SAppMenu::left
lcdint_t left
left offset
Definition:
canvas_types.h:167
SCharInfo::height
uint8_t height
char height in pixels
Definition:
canvas_types.h:144
lcduint_t
uint8_t lcduint_t
internal int type, used by the library.
Definition:
canvas_types.h:79
SFixedFontInfo::primary_table
const uint8_t * primary_table
font chars bits
Definition:
canvas_types.h:134
SCharInfo
Structure describes single char information.
Definition:
canvas_types.h:141
CANVAS_TEXT_WRAP_LOCAL
If the flag is specified, text cursor is moved to new line when end of canvas is reached.
Definition:
canvas_types.h:103
SFontHeaderRecord::width
uint8_t width
width in pixels
Definition:
canvas_types.h:120
CANVAS_MODE_TRANSPARENT
This flag make bitmaps transparent (Black color)
Definition:
canvas_types.h:101
lcdint_t
int8_t lcdint_t
internal int type, used by the library.
Definition:
canvas_types.h:77
SAppMenu::width
lcduint_t width
width of menu
Definition:
canvas_types.h:169
SFontHeaderRecord::type
uint8_t type
font type: 0 - Fixed Font
Definition:
canvas_types.h:119
SFontHeaderRecord::height
uint8_t height
height in pixels
Definition:
canvas_types.h:121
SFixedFontInfo
Structure is used for internal font presentation.
Definition:
canvas_types.h:127
SAppMenu::height
lcduint_t height
height of menu
Definition:
canvas_types.h:171
SFontHeaderRecord::ascii_offset
uint8_t ascii_offset
ascii offset
Definition:
canvas_types.h:122
UserSettings.h
canvas module configuration.
SAppMenu::selection
uint8_t selection
currently selected item. Internally updated.
Definition:
canvas_types.h:159
SAppMenu::scrollPosition
uint8_t scrollPosition
position of menu scrolling. Internally updated
Definition:
canvas_types.h:163
CANVAS_TEXT_WRAP
If the flag is specified, text cursor is moved to new line when end of screen is reached.
Definition:
canvas_types.h:99
SAppMenu::count
uint8_t count
count of menu items in the menu
Definition:
canvas_types.h:157
SCharInfo::width
uint8_t width
char width in pixels
Definition:
canvas_types.h:143
SFixedFontInfo::secondary_table
const uint8_t * secondary_table
font chars bits
Definition:
canvas_types.h:136
SAppMenu
Describes menu object.
Definition:
canvas_types.h:152
SAppMenu::top
lcdint_t top
top offset
Definition:
canvas_types.h:165
SFixedFontInfo::h
SFontHeaderRecord h
record, containing information on font
Definition:
canvas_types.h:129
SCharInfo::glyph
const uint8_t * glyph
char data, located in progmem.
Definition:
canvas_types.h:146
SFontHeaderRecord
Structure describes font format in memory.
Definition:
canvas_types.h:117
SCharInfo::spacing
uint8_t spacing
additional spaces after char in pixels
Definition:
canvas_types.h:145
EFontStyle
EFontStyle
Supported font styles.
Definition:
canvas_types.h:88
EFontSize
EFontSize
Supported scale font values.
Definition:
canvas_types.h:107
SFixedFontInfo::spacing
uint8_t spacing
spacing between two characters
Definition:
canvas_types.h:133
SFixedFontInfo::glyph_size
uint8_t glyph_size
glyph size in bytes
Definition:
canvas_types.h:132
SFixedFontInfo::pages
uint8_t pages
height in pages (each page height is 8-pixels)
Definition:
canvas_types.h:131
SFixedFontInfo::count
uint8_t count
count of characters
Definition:
canvas_types.h:130
SAppMenu::oldSelection
uint8_t oldSelection
selected item, when last redraw operation was performed. Internally updated.
Definition:
canvas_types.h:161
SAppMenu::items
const char ** items
list of menu items of the menu
Definition:
canvas_types.h:155
src
canvas
canvas_types.h
Generated by
1.8.13