Refactor printedpad (#24236)
This commit is contained in:
		
							parent
							
								
									b5b4e93857
								
							
						
					
					
						commit
						ac1b488170
					
				
					 7 changed files with 88 additions and 77 deletions
				
			
		| 
						 | 
				
			
			@ -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);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue