-
Notifications
You must be signed in to change notification settings - Fork 0
/
touch.h
188 lines (155 loc) · 4.75 KB
/
touch.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
186
187
188
#define BUTW 50
#define BUTH 40
#ifdef USETOUCH
#ifndef TOUCH_H
#define TOUCH_H
#include "fonts.h"
class RadioButton : public TFT_eSPI_Button {
private:
static const uint16_t outline = TFT_MY_SILVER;
static const uint16_t buttonfill = TFT_REALGOLD;
static const uint16_t textcolor = TFT_BLACK;
public:
RadioButton(void){};
void set_symbol_normal( char *newvalue ){
if ( symbol_normal != NULL )free( symbol_normal );
symbol_normal = NULL;
if( newvalue )symbol_normal = ps_strdup( newvalue );
}
void set_symbol_invert( char *newvalue ){
if ( symbol_invert != NULL )free( symbol_invert );
symbol_invert = NULL;
if( newvalue )symbol_invert = ps_strdup( newvalue );
}
void draw( bool invert=false, char *longname = NULL){
if ( longname == NULL ){
if ( invert && symbol_invert != NULL){
longname = symbol_invert;
}else{
longname = symbol_normal;
}
}
if ( bmp_normal == NULL && bmp_invert == NULL ){
xSemaphoreTake( tftSemaphore, portMAX_DELAY);
if ( strlen( longname ) == 1 ){
//use radio_button_font font
if ( longname[0] < 112 ){
tft.setFreeFont(&radio_button_font);
}else{
tft.setFreeFont(&Arrows);
}
if ( invert ){
tft.setTextColor( TFT_BLUE, TFT_BLACK);
}else{
tft.setTextColor( TFT_REALGOLD, TFT_BLACK);
}
//log_d( "fontbutton - draw %s", longname);
tft.drawString( longname, x,y );
}else{
char *displayname;
if ( *longname == 0xd0 || *longname == 0xd1 ){
displayname = (char *)gr_calloc( strlen( longname) + 4,1);
utf8torus( longname, displayname);
setLabelDatum(0, 0, MC_DATUM );
tft.setFreeFont( STATION_FONT );
}else{
latin2utf( (unsigned char *) longname, (unsigned char **)&displayname );
setLabelDatum(0, 3, MC_DATUM );
tft.setFreeFont( STATION_FONT_LATIN );
}
drawButton( invert, displayname);
free( displayname );
}
xSemaphoreGive( tftSemaphore );
}
if ( bmp_normal != NULL && !invert ){
log_i ( "drawing %s", bmp_normal);
drawBmp( bmp_normal, x, y );
}
if ( bmp_invert != NULL && invert ){
log_i ( "drawing %s", bmp_invert);
drawBmp( bmp_invert, x, y );
}
return;
}
void init( int argx, int argy, char *argsymbol_normal, int arg_butw = BUTW, int arg_buth = BUTH, char *argsymbol_invert = NULL, char *argbmp_normal=NULL, char *argbmp_invert=NULL ){
x = argx;
y = argy;
butw = arg_butw;
buth = arg_buth;
set_symbol_normal( argsymbol_normal );
set_symbol_invert( argsymbol_invert );
if ( argbmp_normal != NULL) bmp_normal = ps_strdup( argbmp_normal );
if ( argbmp_invert != NULL) bmp_invert = ps_strdup( argbmp_invert );
if ( argbmp_normal && argbmp_invert == NULL ) bmp_invert = bmp_normal;
initButtonUL(&tft, x, y, arg_butw, arg_buth, outline, buttonfill, textcolor, symbol_normal, 1);
setLabelDatum(0, 0, MC_DATUM ); // x-delta, ydelta ( a bit down) , what place in the text ( here: the middle)
// in the middle of the label ("datum"). y offset of 7 for font 4 = bigfont
// y offset 0 for FreeSansBold10pt8b
}
int x;
int y;
int butw;
int buth;
char *symbol_normal;
char *symbol_invert;
char *bmp_normal;
char *bmp_invert;
int stationidx;
};
#define TOUCHBUTTONCOUNT 30
#ifdef USEINPUTSELECT
enum buttontype{
BUTTON_AV,
BUTTON_BLUETOOTH,
BUTTON_RADIO,
BUTTON_STOP,
BUTTON_MUTE,
BUTTON_PREV,
BUTTON_NEXT,
BUTTON_LIST,
BUTTON_ITEM0,
BUTTON_ITEM1,
BUTTON_ITEM2,
BUTTON_ITEM3,
BUTTON_ITEM4,
BUTTON_ITEM5,
BUTTON_ITEM6,
BUTTON_ITEM7,
BUTTON_LEFTLIST,
BUTTON_QUITLIST,
BUTTON_RIGHTLIST,
BUTTON_DOWN,
BUTTON_UP
};
#else
enum buttontype{
BUTTON_DOWN,
BUTTON_UP,
BUTTON_RADIO,
BUTTON_STOP,
BUTTON_MUTE,
BUTTON_PREV,
BUTTON_NEXT,
BUTTON_LIST,
BUTTON_ITEM0,
BUTTON_ITEM1,
BUTTON_ITEM2,
BUTTON_ITEM3,
BUTTON_ITEM4,
BUTTON_ITEM5,
BUTTON_ITEM6,
BUTTON_ITEM7,
BUTTON_LEFTLIST,
BUTTON_QUITLIST,
BUTTON_RIGHTLIST,
BUTTON_AV,
BUTTON_BLUETOOTH,
};
#endif
#define CALIBRATION_FILE "/TouchCal.dat"
extern RadioButton touchbutton [ TOUCHBUTTONCOUNT ] ;
extern bool MuteActive;
int touch_init();
#endif
#endif