Make it easier to use drivers
This commit is contained in:
		
							parent
							
								
									4da3b19603
								
							
						
					
					
						commit
						9d8279960d
					
				@ -1,2 +1,3 @@
 | 
			
		||||
GFXINC += drivers/ugfx/gdisp/is31fl3731c
 | 
			
		||||
GFXSRC += drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c
 | 
			
		||||
GDISP_DRIVER_LIST += GDISPVMT_IS31FL3731C_QMK
 | 
			
		||||
@ -20,6 +20,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
#if GFX_USE_GDISP
 | 
			
		||||
 | 
			
		||||
#define GDISP_DRIVER_VMT          GDISPVMT_IS31FL3731C_QMK
 | 
			
		||||
#define GDISP_SCREEN_HEIGHT       LED_HEIGHT
 | 
			
		||||
#define GDISP_SCREEN_WIDTH        LED_WIDTH
 | 
			
		||||
 | 
			
		||||
#include "gdisp_lld_config.h"
 | 
			
		||||
#include "src/gdisp/gdisp_driver.h"
 | 
			
		||||
 | 
			
		||||
@ -33,12 +36,6 @@ extern const uint8_t CIE1931_CURVE[];
 | 
			
		||||
/* Driver local definitions.                                                 */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
#ifndef GDISP_SCREEN_HEIGHT
 | 
			
		||||
    #define GDISP_SCREEN_HEIGHT       9
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GDISP_SCREEN_WIDTH
 | 
			
		||||
    #define GDISP_SCREEN_WIDTH        16
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GDISP_INITIAL_CONTRAST
 | 
			
		||||
    #define GDISP_INITIAL_CONTRAST    0
 | 
			
		||||
#endif
 | 
			
		||||
@ -100,7 +97,6 @@ extern const uint8_t CIE1931_CURVE[];
 | 
			
		||||
#define IS31_PWM_SIZE 0x90
 | 
			
		||||
 | 
			
		||||
#define IS31_LED_MASK_SIZE 0x12
 | 
			
		||||
#define IS31_SCREEN_WIDTH 16
 | 
			
		||||
 | 
			
		||||
#define IS31
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,2 +1,3 @@
 | 
			
		||||
GFXINC += drivers/ugfx/gdisp/st7565
 | 
			
		||||
GFXSRC += drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c
 | 
			
		||||
GDISP_DRIVER_LIST += GDISPVMT_ST7565_QMK
 | 
			
		||||
@ -20,10 +20,10 @@
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
#ifndef GDISP_SCREEN_HEIGHT
 | 
			
		||||
#define GDISP_SCREEN_HEIGHT         32
 | 
			
		||||
#define GDISP_SCREEN_HEIGHT         LCD_HEIGHT
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GDISP_SCREEN_WIDTH
 | 
			
		||||
#define GDISP_SCREEN_WIDTH          128
 | 
			
		||||
#define GDISP_SCREEN_WIDTH          LCD_WIDTH
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GDISP_INITIAL_CONTRAST
 | 
			
		||||
#define GDISP_INITIAL_CONTRAST      35
 | 
			
		||||
 | 
			
		||||
