Skip to content

Commit

Permalink
Reset key animation
Browse files Browse the repository at this point in the history
  • Loading branch information
lleonini committed Dec 24, 2024
1 parent 3bb2d04 commit f0693ad
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions keyboards/adm42/v2/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define VERSION "v2.5"
#define VERSION "v2.51"

#include QMK_KEYBOARD_H
#include <version.h>
Expand All @@ -28,6 +28,12 @@ static uint8_t tapping_term = 200;
// Without a delay, some games may miss fast tap/release triggered by dual-keys
static uint8_t dual_tap_duration = 25;

// Reset animation
static bool reset = false;
static uint8_t reset_anim_count = 0;
static uint8_t reset_anim_duration = 20;
static uint16_t reset_anim_time = 0;

// Config in eeprom
static union {
uint32_t raw;
Expand Down Expand Up @@ -961,8 +967,12 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
set_single_persistent_default_layer(_CUSTOM);
return false;
case REFLASH:
writePinLow(QMK_LED);
reset_keyboard();
reset = true;
reset_anim_time = timer_read();
reset_anim_count = 14;
rgb_matrix_enable_noeeprom();
rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR);

return false;

case ADM_INF:
Expand Down Expand Up @@ -1110,6 +1120,22 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}

void matrix_scan_user(void) {
if (reset && timer_elapsed(reset_anim_time) > reset_anim_duration) {
if (reset_anim_count == 0) {
writePinLow(QMK_LED);
reset_keyboard();
} else {
reset_anim_time = timer_read();
reset_anim_count--;
if (reset_anim_count % 2 == 0) {
rgb_matrix_sethsv_noeeprom(0, 0, 0);
reset_anim_duration = 40;
} else {
rgb_matrix_sethsv_noeeprom(0, 0, 192);
reset_anim_duration = 20;
}
}
}
mt_taphold_check();
retained_mod_check();
delayed_check();
Expand Down

0 comments on commit f0693ad

Please sign in to comment.