// Copyright 2022 Arturo Avila (@ADPenrose) // SPDX-License-Identifier: GPL-2.0-or-later #include QMK_KEYBOARD_H #include "animation_frames.h" #ifdef OLED_ENABLE #define IDLE_FRAME_DURATION 200 // Idle animation iteration rate in ms oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_270; } uint32_t anim_timer = 0; uint32_t anim_sleep = 0; uint8_t current_idle_frame = 0; bool tap_anim = false; bool tap_anim_toggle = false; // Decompress and write a precompressed bitmap frame to the OLED. // Documentation and python compression script available at: // https://github.com/nullbitsco/squeez-o #ifdef USE_OLED_BITMAP_COMPRESSION static void oled_write_compressed_P(const char* input_block_map, const char* input_block_list) { uint16_t block_index = 0; for (uint16_t i=0; i IDLE_FRAME_DURATION) { anim_timer = timer_read32(); animation_phase(); } anim_sleep = timer_read32(); } else { // Turn off screen when timer threshold elapsed or reset time since last input if (timer_elapsed32(anim_sleep) > OLED_TIMEOUT) { oled_off(); } else { if (timer_elapsed32(anim_timer) > IDLE_FRAME_DURATION) { anim_timer = timer_read32(); animation_phase(); } } } } #endif // Animate tap bool process_record_user(uint16_t keycode, keyrecord_t *record) { #ifdef OLED_ENABLE // Check if non-mod if ((keycode >= KC_TAB && keycode <= KC_SLASH) || // Tab - Slash (Symbols, Punctuation, Space) (keycode >= KC_KP_SLASH && keycode <= KC_KP_COMMA) || // Keypad slash - Keypad Dot (keycode >= KC_F1 && keycode <= KC_F12)) { // F1 - F12 if (record->event.pressed) { // Display tap frames tap_anim_toggle = !tap_anim_toggle; #ifdef USE_OLED_BITMAP_COMPRESSION oled_write_compressed_P(tap_block_map[tap_anim_toggle], tap_frames[tap_anim_toggle]); #else oled_write_raw_P(tap_frames[tap_anim_toggle], NUM_OLED_BYTES); #endif } } #endif return true; }