Skip to content

Commit

Permalink
Make it easier to use drivers
Browse files Browse the repository at this point in the history
  • Loading branch information
fredizzimo authored and jackhumbert committed Jul 10, 2017
1 parent 4da3b19 commit 9d82799
Show file tree
Hide file tree
Showing 15 changed files with 58 additions and 45 deletions.
1 change: 1 addition & 0 deletions drivers/ugfx/gdisp/is31fl3731c/driver.mk
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
GFXINC += drivers/ugfx/gdisp/is31fl3731c
GFXSRC += drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c
GDISP_DRIVER_LIST += GDISPVMT_IS31FL3731C_QMK
12 changes: 4 additions & 8 deletions drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ 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_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"

Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions drivers/ugfx/gdisp/st7565/driver.mk
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
GFXINC += drivers/ugfx/gdisp/st7565
GFXSRC += drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c
GDISP_DRIVER_LIST += GDISPVMT_ST7565_QMK
4 changes: 2 additions & 2 deletions drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions keyboards/ergodox/infinity/board_IS31FL3731C.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
5 changes: 0 additions & 5 deletions keyboards/ergodox/infinity/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 0 additions & 6 deletions keyboards/ergodox/infinity/gfxconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
9 changes: 7 additions & 2 deletions keyboards/ergodox/infinity/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions keyboards/whitefox/board_IS31FL3731C.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
8 changes: 1 addition & 7 deletions keyboards/whitefox/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#define NO_ACTION_MACRO
//#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
#endif
4 changes: 0 additions & 4 deletions keyboards/whitefox/gfxconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
4 changes: 3 additions & 1 deletion keyboards/whitefox/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions quantum/visualizer/lcd_keyframes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions quantum/visualizer/led_backlight_keyframes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
35 changes: 35 additions & 0 deletions quantum/visualizer/visualizer.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 9d82799

Please sign in to comment.