Skip to content

Commit

Permalink
Merge pull request qmk#490 from fredizzimo/integrate_visualizer
Browse files Browse the repository at this point in the history
Integrate visualizer for ChibiOS and Infinity Ergodox
  • Loading branch information
jackhumbert authored Jul 7, 2016
2 parents 589df84 + caedec9 commit ad43d45
Show file tree
Hide file tree
Showing 26 changed files with 1,627 additions and 39 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "lib/chibios-contrib"]
path = lib/chibios-contrib
url = https://github.com/ChibiOS/ChibiOS-Contrib.git
[submodule "lib/ugfx"]
path = lib/ugfx
url = https://bitbucket.org/Tectu/ugfx
15 changes: 7 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,6 @@ ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes)
VAPTH += $(SERIAL_PATH)
endif

ifeq ($(MASTER),right)
OPT_DEFS += -DMASTER_IS_ON_RIGHT
else
ifneq ($(MASTER),left)
$(error MASTER does not have a valid value(left/right))
endif
endif

# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax

Expand Down Expand Up @@ -257,10 +249,17 @@ ifeq ($(PLATFORM),AVR)
else ifeq ($(PLATFORM),CHIBIOS)
include $(TMK_PATH)/protocol/chibios.mk
include $(TMK_PATH)/chibios.mk
OPT_OS = chibios
else
$(error Unknown platform)
endif

ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
VISUALIZER_DIR = $(QUANTUM_DIR)/visualizer
VISUALIZER_PATH = $(QUANTUM_PATH)/visualizer
include $(VISUALIZER_PATH)/visualizer.mk
endif

include $(TMK_PATH)/rules.mk

GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d-%H:%M:%S")
Expand Down
12 changes: 12 additions & 0 deletions keyboards/infinity_ergodox/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ SLEEP_LED_ENABLE ?= yes # Breathing sleep LED during USB suspend
NKRO_ENABLE ?= yes # USB Nkey Rollover
CUSTOM_MATRIX ?= yes # Custom matrix file
SERIAL_LINK_ENABLE = yes
VISUALIZER_ENABLE ?= yes
LCD_ENABLE ?= yes
LED_ENABLE ?= yes
LCD_BACKLIGHT_ENABLE ?= yes

ifdef LCD_ENABLE
include drivers/gdisp/st7565ergodox/driver.mk
endif

ifdef LED_ENABLE
include drivers/gdisp/IS31FL3731C/driver.mk
endif

ifndef QUANTUM_DIR
include ../../Makefile
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
Copyright 2016 Fred Sundvik <[email protected]>
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
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _GDISP_LLD_BOARD_H
#define _GDISP_LLD_BOARD_H

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 */
0xFF, 0x00, /* C3-1 -> C3-16 */
0xFF, 0x00, /* C4-1 -> C4-16 */
0x3F, 0x00, /* C5-1 -> C5-16 */
0x00, 0x00, /* C6-1 -> C6-16 */
0x00, 0x00, /* C7-1 -> C7-16 */
0x00, 0x00, /* C8-1 -> C8-16 */
0x00, 0x00, /* C9-1 -> C9-16 */
};

// The address of the LED
#define LA(c, r) (c + r * 16 )
// Need to be an address that is not mapped, but inside the range of the controller matrix
#define NA LA(8, 8)

// The numbers in the comments are the led numbers DXX on the PCB
// The mapping is taken from the schematic of left hand side
static const uint8_t led_mapping[GDISP_SCREEN_HEIGHT][GDISP_SCREEN_WIDTH] = {
// 45 44 43 42 41 40 39
{ LA(1, 1), LA(1, 0), LA(0, 4), LA(0, 3), LA(0, 2), LA(0, 1), LA(0, 0)},
// 52 51 50 49 48 47 46
{ LA(2, 3), LA(2, 2), LA(2, 1), LA(2, 0), LA(1, 4), LA(1, 3), LA(1, 2) },
// 58 57 56 55 54 53 N/A
{ LA(3, 4), LA(3, 3), LA(3, 2), LA(3, 1), LA(3, 0), LA(2, 4), NA },
// 67 66 65 64 63 62 61
{ LA(5, 3), LA(5, 2), LA(5, 1), LA(5, 0), LA(4, 4), LA(4, 3), LA(4, 2) },
// 76 75 74 73 72 60 59
{ LA(7, 3), LA(7, 2), LA(7, 1), LA(7, 0), LA(6, 3), LA(4, 1), LA(4, 0) },
// N/A N/A N/A N/A N/A N/A 68
{ NA, NA, NA, NA, NA, NA, LA(5, 4) },
// N/A N/A N/A N/A 71 70 69
{ NA, NA, NA, NA, LA(6, 2), LA(6, 1), LA(6, 0) },
};


#define IS31_ADDR_DEFAULT 0x74 // AD connected to GND
#define IS31_TIMEOUT 5000

static GFXINLINE void init_board(GDisplay *g) {
(void) g;
/* I2C pins */
palSetPadMode(GPIOB, 0, PAL_MODE_ALTERNATIVE_2); // PTB0/I2C0/SCL
palSetPadMode(GPIOB, 1, PAL_MODE_ALTERNATIVE_2); // PTB1/I2C0/SDA
palSetPadMode(GPIOB, 16, PAL_MODE_OUTPUT_PUSHPULL);
palClearPad(GPIOB, 16);
/* start I2C */
i2cStart(&I2CD1, &i2ccfg);
// try high drive (from kiibohd)
I2CD1.i2c->C2 |= I2Cx_C2_HDRS;
// try glitch fixing (from kiibohd)
I2CD1.i2c->FLT = 4;
}

static GFXINLINE void post_init_board(GDisplay *g) {
(void) g;
}

static GFXINLINE const uint8_t* get_led_mask(GDisplay* g) {
(void) g;
return led_mask;
}

static GFXINLINE uint8_t get_led_address(GDisplay* g, uint16_t x, uint16_t y)
{
(void) g;
return led_mapping[y][x];
}

static GFXINLINE void set_hardware_shutdown(GDisplay* g, bool shutdown) {
(void) g;
if(!shutdown) {
palSetPad(GPIOB, 16);
}
else {
palClearPad(GPIOB, 16);
}
}

static GFXINLINE void write_data(GDisplay *g, uint8_t* data, uint16_t length) {
(void) g;
i2cMasterTransmitTimeout(&I2CD1, IS31_ADDR_DEFAULT, data, length, 0, 0, US2ST(IS31_TIMEOUT));
}

#endif /* _GDISP_LLD_BOARD_H */
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GFXINC += drivers/gdisp/IS31FL3731C
GFXSRC += drivers/gdisp/IS31FL3731C/gdisp_IS31FL3731C.c
Loading

0 comments on commit ad43d45

Please sign in to comment.