-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
dab_timer.h
298 lines (282 loc) · 7.81 KB
/
dab_timer.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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
#pragma once
#include <datetime/datetime.h>
#include <dolphin/dolphin.h>
#include <furi.h>
#include <furi_hal.h>
#include <gui/elements.h>
#include <gui/gui.h>
#include <input/input.h>
#include <locale/locale.h>
#include <math.h>
#include <notification/notification.h>
#include <notification/notification_messages.h>
#if __has_include(<cfw/cfw.h>)
#include "applications/settings/desktop_settings/desktop_settings_app.h"
#endif
#define DAB_TIMER_ISO_DATE_FORMAT "%.4d-%.2d-%.2d"
#define DAB_TIMER_RFC_DATE_FORMAT "%.2d-%.2d-%.4d"
#define DAB_TIMER_TIME_FORMAT "%.2d:%.2d:%.2d"
#define MERIDIAN_FORMAT "%s"
#define MERIDIAN_STRING_AM "AM"
#define MERIDIAN_STRING_PM "PM"
#define TIME_LEN 12
#define DATE_LEN 14
#define MERIDIAN_LEN 3
#define PI 3.14
// #define DAB_TIMER_SETTINGS_PATH CFG_PATH("dab_timer_settings.txt")
typedef struct {
uint8_t x;
uint8_t y;
} Vector2;
typedef enum {
EventTypeTick,
EventTypeKey,
} EventType;
typedef struct {
EventType type;
InputEvent input;
} PluginEvent;
typedef enum {
FaceStylePwn,
FaceStyleOriginal,
FaceStyleOriginalSmall,
FaceStyleCircle,
FaceStyleBinary,
FaceStylePwnInverted,
FaceStyleOriginalInverted,
FaceStyleOriginalSmallInverted,
FaceStyleCircleInverted,
FaceStyleBinaryInverted,
FaceStyleCount,
} FaceStyle;
typedef enum {
SoundAlertOff,
SoundAlertByMin,
SoundAlertMario,
SoundAlertGoGoPoRa,
SoundAlertCont,
SoundAlertCount,
} SoundAlert;
typedef struct {
FuriMutex* mutex;
FuriMessageQueue* event_queue;
#if __has_include(<cfw/cfw.h>)
DesktopSettings* desktop_settings;
#endif
LocaleDateFormat date_format;
LocaleTimeFormat time_format;
// ViewDispatcher* view_dispatcher;
uint32_t timer_start_timestamp;
uint32_t lastexp_timestamp;
uint32_t timer_stopped_seconds;
uint32_t timerSecs;
uint32_t alert_time;
uint8_t codeSequence;
uint8_t curEmotiveFace;
bool timer_running;
bool w_test;
FaceStyle faceType;
SoundAlert songSelect;
} DabTimerState;
const NotificationSequence dab_timer_alert_silent = {
&message_vibro_on,
&message_red_255,
&message_green_255,
&message_blue_255,
&message_display_backlight_on,
&message_vibro_off,
&message_display_backlight_off,
&message_delay_50,
&message_display_backlight_on,
NULL,
};
const NotificationSequence dab_timer_alert_pr1 = {
&message_vibro_on,
&message_red_255,
&message_green_255,
&message_blue_255,
&message_display_backlight_on,
&message_note_g5,
&message_delay_100,
&message_delay_100,
&message_delay_50,
&message_sound_off,
&message_vibro_off,
&message_display_backlight_off,
&message_delay_50,
&message_display_backlight_on,
&message_note_g5,
&message_delay_100,
&message_delay_100,
&message_delay_50,
&message_sound_off,
NULL,
};
const NotificationSequence dab_timer_alert_pr2 = {
&message_vibro_on,
&message_note_fs5,
&message_delay_100,
&message_delay_100,
&message_sound_off,
&message_display_backlight_off,
&message_vibro_off,
&message_delay_50,
&message_note_g5,
&message_delay_100,
&message_delay_100,
&message_sound_off,
&message_display_backlight_on,
&message_delay_50,
&message_note_a5,
&message_delay_100,
&message_delay_100,
&message_sound_off,
NULL,
};
const NotificationSequence dab_timer_alert_pr3 = {
&message_display_backlight_off,
&message_note_g5,
&message_delay_100,
&message_delay_100,
&message_sound_off,
&message_delay_50,
&message_red_255,
&message_green_255,
&message_blue_255,
&message_display_backlight_on,
&message_delay_100,
NULL,
};
const NotificationSequence dab_timer_alert_mario1 = {
&message_vibro_on,
&message_red_255,
&message_green_255,
&message_blue_255,
&message_display_backlight_on,
&message_note_e5,
&message_delay_100,
&message_delay_100,
&message_delay_50,
&message_sound_off,
&message_note_e5,
&message_delay_100,
&message_delay_100,
&message_delay_50,
&message_sound_off,
&message_vibro_off,
&message_display_backlight_off,
&message_delay_100,
&message_display_backlight_on,
&message_delay_100,
&message_note_e5,
&message_delay_100,
&message_delay_100,
&message_delay_50,
&message_sound_off,
NULL,
};
const NotificationSequence dab_timer_alert_mario2 = {
&message_vibro_on,
&message_display_backlight_off,
&message_delay_100,
&message_display_backlight_on,
&message_delay_100,
&message_note_c5,
&message_delay_100,
&message_delay_100,
&message_sound_off,
&message_display_backlight_off,
&message_vibro_off,
&message_delay_50,
&message_note_e5,
&message_delay_100,
&message_delay_100,
&message_sound_off,
&message_display_backlight_on,
NULL,
};
const NotificationSequence dab_timer_alert_mario3 = {
&message_display_backlight_off,
&message_note_g5,
&message_delay_100,
&message_delay_100,
&message_delay_100,
&message_delay_100,
&message_sound_off,
&message_delay_50,
&message_red_255,
&message_green_255,
&message_blue_255,
&message_display_backlight_on,
&message_delay_100,
&message_note_g4,
&message_delay_100,
&message_delay_100,
&message_delay_100,
&message_delay_100,
&message_sound_off,
NULL,
};
const NotificationSequence dab_timer_alert_perMin = {
&message_note_g5,
&message_delay_100,
&message_delay_50,
&message_sound_off,
&message_delay_10,
&message_note_g4,
&message_delay_50,
&message_delay_10,
&message_delay_10,
&message_sound_off,
NULL,
};
const NotificationSequence dab_timer_alert_startStop = {
&message_red_255,
&message_green_255,
&message_blue_255,
&message_note_d6,
&message_delay_100,
&message_delay_10,
&message_delay_10,
&message_sound_off,
NULL,
};
const NotificationMessage message_red_127 = {
.type = NotificationMessageTypeLedRed,
.data.led.value = 0x7F,
};
const NotificationMessage message_green_127 = {
.type = NotificationMessageTypeLedGreen,
.data.led.value = 0x7F,
};
const NotificationMessage message_blue_127 = {
.type = NotificationMessageTypeLedBlue,
.data.led.value = 0x7F,
};
const NotificationSequence sequence_rainbow = {
&message_red_255, &message_green_0, &message_blue_0,
&message_delay_250, &message_red_255, &message_green_127,
&message_blue_0, &message_delay_250, &message_red_255,
&message_green_255, &message_blue_0, &message_delay_250,
&message_red_127, &message_green_255, &message_blue_0,
&message_delay_250, &message_red_0, &message_green_255,
&message_blue_0, &message_delay_250, &message_red_0,
&message_green_255, &message_blue_127, &message_delay_250,
&message_red_0, &message_green_255, &message_blue_255,
&message_delay_250, &message_red_0, &message_green_127,
&message_blue_255, &message_delay_250, &message_red_0,
&message_green_0, &message_blue_255, &message_delay_250,
&message_red_127, &message_green_0, &message_blue_255,
&message_delay_250, &message_red_255, &message_green_0,
&message_blue_255, &message_delay_250, &message_red_255,
&message_green_0, &message_blue_127, &message_delay_250,
&message_red_127, &message_green_127, &message_blue_127,
&message_delay_250, &message_red_255, &message_green_255,
&message_blue_255, &message_delay_250, NULL,
};
static Vector2 angle_to_vector2(float angle_in_degrees, uint8_t distance, Vector2 center);
void dab_timer_render_binary_face(
Canvas* const canvas,
int32_t value,
int32_t height,
uint32_t timer_start_timestamp);