diff options
author | QMK Bot <hello@qmk.fm> | 2022-10-07 19:31:00 +0000 |
---|---|---|
committer | QMK Bot <hello@qmk.fm> | 2022-10-07 19:31:00 +0000 |
commit | c1e05b14d5a1c73c328e791db2aea5834ffa67c0 (patch) | |
tree | 7c23049b9d1ccee11974d88ede7fe656bc4cb2ee /keyboards/crkbd/keymaps/jpe230/oled/rp2040/master/oled_master_handler.c | |
parent | 150572da447ea4ec54df0621c2cb47c26818b621 (diff) | |
parent | 5d7e19209eac263f24d90e079749f646a86e50cc (diff) |
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'keyboards/crkbd/keymaps/jpe230/oled/rp2040/master/oled_master_handler.c')
-rw-r--r-- | keyboards/crkbd/keymaps/jpe230/oled/rp2040/master/oled_master_handler.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/keyboards/crkbd/keymaps/jpe230/oled/rp2040/master/oled_master_handler.c b/keyboards/crkbd/keymaps/jpe230/oled/rp2040/master/oled_master_handler.c new file mode 100644 index 0000000000..a2230e5ee1 --- /dev/null +++ b/keyboards/crkbd/keymaps/jpe230/oled/rp2040/master/oled_master_handler.c @@ -0,0 +1,79 @@ +// Copyright 2022 Jose Pablo Ramirez (@jpe230) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "jpe230.h" +#include "indicators.h" + +extern uint8_t logged_row, logged_col; +extern uint32_t oled_timer; +extern const uint8_t key_frame[4]; + +static uint32_t frame_limiter; + +void oled_render_layer_state(void) { + int current_layer_idx = get_highest_layer(layer_state | default_layer_state); + static int current_frame = 0; + static bool first_run = 1; + + if(first_run){ + first_run = 0; + char clear[ANIM_SIZE] = {0}; + memset(clear, 0, ANIM_SIZE); + oled_write_raw_P(clear, ANIM_SIZE); + frame_limiter = timer_read(); + return; + } + + if (timer_elapsed(frame_limiter) < 12) { + return; + } + + frame_limiter = timer_read(); + + if(current_frame < key_frame[current_layer_idx]){ + current_frame = (current_frame + 1) % IDLE_FRAMES; + change_frame_up(current_frame); + }else if(current_frame > key_frame[current_layer_idx]) { + current_frame = (current_frame - 1) % IDLE_FRAMES; + change_frame_down(IDLE_FRAMES - current_frame - 1); + } + +} + +void render_master_oled() { + if (timer_elapsed32(oled_timer) > CUSTOM_OLED_TIMEOUT) { + oled_off(); + return; + } + + oled_on(); + + /* Render the layar state */ + oled_render_layer_state(); + + /* Move cursor bellow the graphic */ + oled_set_cursor(0, 12); + + /* Print logged col and row + * Format: 00x00 + */ + char logged_matrix[9] = {0}; + sprintf(logged_matrix, "%02dx%02d", logged_col, logged_row); + + /* Write a separator char: ◆, + * make sure to add a NULL terminator otherwise strlen could fail + */ + static const char PROGMEM separator[] = {4, 4, 4, 4, 4, 0}; + oled_write(separator, false); + + /* Write logged matrix position */ + oled_write(logged_matrix, false); + + /* Write another separator */ + oled_write(separator, false); + + /* Write scanrate */ + oled_write(get_u16_str(get_matrix_scan_rate(), ' '), false); +} + +oled_rotation_t rotate_master(oled_rotation_t rotation) {return OLED_ROTATION_270;} |