-
Notifications
You must be signed in to change notification settings - Fork 0
/
keymap.c
588 lines (549 loc) · 29.3 KB
/
keymap.c
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
// kb: crkbd
// km: neoncorneghost
#include QMK_KEYBOARD_H
enum corne_layers { // las capas en este keymap
_BASE,
_LOWER,
_RAISE,
_TUNE
};
enum custom_keycodes { // dando nombre de keycodes por definir
LOWER = SAFE_RANGE,
RAISE,
QUOTE,
CIRC,
WAVE,
VERTICALBAR,
GRAVE,
HUI,
HUD
};
enum td_keycodes {
CAPLOCK,
SUPER,
ALT
};
// definiendo el keycode TD_CAPLOCK
// un pulso: Left Shift
// dos pulsos: Caps Lock
qk_tap_dance_action_t tap_dance_actions[] = {
[CAPLOCK] = ACTION_TAP_DANCE_DOUBLE(KC_LSFT, KC_CAPS),
[SUPER] = ACTION_TAP_DANCE_DOUBLE(KC_APPLICATION, LOWER),
[ALT] = ACTION_TAP_DANCE_DOUBLE(KC_RALT, KC_LALT)
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { // Las keycodes en cada capa
[_BASE] = LAYOUT_split_3x6_3(
KC_ESCAPE , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_Y , KC_U , KC_I , KC_O , KC_P , KC_BSPC ,
KC_TAB , KC_A , KC_S , KC_D , KC_F , KC_G , KC_H , KC_J , KC_K , KC_L , KC_SCLN , QUOTE ,
KC_LEFT_SHIFT , KC_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M , KC_COMM , KC_DOT , KC_SLSH , KC_ESC ,
KC_LEFT_CTRL , SUPER , KC_SPC , KC_ENT , RAISE , TD(ALT)
),
[_LOWER] = LAYOUT_split_3x6_3(
KC_TAB , KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , KC_BSPC ,
KC_LSFT , KC_PGDN , KC_PGUP , KC_PSCREEN , KC_LGUI , XXXXXXX , KC_HOME , KC_LEFT , KC_DOWN , KC_UP , KC_RIGHT , KC_END ,
KC_LCTL , KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 ,
KC_DEL , _______ , KC_SPC , KC_ENT , RAISE , TD(ALT)
),
[_RAISE] = LAYOUT_split_3x6_3(
KC_TAB , KC_EXLM , KC_AT , KC_HASH , KC_DLR , KC_PERC , CIRC , KC_AMPR , KC_ASTR , KC_LPRN , KC_RPRN , KC_BSPC ,
KC_LSFT , KC_LBRC , KC_RBRC , KC_LCBR , KC_RCBR , KC_BSLS , KC_EQUAL , KC_PLUS , KC_MINS , KC_ASTR , KC_KP_SLASH , KC_UNDS ,
KC_LCTL , RALT(KC_1) , RALT(KC_SLSH) , WAVE , VERTICALBAR , GRAVE , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX ,
KC_DEL , LOWER , KC_SPC , KC_ENT , _______ , TD(ALT)
),
[_TUNE] = LAYOUT_split_3x6_3(
XXXXXXX , RGB_M_P , RGB_M_B , RGB_M_R , RGB_M_SW , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX ,
RGB_TOG , HUI , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX ,
XXXXXXX , HUD , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX , XXXXXXX ,
KC_DEL , _______ , KC_SPC , KC_ENT , _______ , TD(ALT)
)
};
// ---------------------- variables -----------------------------
#define ANIM_SIZE_GHOST 128 // size en bytes de cada frame
#define ANIM_FRAME_DURATION 200 // cuanto tiempo mostrar cada frame
led_t led_usb_state;
uint32_t anim_ghost_timer;
uint32_t anim_ghost_sleep;
uint32_t anim_fishing_timer;
uint32_t anim_fishing_sleep;
uint8_t current_wpm = 0;
uint8_t current_ghost_frame = 0;
uint8_t hue_value;
uint8_t sat_value;
uint8_t val_value;
uint8_t mode_value;
uint8_t current_hue;
uint8_t current_val;
char hue_str[4];
char sat_str[4];
char val_str[4];
char mode_str[4];
char wpm_str[4];
// --------------------------------------------------------------
void keyboard_post_init_user(void) {
current_hue = rgblight_get_hue();
current_val = RGBLIGHT_LIMIT_VAL;
}
layer_state_t layer_state_set_user(layer_state_t state) {
switch (get_highest_layer(state)) {
case _TUNE:
if (!host_keyboard_led_state().caps_lock) {
rgblight_sethsv(HSV_WHITE);
}
break;
case _RAISE:
if (!host_keyboard_led_state().caps_lock) {
rgblight_sethsv(245, 255, current_val);
}
break;
case _LOWER:
if (!host_keyboard_led_state().caps_lock) {
rgblight_sethsv(HSV_TEAL);
}
break;
case _BASE:
if (!host_keyboard_led_state().caps_lock) {
rgblight_sethsv(current_hue, 255, current_val);
}
break;
}
return state;
}
void led_set_user(uint8_t usb_led) {
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
rgblight_sethsv(22, 255, current_val); // amarillo
} else {
rgblight_sethsv(current_hue, 255, current_val);
}
}
#ifdef OLED_ENABLE // si OLED_ENABLE = yes en rules.mk
#include <stdio.h>
static void master_render_ghost(void) { // esta funcion contiene los frames y logica de la animacion del ghost
static const char PROGMEM hide[2][ANIM_SIZE_GHOST] = { // frames de hide
{ // 'hide1' 32x28px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0x90, 0x08, 0x04, 0x02, 0x01, 0x00, 0x40, 0x20, 0x10, 0x08, 0x08,
0x08, 0x08, 0x88, 0x70, 0x00, 0x70, 0x88, 0x08, 0x09, 0x12, 0x04, 0x18, 0xe0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x66, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
0x22, 0x11, 0x08, 0x08, 0x08, 0x08, 0x10, 0x21, 0x02, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x10, 0x20, 0x20, 0x20, 0x40,
0x40, 0x40, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00
},
{ // 'hide2' 32x28px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0x90, 0x08, 0x04, 0x02, 0x01, 0x00, 0x40, 0x20, 0x10, 0x08, 0x08,
0x08, 0x08, 0x88, 0x70, 0x00, 0x70, 0x88, 0x08, 0x09, 0x12, 0x04, 0x18, 0xe0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x66, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0x62, 0x31, 0x38, 0x38, 0x38, 0x38, 0x30, 0x61, 0x82, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x10, 0x20, 0x20, 0x20, 0x40,
0x40, 0x40, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00
}
};
static const char PROGMEM shyguy[2][ANIM_SIZE_GHOST] = { // frames de shyguy
{ // 'shyguy1' 32x28px
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0xa0, 0x60, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x04, 0xfc, 0x44, 0x44, 0x44, 0x44, 0xfe,
0x01, 0x00, 0x00, 0x1e, 0x1e, 0x1e, 0x00, 0x00, 0x1e, 0x1e, 0x1e, 0x00, 0x01, 0xfe, 0x00, 0x00,
0x00, 0x70, 0x90, 0x10, 0x10, 0x10, 0x10, 0x08, 0x04, 0x02, 0x01, 0x80, 0x80, 0x00, 0x00, 0x0f,
0x10, 0x20, 0xc0, 0x40, 0x80, 0x80, 0x98, 0x98, 0x80, 0x80, 0xc0, 0x20, 0x30, 0xcf, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0x04, 0x08, 0x10, 0x20, 0x20, 0x20, 0x10, 0x08, 0x10, 0x21, 0x42, 0x44,
0x48, 0x48, 0x47, 0x40, 0x40, 0x40, 0x40, 0x20, 0x20, 0x20, 0x1f, 0x04, 0x08, 0x0f, 0x00, 0x00
},
{ // 'shyguy2' 32x28px
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0xa0, 0x60, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x81, 0x02, 0x04, 0x04, 0xfc, 0x44, 0x44, 0x44, 0x44, 0xfe,
0x01, 0x00, 0x00, 0x1e, 0x1e, 0x1e, 0x00, 0x00, 0x1e, 0x1e, 0x1e, 0x00, 0x01, 0xfe, 0x00, 0x00,
0x00, 0x38, 0x24, 0x22, 0x21, 0xc0, 0x00, 0x01, 0x02, 0x02, 0x03, 0x80, 0x80, 0x00, 0x00, 0x0f,
0x10, 0x20, 0xc0, 0x40, 0x80, 0x80, 0x98, 0x98, 0x80, 0x80, 0xc0, 0x20, 0x30, 0xcf, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x21, 0x42, 0x44,
0x48, 0x48, 0x47, 0x40, 0x40, 0x40, 0x40, 0x20, 0x20, 0x20, 0x1f, 0x04, 0x08, 0x0f, 0x00, 0x00
}
};
static const char PROGMEM eerie[2][ANIM_SIZE_GHOST] = { // frames de eerie
{ // 'eerie1' 32x28px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x80, 0x00, 0x80, 0x40, 0x20, 0x20, 0x20,
0x20, 0x40, 0x80, 0x40, 0x20, 0x20, 0x20, 0x20, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x80, 0x4f, 0x50, 0xf0, 0x10, 0x08, 0x07, 0x18, 0x20, 0x40, 0x84, 0x84,
0x84, 0x40, 0x20, 0x10, 0x14, 0x14, 0x14, 0x10, 0x10, 0x0f, 0x08, 0x08, 0x10, 0xe0, 0x00, 0x00,
0x00, 0x00, 0x80, 0x87, 0x48, 0x50, 0x50, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10,
0x20, 0x28, 0x28, 0xca, 0x02, 0x02, 0x02, 0x02, 0x02, 0xfe, 0x12, 0x12, 0x22, 0xc3, 0x00, 0x00,
0x00, 0x00, 0x03, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x40, 0x40, 0x40, 0x42, 0x42, 0x4c,
0x50, 0x50, 0x50, 0x4f, 0x40, 0x20, 0x10, 0x10, 0x0c, 0x07, 0x08, 0x10, 0x10, 0x0f, 0x00, 0x00
},
{ // 'eerie2' 32x28px
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x80, 0x40, 0x20, 0x20, 0x20, 0x20,
0x40, 0x80, 0x40, 0x20, 0x20, 0x20, 0x20, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x8f, 0x50, 0x50, 0xe0, 0x00, 0x01, 0x1f, 0x20, 0x40, 0x82, 0x82, 0x82,
0x40, 0x20, 0x10, 0x12, 0x0a, 0x0a, 0x08, 0x08, 0x0f, 0x08, 0x08, 0x08, 0x08, 0x10, 0xe0, 0x00,
0x00, 0x00, 0xc0, 0x5f, 0x50, 0x50, 0x50, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x10,
0x10, 0x20, 0x20, 0x48, 0x8a, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0xff, 0x21, 0xc1, 0x01, 0x00,
0x00, 0x00, 0x03, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x20, 0x20, 0x42, 0x42, 0x42, 0x44,
0x48, 0x50, 0x50, 0x48, 0x47, 0x20, 0x10, 0x10, 0x08, 0x04, 0x06, 0x09, 0x08, 0x07, 0x00, 0x00
}
};
static const char PROGMEM scare[2][ANIM_SIZE_GHOST] = { // frames de scare
{ // 'scare1' 32x28px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x18, 0x04, 0xc2, 0x21, 0x20, 0x20, 0x60, 0xc0, 0x00, 0x00,
0x00, 0x00, 0xf8, 0xf8, 0x00, 0x00, 0xf8, 0xf8, 0x01, 0x02, 0x04, 0x18, 0xe0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x19, 0x66, 0x80, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x03, 0x60, 0x60,
0x18, 0x18, 0x60, 0x60, 0x18, 0x18, 0x60, 0x60, 0x18, 0x18, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x10, 0x20, 0x20, 0x20, 0x40,
0x40, 0x40, 0x40, 0x40, 0x40, 0x20, 0x20, 0x10, 0x08, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00
},
{ // 'scare2' 32x28px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x18, 0xc4, 0x22, 0x21, 0x20, 0x20, 0x40, 0x80, 0x00, 0x00,
0x00, 0x00, 0xf8, 0xf8, 0x00, 0x00, 0xf8, 0xf8, 0x01, 0x02, 0x04, 0x18, 0xe0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x19, 0x66, 0x80, 0x00, 0x00, 0x03, 0x04, 0x08, 0x00, 0x00, 0x00, 0xc0, 0xc0,
0x7c, 0x7c, 0xf0, 0xf0, 0x7c, 0x7c, 0xf0, 0xf0, 0x3c, 0x3c, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x10, 0x20, 0x20, 0x21, 0x41,
0x40, 0x40, 0x41, 0x41, 0x40, 0x20, 0x21, 0x11, 0x08, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00
}
};
static const char PROGMEM troll[2][ANIM_SIZE_GHOST] = { // frames de troll
{ // 'troll1' 32x28px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x20, 0xd0, 0x08, 0x04, 0x02, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x7c,
0x7c, 0x44, 0x00, 0x00, 0x88, 0xf8, 0xf8, 0x70, 0x01, 0x02, 0x04, 0x18, 0xe0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x33, 0x4c, 0x80, 0x1e, 0x21, 0x20, 0x10, 0x00, 0x00, 0x18, 0x1e, 0x3c, 0x78,
0x78, 0xf8, 0xf8, 0xf8, 0xf8, 0x78, 0x78, 0x3c, 0x0e, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x10, 0x20, 0x20, 0x40, 0x40,
0x40, 0x40, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00
},
{ // 'troll2' 32x28px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x20, 0xd0, 0x08, 0x84, 0x42, 0x41, 0x40, 0x80, 0x00, 0x00, 0x00, 0x38, 0x7c,
0x7c, 0x44, 0x00, 0x00, 0x88, 0xf8, 0xf8, 0x70, 0x01, 0x02, 0x04, 0x18, 0xe0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x33, 0x4c, 0x80, 0x03, 0x04, 0x08, 0x10, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x18,
0x18, 0x38, 0x38, 0x38, 0x38, 0x38, 0x18, 0x0c, 0x06, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x10, 0x20, 0x20, 0x40, 0x40,
0x40, 0x40, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00
}
};
static const char PROGMEM laugh[2][ANIM_SIZE_GHOST] = { // frames de laugh
{ // 'laugh1' 32x28px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0x90, 0x08, 0x04, 0x02, 0x81, 0x80, 0x80, 0x80, 0x00, 0x00, 0x04,
0x04, 0x04, 0x04, 0x78, 0x00, 0x00, 0x78, 0x04, 0x05, 0x06, 0x04, 0x18, 0xe0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x66, 0x99, 0x00, 0x00, 0x0f, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x22,
0x3c, 0x3c, 0x3c, 0x78, 0x78, 0x78, 0x78, 0x3c, 0x00, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x10, 0x20, 0x20, 0x20, 0x40,
0x40, 0x40, 0x40, 0x40, 0x40, 0x20, 0x20, 0x10, 0x08, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00
},
{ // 'laugh2' 32x28px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0x90, 0x08, 0x04, 0x02, 0x81, 0x80, 0x80, 0x80, 0x00, 0x00, 0x04,
0x04, 0x04, 0x04, 0x78, 0x00, 0x00, 0x78, 0x04, 0x05, 0x06, 0x04, 0x18, 0xe0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x66, 0x99, 0x00, 0x00, 0x0f, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x22,
0x1c, 0x10, 0x10, 0x20, 0x20, 0x20, 0x20, 0x1c, 0x00, 0x00, 0x00, 0xc0, 0x3f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x10, 0x20, 0x20, 0x20, 0x40,
0x40, 0x40, 0x40, 0x40, 0x40, 0x20, 0x20, 0x10, 0x08, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00
}
};
void animate_ghost(void) {
current_ghost_frame = (current_ghost_frame + 1) % 2; // current_ghost_frame se va turnando entre los valores 0 y 1
if (led_usb_state.caps_lock) { // si esta activado Caps Lock
oled_write_raw_P(hide[abs(1 - current_ghost_frame)], ANIM_SIZE_GHOST); // ghost se esconde
}
else if (IS_LAYER_ON(_LOWER)) {
if (IS_LAYER_OFF(_TUNE)) {
oled_write_raw_P(shyguy[abs(1 - current_ghost_frame)], ANIM_SIZE_GHOST); // shyguy
}
else {
oled_write_raw_P(laugh[abs(1 - current_ghost_frame)], ANIM_SIZE_GHOST); // ghost se rie
}
}
else if (IS_LAYER_ON(_RAISE)) {
if (IS_LAYER_OFF(_TUNE)) {
oled_write_raw_P(eerie[abs(1 - current_ghost_frame)], ANIM_SIZE_GHOST); // eerie
}
else {
oled_write_raw_P(laugh[abs(1 - current_ghost_frame)], ANIM_SIZE_GHOST); // ghost se rie
}
}
else if ( (keyboard_report->mods & MOD_BIT (KC_LSFT)) || (keyboard_report->mods & MOD_BIT (KC_RSFT)) ) {
oled_write_raw_P(scare[abs(1 - current_ghost_frame)], ANIM_SIZE_GHOST); // ghost asusta
}
else if (keyboard_report->mods & MOD_BIT (KC_RALT)) {
oled_write_raw_P(troll[abs(1 - current_ghost_frame)], ANIM_SIZE_GHOST); // ghost trollea
}
else {
oled_write_raw_P(laugh[abs(1 - current_ghost_frame)], ANIM_SIZE_GHOST); // ghost se rie
}
}
if (timer_elapsed32(anim_ghost_timer) > ANIM_FRAME_DURATION) { // timer_elapsed32(anim_ghost_timer) tiempo transcurrido en ms desde la ultima vez que se actualizo anim_ghost_timer
anim_ghost_timer = timer_read32(); // se actualiza anim_ghost_timer
animate_ghost(); // se ejecuta animate_ghost()
if (current_wpm != 0) {
anim_ghost_sleep = timer_read32(); // se actualiza anim_ghost_sleep
}
}
}
static void render_layer(void) { // esta funcion muestra las capas en el OLED y resalta la capa presente
oled_write_P(PSTR("RAISE"), layer_state_is(_RAISE) && !layer_state_is(_TUNE));
oled_write_P(PSTR("BASE\n"), layer_state_is(_BASE));
oled_write_P(PSTR("LOWER"), layer_state_is(_LOWER) && !layer_state_is(_TUNE));
oled_write_P(PSTR("TUNE\n"), layer_state_is(_TUNE));
}
static void render_mode(void) {
mode_str[3] = '\0';
mode_str[2] = '0' + mode_value % 10;
mode_str[1] = '0' + ( mode_value /= 10) % 10;
mode_str[0] = '0' + mode_value / 10;
oled_write("MODE ", false);
oled_write(" ", false);
oled_write(mode_str, false); // printear valor de WPM
}
static void render_hsv(void) {
oled_write("H ", false);
hue_str[3] = '\0';
hue_str[2] = '0' + hue_value % 10;
hue_str[1] = '0' + ( hue_value /= 10) % 10;
hue_str[0] = '0' + hue_value / 10;
oled_write(hue_str, false);
oled_write("S ", false);
sat_str[3] = '\0';
sat_str[2] = '0' + sat_value % 10;
sat_str[1] = '0' + ( sat_value /= 10) % 10;
sat_str[0] = '0' + sat_value / 10;
oled_write(sat_str, false);
oled_write("V ", false);
val_str[3] = '\0';
val_str[2] = '0' + val_value % 10;
val_str[1] = '0' + ( val_value /= 10) % 10;
val_str[0] = '0' + val_value / 10;
oled_write(val_str, false);
}
static void slave_render_ghost(void) {
static const char PROGMEM fishing[2][416] = { // frames de fishing
{ // 'fishing1' 32x100px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x10,
0x10, 0x10, 0x10, 0x10, 0x20, 0x20, 0x20, 0x20, 0x50, 0x88, 0x08, 0x10, 0x28, 0x44, 0xa8, 0x10,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x7c, 0x82, 0x01, 0x61, 0x01, 0x02,
0x84, 0x48, 0x84, 0x02, 0x61, 0x01, 0x02, 0x84, 0x78, 0x00, 0x03, 0x0c, 0x32, 0xc1, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x08, 0x06, 0x01, 0x08, 0x90, 0x61, 0x02, 0x02, 0x01,
0x00, 0x00, 0x00, 0x01, 0x82, 0x82, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfe, 0x00,
0x04, 0x04, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x0e, 0x11, 0x21, 0x20, 0x20, 0x40, 0x82, 0xff,
0x02, 0x00, 0x0e, 0x11, 0x20, 0x20, 0x40, 0x01, 0x81, 0x82, 0x42, 0x44, 0x40, 0x20, 0x3f, 0x40,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9f,
0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f,
0x00, 0xc0, 0x20, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x08, 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x01, 0xfd,
0x01, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x04, 0x04, 0x02, 0x01, 0x02, 0x04, 0x04, 0x08, 0x08,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x30, 0xc0, 0x00, 0xf8, 0x04, 0x02, 0x01, 0x01, 0x31,
0x49, 0x85, 0x92, 0x68, 0x08, 0x08, 0x10, 0x20, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0x00, 0x00, 0xc0, 0x81, 0x00, 0xc0, 0xf0, 0xf0, 0xf8, 0x88,
0x00, 0x20, 0xe0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x08, 0x10, 0x13, 0x27, 0x4f, 0x5f, 0x5f, 0x5f, 0x5f,
0x5f, 0x5f, 0x5f, 0x4f, 0x27, 0x13, 0x08, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
},
{ // 'fishing2' 32x100px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x10,
0x10, 0x10, 0x10, 0x10, 0x20, 0x20, 0x20, 0x20, 0x50, 0x88, 0x08, 0x10, 0x28, 0x44, 0xa8, 0x10,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x7c, 0x82, 0x01, 0x61, 0x01, 0x02,
0x84, 0x48, 0x84, 0x02, 0x61, 0x01, 0x02, 0x84, 0x78, 0x00, 0x03, 0x0c, 0x32, 0xc1, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x08, 0x06, 0x01, 0x08, 0x90, 0x61, 0x02, 0x02, 0x01,
0x00, 0x00, 0x00, 0x01, 0x82, 0x82, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfe, 0x00,
0x04, 0x04, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x0e, 0x11, 0x21, 0x20, 0x20, 0x40, 0x82, 0xff,
0x02, 0x00, 0x0e, 0x11, 0x20, 0x20, 0x40, 0x01, 0x81, 0x82, 0x42, 0x44, 0x40, 0x20, 0x3f, 0x40,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9f,
0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x40, 0x40, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f,
0x00, 0xc0, 0x20, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x04, 0x08, 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x01, 0xfd,
0x01, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x04, 0x04, 0x02, 0x01, 0x02, 0x04, 0x04, 0x08, 0x08,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0xf9,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0x10, 0xd0, 0x30, 0x01, 0x82, 0x64, 0x18, 0x00, 0x00, 0x00,
0x01, 0x06, 0x18, 0xe0, 0x00, 0x00, 0xc0, 0x30, 0x08, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3f, 0xc0, 0x00, 0x00, 0x01, 0xc2, 0xe2, 0x21, 0x00, 0x80, 0xc4, 0xfc, 0xf8,
0xf0, 0xc0, 0x00, 0x00, 0x01, 0xc1, 0xf0, 0x00, 0x00, 0x01, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x08, 0x11, 0x13, 0x26, 0x4e, 0x5f, 0x5f, 0x5f, 0x5f,
0x5f, 0x5f, 0x5e, 0x5e, 0x4f, 0x27, 0x11, 0x08, 0x04, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
};
void animate_fishing(void) {
current_ghost_frame = (current_ghost_frame + 1) % 2; // current_ghost_frame se va turnando entre los valores 0 y 1
oled_write_raw_P(fishing[abs(1 - current_ghost_frame)], 416); // fishing
}
if (timer_elapsed32(anim_fishing_timer) > ANIM_FRAME_DURATION) { // timer_elapsed32(anim_ghost_timer) tiempo transcurrido en ms desde la ultima vez que se actualizo anim_ghost_timer
anim_fishing_timer = timer_read32(); // se actualiza anim_ghost_timer
animate_fishing(); // se ejecuta animate_ghost()
if (current_wpm != 0) {
anim_fishing_sleep = timer_read32(); // se actualiza anim_ghost_sleep
}
}
}
/*
static void render_wpm(void) {
oled_write("WPM\n", false);
sprintf(wpm_str, "%03d", current_wpm);
oled_write(wpm_str, false); // printear valor de WPM
}
*/
oled_rotation_t oled_init_user(oled_rotation_t rotation) {
if (is_keyboard_master()) {
return OLED_ROTATION_270;
}
else {
return OLED_ROTATION_270;
}
return rotation;
// rotacion de 270 en ambas pantallas OLED (master y slave)
// de manera que el punto inicial este en un cierto extremo
// y se siga cierta orientacion
}
// el OLED es de 128x32 pixeles
// cada page es de 8 pixeles a lo largo del lado con 128 px
// por lo que hay 16 pages a lo largo de los 128 px
bool oled_task_user(void) { // funcion en la cual se indica que poner en cada OLED
current_wpm = get_current_wpm();
mode_value = rgblight_get_mode();
hue_value = rgblight_get_hue();
sat_value = rgblight_get_sat();
val_value = rgblight_get_val();
if ((timer_elapsed32(anim_ghost_sleep) > 120000) && (timer_elapsed32(anim_fishing_sleep) > 120000) && (current_wpm == 0)) {
if (is_oled_on()) {
oled_off();
}
timer_init();
return true;
}
if (current_wpm != 0 && !is_oled_on()) {
oled_on();
}
led_usb_state = host_keyboard_led_state();
if (is_keyboard_master()) { // OLED del master
oled_set_cursor(0,1);
master_render_ghost(); // lo del fantasma
oled_set_cursor(0,6);
render_layer(); // lo de las capas
oled_set_cursor(0,11);
// render_mode();
// oled_set_cursor(0,12);
render_hsv(); // lo del HSV
}
else {
oled_set_cursor(0,1);
slave_render_ghost();
oled_set_cursor(0,13);
// render_wpm();
render_mode();
}
return true;
}
#endif // OLED_ENABLE
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case HUI:
if (record->event.pressed) {
current_hue = current_hue + 5;
if (current_hue > 255) {
current_hue = current_hue - 256;
}
}
else {
;
}
return false;
case HUD:
if (record->event.pressed) {
current_hue = current_hue - 5;
if (current_hue < 0) {
current_hue = 256 + current_hue;
}
}
else {
;
}
return false;
case LOWER:
if (record->event.pressed) {
layer_on(_LOWER);
update_tri_layer(_LOWER, _RAISE, _TUNE);
}
else {
layer_off(_LOWER);
update_tri_layer(_LOWER, _RAISE, _TUNE);
}
return false;
case RAISE:
if (record->event.pressed) {
layer_on(_RAISE);
update_tri_layer(_LOWER, _RAISE, _TUNE);
}
else {
layer_off(_RAISE);
update_tri_layer(_LOWER, _RAISE, _TUNE);
}
return false;
case QUOTE:
if (record->event.pressed) {
register_code(KC_QUOTE);
register_code(KC_SPACE);
}
else {
unregister_code(KC_QUOTE);
unregister_code(KC_SPACE);
}
return false;
case CIRC:
if (record->event.pressed) {
register_code(KC_LSFT);
register_code(KC_6);
register_code(KC_SPACE);
}
else {
unregister_code(KC_LSFT);
unregister_code(KC_6);
unregister_code(KC_SPACE);
}
return false;
case WAVE:
if (record->event.pressed) {
register_code(KC_LSFT);
register_code(KC_GRAVE);
register_code(KC_SPACE);
}
else {
unregister_code(KC_LSFT);
unregister_code(KC_GRAVE);
unregister_code(KC_SPACE);
}
return false;
case VERTICALBAR:
if (record->event.pressed) {
register_code(KC_LSFT);
register_code(KC_BSLASH);
}
else {
unregister_code(KC_LSFT);
unregister_code(KC_BSLASH);
}
return false;
case GRAVE:
if (record->event.pressed) {
register_code(KC_GRAVE);
register_code(KC_SPACE);
}
else {
unregister_code(KC_GRAVE);
unregister_code(KC_SPACE);
}
return false;
}
return true;
}