]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Make it easier to use drivers
authorFred Sundvik <fsundvik@gmail.com>
Sun, 9 Jul 2017 17:35:33 +0000 (20:35 +0300)
committerJack Humbert <jack.humb@gmail.com>
Mon, 10 Jul 2017 13:01:59 +0000 (09:01 -0400)
15 files changed:
drivers/ugfx/gdisp/is31fl3731c/driver.mk
drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c
drivers/ugfx/gdisp/st7565/driver.mk
drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c
keyboards/ergodox/infinity/board_IS31FL3731C.h
keyboards/ergodox/infinity/config.h
keyboards/ergodox/infinity/gfxconf.h
keyboards/ergodox/infinity/rules.mk
keyboards/whitefox/board_IS31FL3731C.h
keyboards/whitefox/config.h
keyboards/whitefox/gfxconf.h
keyboards/whitefox/rules.mk
quantum/visualizer/lcd_keyframes.c
quantum/visualizer/led_backlight_keyframes.c
quantum/visualizer/visualizer.mk

index c9de62d1e8afb4c6af813bc991064eaac67f20f4..4364787c90274c7baf591db93266a9cfd83cb6c8 100644 (file)
@@ -1,2 +1,3 @@
 GFXINC += drivers/ugfx/gdisp/is31fl3731c
 GFXSRC += drivers/ugfx/gdisp/is31fl3731c/gdisp_is31fl3731c.c
+GDISP_DRIVER_LIST += GDISPVMT_IS31FL3731C_QMK
\ No newline at end of file
index 0691dbfbf328c1db91cf6d6e7521f1581eaf387c..3faddcda8b165d10a25b412bc36ad7348bfe23ff 100644 (file)
@@ -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"
 
@@ -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
 
index 0190b6019483f60573b75d247c9f2e50dddeecb0..31fc8f1c766d25bf4a381bbfb9197786a0f7d5ca 100644 (file)
@@ -1,2 +1,3 @@
 GFXINC += drivers/ugfx/gdisp/st7565
 GFXSRC += drivers/ugfx/gdisp/st7565/gdisp_lld_ST7565.c
+GDISP_DRIVER_LIST += GDISPVMT_ST7565_QMK
\ No newline at end of file
index 55552cb795754a84e5040d834d4ec7d33f28a227..4a4c83e8910b4ae9df84dee7afcae9d039af4a99 100644 (file)
 /*===========================================================================*/
 
 #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
index 2ea73f1fb3c7d769cc2e6f52699a673957d29283..f248cc25baf64ce7080a84ac39265754f2b2c927 100644 (file)
@@ -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 */
index fa157a893f9dc3cb6afd2b6af98fdd5ab12a54ac..c46edeb7b28055ccbbd6cd53c0c09e54c2c1f149 100644 (file)
@@ -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.
index 0d017aea970fed1d3ce73ca4dc8d9e1716ffe1f2..ca338399d31b02cd78a908410dec89bd6d161863 100644 (file)
 #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 */
index 2ccf98b8c50f9736df1e9401065d183407850f69..a341bbfce8136c318abb5ccdb25dbb48e41034be 100644 (file)
@@ -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
\ No newline at end of file
+LCD_DRIVER = st7565
+LCD_WIDTH = 128 
+LCD_HEIGHT = 32
+
+LED_DRIVER = is31fl3731c
+LED_WIDTH = 7 
+LED_HEIGHT = 7
\ No newline at end of file
index 3dc5327a58f14235057edaac7b127677a41e7898..dea643f107c672741af21898434acd0f2404bef5 100644 (file)
@@ -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 */
index 76040bd7440d2cf772e30a5ecd42ecaeb6768d9f..dc33a7ce5bc634b6a91f1b0e08e07d9a10179394 100644 (file)
@@ -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
\ No newline at end of file
+#endif
\ No newline at end of file
index eb93f92ebbfe3dccb2d6a6820d339f30b1e39f8d..ca338399d31b02cd78a908410dec89bd6d161863 100644 (file)
 #ifndef _GFXCONF_H
 #define _GFXCONF_H
 
-#ifndef EMULATOR
-#define GDISP_DRIVER_LIST                            GDISPVMT_IS31FL3731C_QMK
-#endif
-
 #include "common_gfxconf.h"
 
 #endif /* _GFXCONF_H */
index 3911480718646604721168ead358a7e6c2cb7ff9..32273e08aae021a3f256a84b426d706de1c99d79 100644 (file)
@@ -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
\ No newline at end of file
index 82e4184d2ca2f38b924e39512cdfe5a0510ab8b1..75eb457001c321f65bd799ea292e8c5655c389a2 100644 (file)
@@ -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;
 }
index d2921a391a933acaa28ca62987f74e3bcf85c5ad..eb3f5561d86274733f84da09633c39801c87a505 100644 (file)
@@ -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];
index 3a0f771bcad6937c89785666a65106eb9ccb2f4d..102d23b7effeda7db2cda0551518385cbc949475 100644 (file)
 # 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