diff options
Diffstat (limited to 'users/ninjonas/ninjonas.c')
-rw-r--r-- | users/ninjonas/ninjonas.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/users/ninjonas/ninjonas.c b/users/ninjonas/ninjonas.c new file mode 100644 index 000000000..6a77ecf8b --- /dev/null +++ b/users/ninjonas/ninjonas.c | |||
@@ -0,0 +1,68 @@ | |||
1 | /* Copyright 2019 @ninjonas | ||
2 | * | ||
3 | * This program is free software: you can redistribute it and/or modify | ||
4 | * it under the terms of the GNU General Public License as published by | ||
5 | * the Free Software Foundation, either version 2 of the License, or | ||
6 | * (at your option) any later version. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | #include "ninjonas.h" | ||
17 | |||
18 | layer_state_t layer_state_set_user (layer_state_t state) { | ||
19 | return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST); | ||
20 | } | ||
21 | |||
22 | // BEGIN: SSD1306OLED | ||
23 | // SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h | ||
24 | #if defined(KEYBOARD_lily58_rev1) & defined(PROTOCOL_LUFA) | ||
25 | extern uint8_t is_master; | ||
26 | |||
27 | void matrix_init_user(void) { | ||
28 | //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h | ||
29 | iota_gfx_init(!has_usb()); // turns on the display | ||
30 | } | ||
31 | |||
32 | // When add source files to SRC in rules.mk, you can use functions. | ||
33 | const char *read_layer_state(void); | ||
34 | const char *read_logo(void); | ||
35 | //void set_keylog(uint16_t keycode, keyrecord_t *record); // Moved to process_records.h | ||
36 | const char *read_keylog(void); | ||
37 | const char *read_keylogs(void); | ||
38 | |||
39 | void matrix_scan_user(void) { | ||
40 | iota_gfx_task(); | ||
41 | } | ||
42 | |||
43 | void matrix_render_user(struct CharacterMatrix *matrix) { | ||
44 | if (is_master) { | ||
45 | // If you want to change the display of OLED, you need to change here | ||
46 | matrix_write_ln(matrix, read_layer_state()); | ||
47 | matrix_write_ln(matrix, read_keylog()); | ||
48 | matrix_write_ln(matrix, read_keylogs()); | ||
49 | } else { | ||
50 | matrix_write(matrix, read_logo()); | ||
51 | } | ||
52 | } | ||
53 | |||
54 | void matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source) { | ||
55 | if (memcmp(dest->display, source->display, sizeof(dest->display))) { | ||
56 | memcpy(dest->display, source->display, sizeof(dest->display)); | ||
57 | dest->dirty = true; | ||
58 | } | ||
59 | } | ||
60 | |||
61 | void iota_gfx_task_user(void) { | ||
62 | struct CharacterMatrix matrix; | ||
63 | matrix_clear(&matrix); | ||
64 | matrix_render_user(&matrix); | ||
65 | matrix_update(&display, &matrix); | ||
66 | } | ||
67 | #endif | ||
68 | // END: SSD1306OLED \ No newline at end of file | ||