@ -22,9 +22,6 @@ static const I2CConfig i2ccfg = {
 | 
			
		||||
  400000 // clock speed (Hz); 400kHz max for IS31
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define GDISP_SCREEN_WIDTH  7
 | 
			
		||||
#define GDISP_SCREEN_HEIGHT 7
 | 
			
		||||
 | 
			
		||||
static const uint8_t led_mask[] = {
 | 
			
		||||
	0xFF, 0x00, /* C1-1 -> C1-16 */
 | 
			
		||||
	0xFF, 0x00, /* C2-1 -> C2-16 */
 | 
			
		||||
 | 
			
		||||
@ -54,11 +54,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
#define VISUALIZER_USER_DATA_SIZE 16
 | 
			
		||||
 | 
			
		||||
#define LCD_DISPLAY_NUMBER 0
 | 
			
		||||
#define LED_DISPLAY_NUMBER 1
 | 
			
		||||
 | 
			
		||||
#define LED_NUM_ROWS 7
 | 
			
		||||
#define LED_NUM_COLS 7
 | 
			
		||||
/*
 | 
			
		||||
 * Feature disable options
 | 
			
		||||
 *  These options are also useful to firmware size reduction.
 | 
			
		||||
 | 
			
		||||
@ -22,12 +22,6 @@
 | 
			
		||||
#ifndef _GFXCONF_H
 | 
			
		||||
#define _GFXCONF_H
 | 
			
		||||
 | 
			
		||||
#ifndef EMULATOR
 | 
			
		||||
#define GDISP_DRIVER_LIST                            GDISPVMT_ST7565_QMK, GDISPVMT_IS31FL3731C_QMK
 | 
			
		||||
#else
 | 
			
		||||
#define GDISP_DRIVER_LIST                            GDISPVMT_EMULATOR_LCD_ERGODOX, GDISPVMT_EMULATOR_LED_ERGODOX
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include "common_gfxconf.h"
 | 
			
		||||
 | 
			
		||||
#endif /* _GFXCONF_H */
 | 
			
		||||
 | 
			
		||||
@ -66,5 +66,10 @@ LCD_BACKLIGHT_ENABLE = yes
 | 
			
		||||
MIDI_ENABLE = no
 | 
			
		||||
RGBLIGHT_ENABLE = no
 | 
			
		||||
 | 
			
		||||
include $(TOP_DIR)/drivers/ugfx/gdisp/st7565/driver.mk
 | 
			
		||||
include $(TOP_DIR)/drivers/ugfx/gdisp/is31fl3731c/driver.mk
 | 
			
		||||
LCD_DRIVER = st7565
 | 
			
		||||
LCD_WIDTH = 128 
 | 
			
		||||
LCD_HEIGHT = 32
 | 
			
		||||
 | 
			
		||||
LED_DRIVER = is31fl3731c
 | 
			
		||||
LED_WIDTH = 7 
 | 
			
		||||
LED_HEIGHT = 7
 | 
			
		||||
@ -22,9 +22,6 @@ static const I2CConfig i2ccfg = {
 | 
			
		||||
  400000 // clock speed (Hz); 400kHz max for IS31
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define GDISP_SCREEN_WIDTH  16
 | 
			
		||||
#define GDISP_SCREEN_HEIGHT 5
 | 
			
		||||
 | 
			
		||||
static const uint8_t led_mask[] = {
 | 
			
		||||
	0xFF, 0x00, /* C1-1 -> C1-16 */
 | 
			
		||||
	0xFF, 0x00, /* C2-1 -> C2-16 */
 | 
			
		||||
 | 
			
		||||
@ -82,9 +82,3 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
//#define NO_ACTION_FUNCTION
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// The visualizer needs gfx thread priorities
 | 
			
		||||
#define LED_DISPLAY_NUMBER 0
 | 
			
		||||
 | 
			
		||||
#define LED_NUM_ROWS 5
 | 
			
		||||
#define LED_NUM_COLS 16
 | 
			
		||||
@ -22,10 +22,6 @@
 | 
			
		||||
#ifndef _GFXCONF_H
 | 
			
		||||
#define _GFXCONF_H
 | 
			
		||||
 | 
			
		||||
#ifndef EMULATOR
 | 
			
		||||
#define GDISP_DRIVER_LIST                            GDISPVMT_IS31FL3731C_QMK
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include "common_gfxconf.h"
 | 
			
		||||
 | 
			
		||||
#endif /* _GFXCONF_H */
 | 
			
		||||
 | 
			
		||||
@ -69,4 +69,6 @@ CUSTOM_MATRIX = yes # Custom matrix file
 | 
			
		||||
BACKLIGHT_ENABLE = yes
 | 
			
		||||
VISUALIZER_ENABLE = yes
 | 
			
		||||
 | 
			
		||||
include $(TOP_DIR)/drivers/ugfx/gdisp/is31fl3731c/driver.mk
 | 
			
		||||
LED_DRIVER = is31fl3731c
 | 
			
		||||
LED_WIDTH = 16 
 | 
			
		||||
LED_HEIGHT = 5
 | 
			
		||||
@ -166,8 +166,8 @@ bool lcd_keyframe_draw_logo(keyframe_animation_t* animation, visualizer_state_t*
 | 
			
		||||
    // or state structs, here we use the image
 | 
			
		||||
 | 
			
		||||
    //gdispGBlitArea is a tricky function to use since it supports blitting part of the image
 | 
			
		||||
    // if you have full screen image, then just use 128 and 32 for both source and target dimensions
 | 
			
		||||
    gdispGBlitArea(GDISP, 0, 0, 128, 32, 0, 0, 128, (pixel_t*)resource_lcd_logo);
 | 
			
		||||
    // if you have full screen image, then just use LCD_WIDTH and LCD_HEIGHT for both source and target dimensions
 | 
			
		||||
    gdispGBlitArea(GDISP, 0, 0, LCD_WIDTH, LCD_HEIGHT, 0, 0, LCD_WIDTH, (pixel_t*)resource_lcd_logo);
 | 
			
		||||
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -41,8 +41,8 @@ static void keyframe_fade_all_leds_from_to(keyframe_animation_t* animation, uint
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TODO: Should be customizable per keyboard
 | 
			
		||||
#define NUM_ROWS LED_NUM_ROWS
 | 
			
		||||
#define NUM_COLS LED_NUM_COLS
 | 
			
		||||
#define NUM_ROWS LED_HEIGHT
 | 
			
		||||
#define NUM_COLS LED_WIDTH
 | 
			
		||||
 | 
			
		||||
static uint8_t crossfade_start_frame[NUM_ROWS][NUM_COLS];
 | 
			
		||||
static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS];
 | 
			
		||||
 | 
			
		||||
@ -20,6 +20,30 @@
 | 
			
		||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 | 
			
		||||
# SOFTWARE.
 | 
			
		||||
 | 
			
		||||
define ADD_DRIVER
 | 
			
		||||
    $(1)_DRIVER:=$(strip $($(1)_DRIVER))
 | 
			
		||||
    $(1)_WIDTH:=$(strip $($(1)_WIDTH))
 | 
			
		||||
    $(1)_HEIGHT:=$(strip $($(1)_HEIGHT))
 | 
			
		||||
    ifeq ($($(1)_DRIVER),)
 | 
			
		||||
        $$(error $(1)_DRIVER is not defined)
 | 
			
		||||
    endif
 | 
			
		||||
    ifeq ($($(1)_WIDTH),)
 | 
			
		||||
        $$(error $(1)_WIDTH is not defined)
 | 
			
		||||
    endif
 | 
			
		||||
    ifeq ($($(1)_HEIGHT),)
 | 
			
		||||
        $$(error $(1)_HEIGHT is not defined)
 | 
			
		||||
    endif
 | 
			
		||||
    OPT_DEFS+=-D$(1)_WIDTH=$($(1)_WIDTH)
 | 
			
		||||
    OPT_DEFS+=-D$(1)_HEIGHT=$($(1)_HEIGHT)
 | 
			
		||||
    GFXDEFS+=-D$(1)_WIDTH=$($(1)_WIDTH)
 | 
			
		||||
    GFXDEFS+=-D$(1)_HEIGHT=$($(1)_HEIGHT)
 | 
			
		||||
    $(1)_DISPLAY_NUMBER:=$$(words $$(GDISP_DRIVER_LIST))
 | 
			
		||||
    OPT_DEFS+=-D$(1)_DISPLAY_NUMBER=$$($(1)_DISPLAY_NUMBER)
 | 
			
		||||
    include $(TOP_DIR)/drivers/ugfx/gdisp/$($(1)_DRIVER)/driver.mk
 | 
			
		||||
endef
 | 
			
		||||
 | 
			
		||||
GDISP_DRIVER_LIST:=
 | 
			
		||||
 | 
			
		||||
SRC += $(VISUALIZER_DIR)/visualizer.c \
 | 
			
		||||
	$(VISUALIZER_DIR)/visualizer_keyframes.c
 | 
			
		||||
EXTRAINCDIRS += $(GFXINC) $(VISUALIZER_DIR)
 | 
			
		||||
@ -40,10 +64,12 @@ SRC += $(VISUALIZER_DIR)/lcd_backlight_keyframes.c
 | 
			
		||||
# Note, that the linker will strip out any resources that are not actually in use
 | 
			
		||||
SRC += $(VISUALIZER_DIR)/resources/lcd_logo.c
 | 
			
		||||
OPT_DEFS += -DLCD_BACKLIGHT_ENABLE
 | 
			
		||||
$(eval $(call ADD_DRIVER,LCD))
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
 | 
			
		||||
SRC += $(VISUALIZER_DIR)/led_backlight_keyframes.c
 | 
			
		||||
$(eval $(call ADD_DRIVER,LED))
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
SRC += $(VISUALIZER_DIR)/default_animations.c
 | 
			
		||||
@ -55,6 +81,15 @@ GFXINC += quantum/visualizer
 | 
			
		||||
GFXSRC := $(patsubst $(TOP_DIR)/%,%,$(GFXSRC))
 | 
			
		||||
GFXDEFS := $(patsubst %,-D%,$(patsubst -D%,%,$(GFXDEFS)))
 | 
			
		||||
 | 
			
		||||
GDISP_LIST_COMMA=,
 | 
			
		||||
GDISP_LIST_EMPTY=
 | 
			
		||||
GDISP_LIST_SPACE=$(GDISP_LIST_EMPTY) $(GDISP_LIST_EMPTY)
 | 
			
		||||
 | 
			
		||||
GDISP_DRIVER_LIST := $(strip $(GDISP_DRIVER_LIST))
 | 
			
		||||
GDISP_DRIVER_LIST := $(subst $(GDISP_LIST_SPACE),$(GDISP_LIST_COMMA),$(GDISP_DRIVER_LIST))
 | 
			
		||||
 | 
			
		||||
GFXDEFS +=-DGDISP_DRIVER_LIST="$(GDISP_DRIVER_LIST)"
 | 
			
		||||
 | 
			
		||||
ifneq ("$(wildcard $(KEYMAP_PATH)/visualizer.c)","")
 | 
			
		||||
    SRC += keyboards/$(KEYBOARD)/keymaps/$(KEYMAP)/visualizer.c
 | 
			
		||||
else 
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user