fix: improper usage of keyboard/user-level functions (#22652)
This commit is contained in:
		
							parent
							
								
									05d2b7e2ac
								
							
						
					
					
						commit
						49527afc6a
					
				
					 6 changed files with 182 additions and 161 deletions
				
			
		| 
						 | 
					@ -17,16 +17,18 @@
 | 
				
			||||||
#include "quantum.h"
 | 
					#include "quantum.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Tested and verified working on ext65rev2
 | 
					// 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
 | 
					#ifdef OLED_ENABLE
 | 
				
			||||||
void board_init(void) {
 | 
					void board_init(void) {
 | 
				
			||||||
  SYSCFG->CFGR1 |= SYSCFG_CFGR1_I2C1_DMA_RMP;
 | 
					    SYSCFG->CFGR1 |= SYSCFG_CFGR1_I2C1_DMA_RMP;
 | 
				
			||||||
  SYSCFG->CFGR1 &= ~(SYSCFG_CFGR1_SPI2_DMA_RMP);
 | 
					    SYSCFG->CFGR1 &= ~(SYSCFG_CFGR1_SPI2_DMA_RMP);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
 | 
					oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
 | 
				
			||||||
    return OLED_ROTATION_90;  // rotates the display 90 degrees
 | 
					    return OLED_ROTATION_90; // rotates the display 90 degrees
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void render_layer_state(void) {
 | 
					void render_layer_state(void) {
 | 
				
			||||||
| 
						 | 
					@ -55,26 +57,31 @@ void render_mod_status(uint8_t modifiers) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool oled_task_kb(void) {
 | 
					bool oled_task_kb(void) {
 | 
				
			||||||
 | 
					    if (!oled_task_user()) {
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    render_layer_state();
 | 
					    render_layer_state();
 | 
				
			||||||
    render_keylock_status(host_keyboard_led_state());
 | 
					    render_keylock_status(host_keyboard_led_state());
 | 
				
			||||||
    render_mod_status(get_mods()|get_oneshot_mods());
 | 
					    render_mod_status(get_mods() | get_oneshot_mods());
 | 
				
			||||||
    return false;
 | 
					    return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void keyboard_pre_init_user(void) {
 | 
					void keyboard_pre_init_kb(void) {
 | 
				
			||||||
  // Call the keyboard pre init code.
 | 
					    // Call the keyboard pre init code.
 | 
				
			||||||
  // Set our LED pins as output
 | 
					    // Set our LED pins as output
 | 
				
			||||||
  setPinOutput(B4);
 | 
					    setPinOutput(B4);
 | 
				
			||||||
  setPinOutput(B3);
 | 
					    setPinOutput(B3);
 | 
				
			||||||
  setPinOutput(A15);
 | 
					    setPinOutput(A15);
 | 
				
			||||||
  setPinOutput(A14);
 | 
					    setPinOutput(A14);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    keyboard_pre_init_user();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool led_update_kb(led_t led_state) {
 | 
					bool led_update_kb(led_t led_state) {
 | 
				
			||||||
    bool res = led_update_user(led_state);
 | 
					    bool res = led_update_user(led_state);
 | 
				
			||||||
    if(res) {
 | 
					    if (res) {
 | 
				
			||||||
        writePin(B4, led_state.num_lock);
 | 
					        writePin(B4, led_state.num_lock);
 | 
				
			||||||
        writePin(B3, led_state.caps_lock);
 | 
					        writePin(B3, led_state.caps_lock);
 | 
				
			||||||
        writePin(A15, led_state.scroll_lock);
 | 
					        writePin(A15, led_state.scroll_lock);
 | 
				
			||||||
| 
						 | 
					@ -84,14 +91,13 @@ bool led_update_kb(led_t led_state) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
layer_state_t layer_state_set_kb(layer_state_t state) {
 | 
					layer_state_t layer_state_set_kb(layer_state_t state) {
 | 
				
			||||||
    switch (get_highest_layer(state)) {
 | 
					    switch (get_highest_layer(state)) {
 | 
				
			||||||
      case 1:
 | 
					        case 1:
 | 
				
			||||||
        writePinHigh(A14);
 | 
					            writePinHigh(A14);
 | 
				
			||||||
        break;
 | 
					            break;
 | 
				
			||||||
      default: //  for any other layers, or the default layer
 | 
					        default: //  for any other layers, or the default layer
 | 
				
			||||||
        writePinLow(A14);
 | 
					            writePinLow(A14);
 | 
				
			||||||
        break;
 | 
					            break;
 | 
				
			||||||
      }
 | 
					    }
 | 
				
			||||||
    return layer_state_set_user(state);
 | 
					    return layer_state_set_user(state);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,10 @@
 | 
				
			||||||
char wpm_str[10];
 | 
					char wpm_str[10];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef ENCODER_ENABLE
 | 
					#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
 | 
					    // Right encoder
 | 
				
			||||||
    if (index == 0) {
 | 
					    if (index == 0) {
 | 
				
			||||||
        if (clockwise) {
 | 
					        if (clockwise) {
 | 
				
			||||||
| 
						 | 
					@ -42,16 +45,16 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
 | 
				
			||||||
#ifdef OLED_ENABLE
 | 
					#ifdef OLED_ENABLE
 | 
				
			||||||
// WPM-responsive animation stuff here
 | 
					// WPM-responsive animation stuff here
 | 
				
			||||||
#    define IDLE_FRAMES 5
 | 
					#    define IDLE_FRAMES 5
 | 
				
			||||||
#    define IDLE_SPEED 20  // below this wpm value your animation will idle
 | 
					#    define IDLE_SPEED 20 // below this wpm value your animation will idle
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// #define PREP_FRAMES 1 // uncomment if >1
 | 
					// #define PREP_FRAMES 1 // uncomment if >1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#    define TAP_FRAMES 2
 | 
					#    define TAP_FRAMES 2
 | 
				
			||||||
#    define TAP_SPEED 40  // above this wpm value typing animation to trigger
 | 
					#    define TAP_SPEED 40 // above this wpm value typing animation to trigger
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#    define ANIM_FRAME_DURATION 200  // how long each frame lasts in ms
 | 
					#    define ANIM_FRAME_DURATION 200 // how long each frame lasts in ms
 | 
				
			||||||
// #define SLEEP_TIMER 60000 // should sleep after this period of 0 wpm, needs fixing
 | 
					// #define SLEEP_TIMER 60000 // should sleep after this period of 0 wpm, needs fixing
 | 
				
			||||||
#    define ANIM_SIZE 636  // number of bytes in array, minimize for adequate firmware size, max is 1024
 | 
					#    define ANIM_SIZE 636 // number of bytes in array, minimize for adequate firmware size, max is 1024
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint32_t anim_timer         = 0;
 | 
					uint32_t anim_timer         = 0;
 | 
				
			||||||
uint32_t anim_sleep         = 0;
 | 
					uint32_t anim_sleep         = 0;
 | 
				
			||||||
| 
						 | 
					@ -111,7 +114,7 @@ static void render_anim(void) {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (get_current_wpm() > IDLE_SPEED && get_current_wpm() < TAP_SPEED) {
 | 
					        if (get_current_wpm() > IDLE_SPEED && get_current_wpm() < TAP_SPEED) {
 | 
				
			||||||
            // oled_write_raw_P(prep[abs((PREP_FRAMES-1)-current_prep_frame)], ANIM_SIZE); // uncomment if IDLE_FRAMES >1
 | 
					            // oled_write_raw_P(prep[abs((PREP_FRAMES-1)-current_prep_frame)], ANIM_SIZE); // uncomment if IDLE_FRAMES >1
 | 
				
			||||||
            oled_write_raw_P(prep[0], ANIM_SIZE);  // remove if IDLE_FRAMES >1
 | 
					            oled_write_raw_P(prep[0], ANIM_SIZE); // remove if IDLE_FRAMES >1
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (get_current_wpm() >= TAP_SPEED) {
 | 
					        if (get_current_wpm() >= TAP_SPEED) {
 | 
				
			||||||
            current_tap_frame = (current_tap_frame + 1) % TAP_FRAMES;
 | 
					            current_tap_frame = (current_tap_frame + 1) % TAP_FRAMES;
 | 
				
			||||||
| 
						 | 
					@ -119,7 +122,7 @@ static void render_anim(void) {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (get_current_wpm() != 000) {
 | 
					    if (get_current_wpm() != 000) {
 | 
				
			||||||
        oled_on();  // not essential but turns on animation OLED with any alpha keypress
 | 
					        oled_on(); // not essential but turns on animation OLED with any alpha keypress
 | 
				
			||||||
        if (timer_elapsed32(anim_timer) > ANIM_FRAME_DURATION) {
 | 
					        if (timer_elapsed32(anim_timer) > ANIM_FRAME_DURATION) {
 | 
				
			||||||
            anim_timer = timer_read32();
 | 
					            anim_timer = timer_read32();
 | 
				
			||||||
            animation_phase();
 | 
					            animation_phase();
 | 
				
			||||||
| 
						 | 
					@ -138,18 +141,21 @@ static void render_anim(void) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Used to draw on to the oled screen
 | 
					// Used to draw on to the oled screen
 | 
				
			||||||
bool oled_task_user(void) {
 | 
					bool oled_task_kb(void) {
 | 
				
			||||||
    render_anim();  // renders pixelart
 | 
					    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)
 | 
					    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)
 | 
				
			||||||
    oled_write_P(PSTR("WPM: "), false);
 | 
					    oled_write_P(PSTR("WPM: "), false);
 | 
				
			||||||
    oled_write(get_u8_str(get_current_wpm(), '0'), false);
 | 
					    oled_write(get_u8_str(get_current_wpm(), '0'), false);
 | 
				
			||||||
    oled_write(wpm_str, false);                       // writes wpm on top left corner of string
 | 
					    oled_write(wpm_str, false); // writes wpm on top left corner of string
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    led_t led_state = host_keyboard_led_state();  // caps lock stuff, prints CAPS on new line if caps led is on
 | 
					    led_t led_state = host_keyboard_led_state(); // caps lock stuff, prints CAPS on new line if caps led is on
 | 
				
			||||||
    oled_set_cursor(0, 1);
 | 
					    oled_set_cursor(0, 1);
 | 
				
			||||||
    oled_write_P(led_state.caps_lock ? PSTR("CAPS") : PSTR("       "), false);
 | 
					    oled_write_P(led_state.caps_lock ? PSTR("CAPS") : PSTR("       "), false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return false;
 | 
					    return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,18 +20,21 @@
 | 
				
			||||||
#include "lib/bongocat.h"
 | 
					#include "lib/bongocat.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef OLED_ENABLE
 | 
					#ifdef OLED_ENABLE
 | 
				
			||||||
    bool oled_task_kb(void) {
 | 
					bool oled_task_kb(void) {
 | 
				
			||||||
        led_t led_usb_state = host_keyboard_led_state();
 | 
					    if (!oled_task_user()) {
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
        render_bongocat();
 | 
					 | 
				
			||||||
        oled_set_cursor(14, 0); // sets cursor to (column, row) using charactar spacing (4 rows on 128x32 screen, anything more will overflow back to the top)
 | 
					 | 
				
			||||||
        oled_write_P(PSTR("WPM:"), false);
 | 
					 | 
				
			||||||
        oled_write(get_u8_str(get_current_wpm(), '0'), false); // writes wpm on top right corner of string
 | 
					 | 
				
			||||||
        oled_set_cursor(17, 2);
 | 
					 | 
				
			||||||
        oled_write_P(led_usb_state.caps_lock ? PSTR("CAPS") : PSTR("    "), false);
 | 
					 | 
				
			||||||
        oled_set_cursor(17, 3);
 | 
					 | 
				
			||||||
        oled_write_P(led_usb_state.scroll_lock ? PSTR("SCRL") : PSTR("    "), false);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return true;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    led_t led_usb_state = host_keyboard_led_state();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    render_bongocat();
 | 
				
			||||||
 | 
					    oled_set_cursor(14, 0); // sets cursor to (column, row) using charactar spacing (4 rows on 128x32 screen, anything more will overflow back to the top)
 | 
				
			||||||
 | 
					    oled_write_P(PSTR("WPM:"), false);
 | 
				
			||||||
 | 
					    oled_write(get_u8_str(get_current_wpm(), '0'), false); // writes wpm on top right corner of string
 | 
				
			||||||
 | 
					    oled_set_cursor(17, 2);
 | 
				
			||||||
 | 
					    oled_write_P(led_usb_state.caps_lock ? PSTR("CAPS") : PSTR("    "), false);
 | 
				
			||||||
 | 
					    oled_set_cursor(17, 3);
 | 
				
			||||||
 | 
					    oled_write_P(led_usb_state.scroll_lock ? PSTR("SCRL") : PSTR("    "), false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,38 +1,40 @@
 | 
				
			||||||
 /* Copyright 2021 HellSingCoder
 | 
					/* Copyright 2021 HellSingCoder
 | 
				
			||||||
  *
 | 
					 *
 | 
				
			||||||
  * This program is free software: you can redistribute it and/or modify
 | 
					 * 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
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
  * the Free Software Foundation, either version 2 of the License, or
 | 
					 * the Free Software Foundation, either version 2 of the License, or
 | 
				
			||||||
  * (at your option) any later version.
 | 
					 * (at your option) any later version.
 | 
				
			||||||
  *
 | 
					 *
 | 
				
			||||||
  * This program is distributed in the hope that it will be useful,
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
  * GNU General Public License for more details.
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
  *
 | 
					 *
 | 
				
			||||||
  * You should have received a copy of the GNU General Public License
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
					 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
  */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "quantum.h"
 | 
					#include "quantum.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Encoders */
 | 
					/* Encoders */
 | 
				
			||||||
#ifdef ENCODER_ENABLE
 | 
					#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)) {
 | 
				
			||||||
        if (index == 0) {
 | 
					 | 
				
			||||||
            if (clockwise) {
 | 
					 | 
				
			||||||
                tap_code(KC_MNXT);
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                tap_code(KC_MPRV);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        } else if (index == 1) {
 | 
					 | 
				
			||||||
            if (clockwise) {
 | 
					 | 
				
			||||||
                tap_code(KC_VOLU);
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                tap_code(KC_VOLD);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    if (index == 0) {
 | 
				
			||||||
 | 
					        if (clockwise) {
 | 
				
			||||||
 | 
					            tap_code(KC_MNXT);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            tap_code(KC_MPRV);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    } else if (index == 1) {
 | 
				
			||||||
 | 
					        if (clockwise) {
 | 
				
			||||||
 | 
					            tap_code(KC_VOLU);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            tap_code(KC_VOLD);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return true;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,13 +3,13 @@
 | 
				
			||||||
#include "quantum.h"
 | 
					#include "quantum.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef OLED_ENABLE
 | 
					#ifdef OLED_ENABLE
 | 
				
			||||||
#define FRAMES 5
 | 
					#    define FRAMES 5
 | 
				
			||||||
#define ANIMATION_SIZE 512
 | 
					#    define ANIMATION_SIZE 512
 | 
				
			||||||
#define TAP_SPEED 30
 | 
					#    define TAP_SPEED 30
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint8_t  current_frame = 0;
 | 
					uint8_t  current_frame       = 0;
 | 
				
			||||||
uint32_t anim_timer = 0;
 | 
					uint32_t anim_timer          = 0;
 | 
				
			||||||
uint32_t anim_sleep = 0;
 | 
					uint32_t anim_sleep          = 0;
 | 
				
			||||||
uint32_t ANIM_FRAME_DURATION = 1000;
 | 
					uint32_t ANIM_FRAME_DURATION = 1000;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void render_animation(void) {
 | 
					static void render_animation(void) {
 | 
				
			||||||
| 
						 | 
					@ -191,8 +191,8 @@ static void render_animation(void) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (get_current_wpm() != 000) {
 | 
					    if (get_current_wpm() != 000) {
 | 
				
			||||||
        oled_on();  // not essential but turns on animation OLED with any alpha keypress
 | 
					        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;
 | 
					            ANIM_FRAME_DURATION = 100;
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            ANIM_FRAME_DURATION = 1000;
 | 
					            ANIM_FRAME_DURATION = 1000;
 | 
				
			||||||
| 
						 | 
					@ -233,16 +233,19 @@ static void render_status(void) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
 | 
					oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
 | 
				
			||||||
        return OLED_ROTATION_270; 
 | 
					    return OLED_ROTATION_270;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool oled_task_kb(void) {
 | 
					bool oled_task_kb(void) {
 | 
				
			||||||
 | 
					    if (!oled_task_user()) {
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    render_animation();
 | 
					    render_animation();
 | 
				
			||||||
    render_status();
 | 
					    render_status();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    oled_write_ln_P(PSTR("WPM:"), false);
 | 
					    oled_write_ln_P(PSTR("WPM:"), false);
 | 
				
			||||||
    oled_write_ln(get_u8_str(get_current_wpm(), '0'), false);
 | 
					    oled_write_ln(get_u8_str(get_current_wpm(), '0'), false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return false;
 | 
					    return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,61 +18,59 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Defines names for use in layer keycodes and the keymap
 | 
					// Defines names for use in layer keycodes and the keymap
 | 
				
			||||||
enum layer_names {
 | 
					enum layer_names {
 | 
				
			||||||
  _QWERTY = 0,
 | 
					    _QWERTY,
 | 
				
			||||||
  _LOWER,
 | 
					    _LOWER,
 | 
				
			||||||
  _RAISE,
 | 
					    _RAISE,
 | 
				
			||||||
  _ADJUST
 | 
					    _ADJUST
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef OLED_ENABLE
 | 
					#ifdef OLED_ENABLE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void render_status(void) {
 | 
					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}}};
 | 
				
			||||||
 | 
					    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 {
 | 
				
			||||||
 | 
					        oled_write_P(os_logo[1][0], false);
 | 
				
			||||||
 | 
					        oled_write_P(PSTR("\n"), false);
 | 
				
			||||||
 | 
					        oled_write_P(os_logo[1][1], false);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    oled_write_P(PSTR(" "), false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // Host Keyboard Layer Status
 | 
				
			||||||
 | 
					    oled_write_P(PSTR("Layer: "), false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    switch (get_highest_layer(layer_state)) {
 | 
				
			||||||
 | 
					        case _QWERTY:
 | 
				
			||||||
 | 
					            oled_write_P(PSTR("Default\n"), false);
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case _RAISE:
 | 
				
			||||||
 | 
					            oled_write_P(PSTR("Raise\n"), false);
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case _LOWER:
 | 
				
			||||||
 | 
					            oled_write_P(PSTR("Lower\n"), false);
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        case _ADJUST:
 | 
				
			||||||
 | 
					            oled_write_P(PSTR("Adjust\n"), false);
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					        default:
 | 
				
			||||||
 | 
					            // Or use the write_ln shortcut over adding '\n' to the end of your string
 | 
				
			||||||
 | 
					            oled_write_ln_P(PSTR("Undefined"), false);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Render to mode icon
 | 
					 | 
				
			||||||
  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(PSTR("\n"), false);
 | 
				
			||||||
    oled_write_P(os_logo[0][1], false);
 | 
					 | 
				
			||||||
  }else{
 | 
					 | 
				
			||||||
    oled_write_P(os_logo[1][0], false);
 | 
					 | 
				
			||||||
    oled_write_P(PSTR("\n"), false);
 | 
					 | 
				
			||||||
    oled_write_P(os_logo[1][1], false);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  oled_write_P(PSTR(" "), false);
 | 
					    // Host Keyboard LED Status
 | 
				
			||||||
 | 
					    led_t led_state = host_keyboard_led_state();
 | 
				
			||||||
  // Host Keyboard Layer Status
 | 
					    oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR("    "), false);
 | 
				
			||||||
  oled_write_P(PSTR("Layer: "), false);
 | 
					    oled_write_P(led_state.caps_lock ? PSTR("CAP ") : PSTR("    "), false);
 | 
				
			||||||
 | 
					    oled_write_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR("    "), false);
 | 
				
			||||||
  switch (get_highest_layer(layer_state)) {
 | 
					 | 
				
			||||||
      case _QWERTY:
 | 
					 | 
				
			||||||
          oled_write_P(PSTR("Default\n"), false);
 | 
					 | 
				
			||||||
          break;
 | 
					 | 
				
			||||||
      case _RAISE:
 | 
					 | 
				
			||||||
          oled_write_P(PSTR("Raise\n"), false);
 | 
					 | 
				
			||||||
          break;
 | 
					 | 
				
			||||||
      case _LOWER:
 | 
					 | 
				
			||||||
          oled_write_P(PSTR("Lower\n"), false);
 | 
					 | 
				
			||||||
          break;
 | 
					 | 
				
			||||||
      case _ADJUST:
 | 
					 | 
				
			||||||
          oled_write_P(PSTR("Adjust\n"), false);
 | 
					 | 
				
			||||||
          break;
 | 
					 | 
				
			||||||
      default:
 | 
					 | 
				
			||||||
          // Or use the write_ln shortcut over adding '\n' to the end of your string
 | 
					 | 
				
			||||||
          oled_write_ln_P(PSTR("Undefined"), false);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  oled_write_P(PSTR("\n"), false);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Host Keyboard LED Status
 | 
					 | 
				
			||||||
  led_t led_state = host_keyboard_led_state();
 | 
					 | 
				
			||||||
  oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR("    "), false);
 | 
					 | 
				
			||||||
  oled_write_P(led_state.caps_lock ? PSTR("CAP ") : PSTR("    "), false);
 | 
					 | 
				
			||||||
  oled_write_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR("    "), false);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
static void render_logo(void) {
 | 
					static void render_logo(void) {
 | 
				
			||||||
    static const char PROGMEM qmk_logo[] = {
 | 
					    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,
 | 
					        0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92, 0x93, 0x94,
 | 
				
			||||||
| 
						 | 
					@ -84,35 +82,38 @@ static void render_logo(void) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void render_rgbled_status(bool full) {
 | 
					static void render_rgbled_status(bool full) {
 | 
				
			||||||
#ifdef RGBLIGHT_ENABLE
 | 
					#    ifdef RGBLIGHT_ENABLE
 | 
				
			||||||
  if (RGBLIGHT_MODES > 1 && rgblight_is_enabled()) {
 | 
					    if (RGBLIGHT_MODES > 1 && rgblight_is_enabled()) {
 | 
				
			||||||
    if (full) {
 | 
					        if (full) {
 | 
				
			||||||
      // " LED %d:%d,%d,%d"
 | 
					            // " LED %d:%d,%d,%d"
 | 
				
			||||||
      oled_write_P(PSTR(" LED"), false);
 | 
					            oled_write_P(PSTR(" LED"), false);
 | 
				
			||||||
      oled_write(get_u8_str(rgblight_get_mode(), ' '), false);
 | 
					            oled_write(get_u8_str(rgblight_get_mode(), ' '), false);
 | 
				
			||||||
      oled_write_char(':', 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_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_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 {
 | 
					        } else {
 | 
				
			||||||
      // "[%2d] "
 | 
					            // "[%2d] "
 | 
				
			||||||
      oled_write_char('[', false);
 | 
					            oled_write_char('[', false);
 | 
				
			||||||
      oled_write(get_u8_str(rgblight_get_mode(), ' '), false);
 | 
					            oled_write(get_u8_str(rgblight_get_mode(), ' '), false);
 | 
				
			||||||
      oled_write_char(']', false);
 | 
					            oled_write_char(']', false);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					#    endif
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool oled_task_user(void) {
 | 
					bool oled_task_kb(void) {
 | 
				
			||||||
  if(is_keyboard_master()){
 | 
					    if (!oled_task_user()) {
 | 
				
			||||||
    render_status();
 | 
					        return false;
 | 
				
			||||||
  }else{
 | 
					    }
 | 
				
			||||||
    render_logo();
 | 
					    if (is_keyboard_master()) {
 | 
				
			||||||
    render_rgbled_status(true);
 | 
					        render_status();
 | 
				
			||||||
  }
 | 
					    } else {
 | 
				
			||||||
  return false;
 | 
					        render_logo();
 | 
				
			||||||
 | 
					        render_rgbled_status(true);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue