-
Notifications
You must be signed in to change notification settings - Fork 12
/
egi_symbol.h
185 lines (141 loc) · 6.46 KB
/
egi_symbol.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/*----------------------------------------------------------------------
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
For test only!
Midas Zhou
------------------------------------------------------------------------*/
#ifndef __EGI_SYMBOL_H__
#define __EGI_SYMBOL_H__
#include "egi_image.h"
#include "egi_fbgeom.h"
#include "egi.h"
#ifdef __cplusplus
extern "C" {
#endif
/* symbol image size */
#define SYM_IMGPAGE_WIDTH 240
#define SYM_IMGPAGE_HEIGHT 320
#define TESTFONT_COLOR_FLIP 0 /* 1 use complementary color */
/*for symbol_writeFB(), roll back to start if symbol point reach boundary of FB mem */
#define no_FB_SYMOUT_ROLLBACK /* also check FB_DOTOUT_ROLLBACK in fblines.h */
#define SYM_NOSUB_COLOR -1 /* no substitute color defined for a symbol or font */
#define SYM_NOTRANSP_COLOR -1 /* no transparent color defined for a symbol or font */
#define SYM_FONT_DEFAULT_TRANSPCOLOR 1 /* >0 Ok, for symbol_string_writeFB(), if the symbol is font then
use symbol back color as transparent tunnel */
/* APP ICON Index of EGI_SYMPAGE sympg_icon */
#define ICON_DISKPLAY_INDEX 4
#define ICON_NETRADIO_INDEX 8
#define ICON_MEMOTXT_INDEX 5
#define ICON_DIAGRAM_INDEX 6
#define ICON_IOT_INDEX 1
/* symbol type */
enum symbol_type
{
symtype_font,
symtype_icon,
symtype_FT2 /* freetype2 */
};
/*
* symbol page struct
* TODO: Cache FT2 characters if possible.
* NOTE:
* 1. For FT(FreeType2) wchar page, a symbl_page holds only one character. and many memebers
* are not applicable then.
*/
typedef struct symbol_page EGI_SYMPAGE;
struct symbol_page
{
/* symbol type, NOT used yet */
enum symbol_type symtype;
/* symbol image file path */
/* for a 320x240x2Byte page, 2Bytes for 16bit color */
char *path;
/* back color of the image, a font symbol may use bkcolor as transparent channel */
uint16_t bkcolor;
/* page symbol mem data, store each symbol data consecutively, no hole. while img page file may have hole or blank row*/
uint16_t *data; /* NOTE: for FT sympage, .data is useless */
/* alpha data */
unsigned char *alpha; /* NOTE: for FT sympage, .data is useless, only .alpha is available
* Only a refrence to bitmap.buffer.
* ftsympg.alpha = slot->bitmap.buffer;
*/
/* color data */
EGI_16BIT_COLOR *color; /* For FT sympage, if color font. */
/* maximum index number of symbols in this page, start from 0 */
int maxnum; /* maxnum+1 = total number,
* NOT applicable for FT page.
*/
/* total symbol number for each row, each row has 240 pixels in a raw img page. */
int sqrow; /* for raw img page */
/* same height for all symbols in a page */
int symheight; /* For FT page, taken set_font height as in FT_Set_Pixel_Sizes(), rather than bitmap.rows
* ftsympg.symheight = slot->bitmap.rows;
*/
/* use symb_index to locate a symbol in mem, and get its width */
//struct symbol_index *symindex; /* symb_index[x], x is the corresponding code number of the symbol, like ASCII code */
/* use symoffset[] to locate a symbole in a row */
int *symoffset; /* in pixel, offset from uint16_t *data for each smybol!!
* Not applicable for FT page
*/
int *symwidth; /* in pixel, symbol width may be different, while height MUST be the same
* Not applicable for FT page
*/
int ftwidth; /* For FT page only, which holds only one character,
* ftsympg.ftwidth = slot->bitmap.width, NOT as advanceX = slot->advance.x>>6 !
* advanceX >= ftwidth.
*/
/* !!!!! following not used, if symbol encoded from 0, you can use array index number as code number.
Each row has same number of symbols, so you can use code number to locate a row in a img page
Code is a unique encoding number for each symbol in a page, like ASCII number.
*/
int *symb_code; /* default NULL, if not applicable
* MAYBE: applicable for FT page
*/
};
/*-------------- shared symbol data -------------*/
extern EGI_SYMPAGE sympg_testfont;
extern EGI_SYMPAGE sympg_numbfont;
extern EGI_SYMPAGE sympg_buttons;
extern EGI_SYMPAGE sympg_sbuttons;
extern EGI_SYMPAGE sympg_icons;
extern EGI_SYMPAGE sympg_icons_2;
extern EGI_SYMPAGE sympg_heweather;
extern EGI_SYMPAGE sympg_ascii;
extern char symmic_cpuload[6][5];
extern char symmic_iotload[9];
/*------------------- functions ---------------------*/
int symbol_load_allpages(void); //__attribute__((constructor))
void symbol_release_allpages(void);
//static uint16_t *symbol_load_page(EGI_SYMPAGE *sym_page);
void symbol_release_page(EGI_SYMPAGE *sym_page);
int symbol_check_page(const EGI_SYMPAGE *sym_page, char *func);
void symbol_save_pagemem(EGI_SYMPAGE *sym_page);
int symbol_load_page_from_imgbuf(EGI_SYMPAGE *sym_page, EGI_IMGBUF *imgbuf);
/*--------------------------------------------------------------------------------------------
transpcolor: >=0 transparent pixel will not be written to FB, so backcolor is shown there.
<0 no transparent pixel
fontcolor: font color (or symbol color for a symbol)
>= 0, use given font color.
<0 use color in img data
use following COLOR:
#define SYM_NOSUB_COLOR -1 --- no substitute color defined for a symbol or font
#define SYM_NOTRANSP_COLOR -1 --- no transparent color defined for a symbol or font
----------------------------------------------------------------------------------------------*/
void symbol_print_symbol(const EGI_SYMPAGE *sym_page, int symbol, uint16_t transpcolor);
int symbol_string_pixlen(char *str, const EGI_SYMPAGE *font);
void symbol_writeFB(FBDEV *fb_dev, const EGI_SYMPAGE *sym_page, \
int fontcolor, int transpcolor, int x0, int y0, unsigned int sym_code, int opaque);
void symbol_string_writeFB(FBDEV *fb_dev, const EGI_SYMPAGE *sym_page, \
int fontcolor, int transpcolor, int x0, int y0, const char* str, int opaque);
int symbol_strings_writeFB( FBDEV *fb_dev, const EGI_SYMPAGE *sym_page, unsigned int pixpl, \
unsigned int lines, unsigned int gap, int fontcolor, int transpcolor, \
int x0, int y0, const char* str, int opaque);
void symbol_motion_string(FBDEV *fb_dev, int dt, const EGI_SYMPAGE *sym_page, \
int transpcolor, int x0, int y0, const char* str);
void symbol_rotate(const EGI_SYMPAGE *sym_page, \
int x0, int y0, int sym_code);
#ifdef __cplusplus
}
#endif
#endif