1
0
Fork 0
forked from forks/qmk_firmware

fix: improper usage of keyboard/user-level functions (#22652)

This commit is contained in:
Less/Rikki 2023-12-13 13:33:15 -05:00 committed by GitHub
parent 05d2b7e2ac
commit 49527afc6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 182 additions and 161 deletions

View file

@ -17,7 +17,9 @@
#include "quantum.h"
// Tested and verified working on ext65rev2
void matrix_io_delay(void) { __asm__ volatile("nop\nnop\nnop\n"); }
void matrix_io_delay(void) {
__asm__ volatile("nop\nnop\nnop\n");
}
#ifdef OLED_ENABLE
void board_init(void) {
@ -55,26 +57,31 @@ void render_mod_status(uint8_t modifiers) {
}
bool oled_task_kb(void) {
if (!oled_task_user()) {
return false;
}
render_layer_state();
render_keylock_status(host_keyboard_led_state());
render_mod_status(get_mods()|get_oneshot_mods());
return false;
render_mod_status(get_mods() | get_oneshot_mods());
return true;
}
#else
void keyboard_pre_init_user(void) {
void keyboard_pre_init_kb(void) {
// Call the keyboard pre init code.
// Set our LED pins as output
setPinOutput(B4);
setPinOutput(B3);
setPinOutput(A15);
setPinOutput(A14);
keyboard_pre_init_user();
}
bool led_update_kb(led_t led_state) {
bool res = led_update_user(led_state);
if(res) {
if (res) {
writePin(B4, led_state.num_lock);
writePin(B3, led_state.caps_lock);
writePin(A15, led_state.scroll_lock);
@ -94,4 +101,3 @@ layer_state_t layer_state_set_kb(layer_state_t state) {
return layer_state_set_user(state);
}
#endif

View file

@ -19,7 +19,10 @@
char wpm_str[10];
#ifdef ENCODER_ENABLE
bool encoder_update_user(uint8_t index, bool clockwise) {
bool encoder_update_kb(uint8_t index, bool clockwise) {
if (!encoder_update_user(index, clockwise)) {
return false;
}
// Right encoder
if (index == 0) {
if (clockwise) {
@ -138,7 +141,10 @@ static void render_anim(void) {
}
// Used to draw on to the oled screen
bool oled_task_user(void) {
bool oled_task_kb(void) {
if (!oled_task_user()) {
return false;
}
render_anim(); // renders pixelart
oled_set_cursor(0, 0); // sets cursor to (row, column) using charactar spacing (5 rows on 128x32 screen, anything more will overflow back to the top)
@ -150,6 +156,6 @@ bool oled_task_user(void) {
oled_set_cursor(0, 1);
oled_write_P(led_state.caps_lock ? PSTR("CAPS") : PSTR(" "), false);
return false;
return true;
}
#endif

View file

@ -20,7 +20,10 @@
#include "lib/bongocat.h"
#ifdef OLED_ENABLE
bool oled_task_kb(void) {
bool oled_task_kb(void) {
if (!oled_task_user()) {
return false;
}
led_t led_usb_state = host_keyboard_led_state();
render_bongocat();
@ -33,5 +36,5 @@
oled_write_P(led_usb_state.scroll_lock ? PSTR("SCRL") : PSTR(" "), false);
return true;
}
}
#endif

View file

@ -1,4 +1,4 @@
/* Copyright 2021 HellSingCoder
/* Copyright 2021 HellSingCoder
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,8 +18,10 @@
/* Encoders */
#ifdef ENCODER_ENABLE
bool encoder_update_user(uint8_t index, bool clockwise) {
bool encoder_update_kb(uint8_t index, bool clockwise) {
if (!encoder_update_user(index, clockwise)) {
return false;
}
if (index == 0) {
if (clockwise) {
tap_code(KC_MNXT);
@ -33,6 +35,6 @@
tap_code(KC_VOLD);
}
}
return false;
}
return true;
}
#endif

View file

@ -3,9 +3,9 @@
#include "quantum.h"
#ifdef OLED_ENABLE
#define FRAMES 5
#define ANIMATION_SIZE 512
#define TAP_SPEED 30
# define FRAMES 5
# define ANIMATION_SIZE 512
# define TAP_SPEED 30
uint8_t current_frame = 0;
uint32_t anim_timer = 0;
@ -192,7 +192,7 @@ static void render_animation(void) {
if (get_current_wpm() != 000) {
oled_on(); // not essential but turns on animation OLED with any alpha keypress
if (get_current_wpm() > TAP_SPEED){
if (get_current_wpm() > TAP_SPEED) {
ANIM_FRAME_DURATION = 100;
} else {
ANIM_FRAME_DURATION = 1000;
@ -237,12 +237,15 @@ oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
}
bool oled_task_kb(void) {
if (!oled_task_user()) {
return false;
}
render_animation();
render_status();
oled_write_ln_P(PSTR("WPM:"), false);
oled_write_ln(get_u8_str(get_current_wpm(), '0'), false);
return false;
return true;
}
#endif

View file

@ -18,7 +18,7 @@
// Defines names for use in layer keycodes and the keymap
enum layer_names {
_QWERTY = 0,
_QWERTY,
_LOWER,
_RAISE,
_ADJUST
@ -27,14 +27,13 @@ enum layer_names {
#ifdef OLED_ENABLE
void render_status(void) {
// Render to mode icon
static const char os_logo[][2][3] PROGMEM ={{{0x95,0x96,0},{0xb5,0xb6,0}},{{0x97,0x98,0},{0xb7,0xb8,0}}};
static const char os_logo[][2][3] PROGMEM = {{{0x95, 0x96, 0}, {0xb5, 0xb6, 0}}, {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}}};
if (is_mac_mode()) {
oled_write_P(os_logo[0][0], false);
oled_write_P(PSTR("\n"), false);
oled_write_P(os_logo[0][1], false);
}else{
} else {
oled_write_P(os_logo[1][0], false);
oled_write_P(PSTR("\n"), false);
oled_write_P(os_logo[1][1], false);
@ -72,7 +71,6 @@ void render_status(void) {
oled_write_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR(" "), false);
}
static void render_logo(void) {
static const char PROGMEM qmk_logo[] = {
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94,
@ -84,18 +82,18 @@ static void render_logo(void) {
}
static void render_rgbled_status(bool full) {
#ifdef RGBLIGHT_ENABLE
# ifdef RGBLIGHT_ENABLE
if (RGBLIGHT_MODES > 1 && rgblight_is_enabled()) {
if (full) {
// " LED %d:%d,%d,%d"
oled_write_P(PSTR(" LED"), false);
oled_write(get_u8_str(rgblight_get_mode(), ' '), false);
oled_write_char(':', false);
oled_write(get_u8_str(rgblight_get_hue()/RGBLIGHT_HUE_STEP, ' '), false);
oled_write(get_u8_str(rgblight_get_hue() / RGBLIGHT_HUE_STEP, ' '), false);
oled_write_char(',', false);
oled_write(get_u8_str(rgblight_get_sat()/RGBLIGHT_SAT_STEP, ' '), false);
oled_write(get_u8_str(rgblight_get_sat() / RGBLIGHT_SAT_STEP, ' '), false);
oled_write_char(',', false);
oled_write(get_u8_str(rgblight_get_val()/RGBLIGHT_VAL_STEP, ' '), false);
oled_write(get_u8_str(rgblight_get_val() / RGBLIGHT_VAL_STEP, ' '), false);
} else {
// "[%2d] "
oled_write_char('[', false);
@ -103,16 +101,19 @@ static void render_rgbled_status(bool full) {
oled_write_char(']', false);
}
}
#endif
# endif
}
bool oled_task_user(void) {
if(is_keyboard_master()){
bool oled_task_kb(void) {
if (!oled_task_user()) {
return false;
}
if (is_keyboard_master()) {
render_status();
}else{
} else {
render_logo();
render_rgbled_status(true);
}
return false;
return true;
}
#endif