forked from forks/qmk_firmware
Refactor printedpad (#24236)
This commit is contained in:
parent
b5b4e93857
commit
ac1b488170
|
@ -42,4 +42,29 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
KC_V, KC_W, KC_X,
|
||||
KC_Y, KC_Z, KC_ENT
|
||||
)
|
||||
};
|
||||
};
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
switch(keycode) {
|
||||
case LT(0, KC_NO):
|
||||
if (record->event.pressed) {
|
||||
// on tap
|
||||
if (record->tap.count) {
|
||||
if (get_highest_layer(layer_state) >= 3) {
|
||||
layer_clear();
|
||||
} else {
|
||||
layer_move(get_highest_layer(layer_state) + 1);
|
||||
}
|
||||
}
|
||||
#ifdef OLED_ENABLE
|
||||
// on hold
|
||||
else {
|
||||
void oled_display_mode_step(void);
|
||||
oled_display_mode_step();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -42,4 +42,29 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
KC_V, KC_W, KC_X,
|
||||
KC_Y, KC_Z, KC_ENT
|
||||
)
|
||||
};
|
||||
};
|
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||
switch(keycode) {
|
||||
case LT(0, KC_NO):
|
||||
if (record->event.pressed) {
|
||||
// on tap
|
||||
if (record->tap.count) {
|
||||
if (get_highest_layer(layer_state) >= 3) {
|
||||
layer_clear();
|
||||
} else {
|
||||
layer_move(get_highest_layer(layer_state) + 1);
|
||||
}
|
||||
}
|
||||
#ifdef OLED_ENABLE
|
||||
// on hold
|
||||
else {
|
||||
void oled_display_mode_step(void);
|
||||
oled_display_mode_step();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
// Copyright 2023 Noah Beidelman (@noahbei)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "printedpad.h"
|
||||
|
||||
#ifdef OLED_ENABLE
|
||||
static void flash_current_layer(void);
|
||||
#include "quantum.h"
|
||||
|
||||
#define FRAME_DURATION 200
|
||||
|
||||
uint32_t animation_timer = 0;
|
||||
uint8_t current_frame = 0;
|
||||
static uint32_t animation_timer = 0;
|
||||
static uint8_t current_frame = 0;
|
||||
|
||||
static uint32_t flash_timer = 0;
|
||||
static bool layer_changed = false;
|
||||
|
||||
static uint8_t current_display_mode = 0;
|
||||
|
||||
static bool key_pressed = false;
|
||||
|
||||
static void flash_current_layer(void);
|
||||
|
||||
|
||||
static void render_animation(void) {
|
||||
// 'monkeylong26', 128x32px
|
||||
|
@ -1391,12 +1398,16 @@ static void render_logo(void) {
|
|||
oled_write_raw_P(prota, sizeof(prota));
|
||||
}
|
||||
|
||||
bool logo_rendered = false;
|
||||
void oled_display_mode_step(void) {
|
||||
current_display_mode = (current_display_mode + 1) % 3;
|
||||
}
|
||||
|
||||
bool oled_task_kb(void) {
|
||||
if (!oled_task_user()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool logo_rendered = false;
|
||||
if (!logo_rendered) {
|
||||
render_logo();
|
||||
if (timer_read() > 2500)
|
||||
|
@ -1417,4 +1428,17 @@ bool oled_task_kb(void) {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||
key_pressed = record->event.pressed;
|
||||
|
||||
return process_record_user(keycode, record);
|
||||
}
|
||||
|
||||
// when the layer is changed, flash the layer number on the screen
|
||||
layer_state_t layer_state_set_kb(layer_state_t state) {
|
||||
flash_timer = timer_read();
|
||||
layer_changed = true;
|
||||
|
||||
return layer_state_set_user(state);
|
||||
}
|
||||
|
|
3
keyboards/printedpad/post_rules.mk
Normal file
3
keyboards/printedpad/post_rules.mk
Normal file
|
@ -0,0 +1,3 @@
|
|||
ifeq ($(strip $(OLED_ENABLE)), yes)
|
||||
SRC += oled.c
|
||||
endif
|
|
@ -1,57 +1,8 @@
|
|||
// Copyright 2023 Noah Beidelman (@noahbei)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
#include "printedpad.h"
|
||||
#include "quantum.h"
|
||||
|
||||
void board_init(void) {
|
||||
SYSCFG->CFGR1 |= SYSCFG_CFGR1_I2C1_DMA_RMP;
|
||||
}
|
||||
|
||||
const uint8_t max_layer = 3;
|
||||
uint8_t current_display_mode = 0;
|
||||
|
||||
bool key_pressed = false;
|
||||
|
||||
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
|
||||
if (!process_record_user(keycode, record)) {
|
||||
return false;
|
||||
}
|
||||
#ifdef OLED_ENABLE
|
||||
key_pressed = record->event.pressed;
|
||||
#endif
|
||||
switch(keycode) {
|
||||
case LT(0, KC_NO):
|
||||
if (record->event.pressed) {
|
||||
// on tap
|
||||
if (record->tap.count) {
|
||||
if (get_highest_layer(layer_state) >= max_layer) {
|
||||
layer_clear();
|
||||
} else {
|
||||
layer_move(get_highest_layer(layer_state) + 1);
|
||||
}
|
||||
}
|
||||
#ifdef OLED_ENABLE
|
||||
// on hold
|
||||
else {
|
||||
current_display_mode = (current_display_mode + 1) % 3;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef OLED_ENABLE
|
||||
uint32_t flash_timer = 0;
|
||||
bool layer_changed = false;
|
||||
|
||||
// when the layer is changed, flash the layer number on the screen
|
||||
layer_state_t layer_state_set_kb(layer_state_t state) {
|
||||
flash_timer = timer_read();
|
||||
layer_changed = true;
|
||||
|
||||
return layer_state_set_user(state);
|
||||
}
|
||||
#endif
|
|
@ -1,16 +0,0 @@
|
|||
// Copyright 2023 Noah Beidelman (@noahbei)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "quantum.h"
|
||||
|
||||
//for oled key press
|
||||
extern bool key_pressed;
|
||||
|
||||
// for changing oled display mode
|
||||
extern uint8_t current_display_mode;
|
||||
|
||||
//for determining when the layer is changed and having a timer for how long we flash the layer
|
||||
extern uint32_t flash_timer;
|
||||
extern bool layer_changed;
|
|
@ -1 +0,0 @@
|
|||
SRC += oled.c
|
Loading…
Reference in a new issue