summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
authorJoshua Colbeck <Skrymir@users.noreply.github.com>2016-07-12 23:14:30 -0500
committerGitHub <noreply@github.com>2016-07-12 23:14:30 -0500
commit68ceffe53e299fb504bdd4733b1555a8558b472b (patch)
treeae9cc958d239374478338fee2783c203517d6762 /quantum
parentac978a50a2f523f2de7f928a6b41ac40469911c2 (diff)
parenta998a48673372e409991066d7d2d9ba282f79d59 (diff)
Merge pull request #2 from jackhumbert/master
Pull from upstream
Diffstat (limited to 'quantum')
-rw-r--r--quantum/keymap.h10
-rw-r--r--quantum/keymap_common.c2
-rwxr-xr-xquantum/light_ws2812.c25
-rw-r--r--quantum/quantum.c66
-rw-r--r--quantum/rgblight.c23
-rw-r--r--quantum/rgblight.h7
-rw-r--r--quantum/template/template.c2
-rw-r--r--quantum/visualizer/led_test.c4
-rw-r--r--quantum/visualizer/visualizer.c14
-rw-r--r--quantum/visualizer/visualizer.h2
-rw-r--r--quantum/visualizer/visualizer.mk36
11 files changed, 142 insertions, 49 deletions
diff --git a/quantum/keymap.h b/quantum/keymap.h
index 73f99f8211..a158651839 100644
--- a/quantum/keymap.h
+++ b/quantum/keymap.h
@@ -156,6 +156,16 @@ enum quantum_keycodes {
BL_INC,
BL_TOGG,
BL_STEP,
+
+ // RGB functionality
+ RGB_TOG,
+ RGB_MOD,
+ RGB_HUI,
+ RGB_HUD,
+ RGB_SAI,
+ RGB_SAD,
+ RGB_VAI,
+ RGB_VAD,
// Left shift, open paren
KC_LSPO,
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
index 76872ac592..d0a8312c1e 100644
--- a/quantum/keymap_common.c
+++ b/quantum/keymap_common.c
@@ -62,7 +62,7 @@ action_t action_for_key(uint8_t layer, keypos_t key)
case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE:
action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode));
break;
- case KC_AUDIO_MUTE ... KC_WWW_FAVORITES:
+ case KC_AUDIO_MUTE ... KC_MEDIA_REWIND:
action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode));
break;
case KC_MS_UP ... KC_MS_ACCEL2:
diff --git a/quantum/light_ws2812.c b/quantum/light_ws2812.c
index f20043067e..401845e855 100755
--- a/quantum/light_ws2812.c
+++ b/quantum/light_ws2812.c
@@ -19,12 +19,16 @@
// Setleds for standard RGB
void inline ws2812_setleds(struct cRGB *ledarray, uint16_t leds)
{
- ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin));
+ // ws2812_setleds_pin(ledarray,leds, _BV(ws2812_pin));
+ ws2812_setleds_pin(ledarray,leds, _BV(RGB_DI_PIN & 0xF));
}
void inline ws2812_setleds_pin(struct cRGB *ledarray, uint16_t leds, uint8_t pinmask)
{
- ws2812_DDRREG |= pinmask; // Enable DDR
+ // ws2812_DDRREG |= pinmask; // Enable DDR
+ // new universal format (DDR)
+ _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= pinmask;
+
ws2812_sendarray_mask((uint8_t*)ledarray,leds+leds+leds,pinmask);
_delay_us(50);
}
@@ -32,14 +36,17 @@ void inline ws2812_setleds_pin(struct cRGB *ledarray, uint16_t leds, uint8_t pin
// Setleds for SK6812RGBW
void inline ws2812_setleds_rgbw(struct cRGBW *ledarray, uint16_t leds)
{
- ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR
- ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(ws2812_pin));
+ // ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR
+ // new universal format (DDR)
+ _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF);
+
+ ws2812_sendarray_mask((uint8_t*)ledarray,leds<<2,_BV(RGB_DI_PIN & 0xF));
_delay_us(80);
}
void ws2812_sendarray(uint8_t *data,uint16_t datlen)
{
- ws2812_sendarray_mask(data,datlen,_BV(ws2812_pin));
+ ws2812_sendarray_mask(data,datlen,_BV(RGB_DI_PIN & 0xF));
}
/*
@@ -108,8 +115,10 @@ void inline ws2812_sendarray_mask(uint8_t *data,uint16_t datlen,uint8_t maskhi)
uint8_t curbyte,ctr,masklo;
uint8_t sreg_prev;
- masklo =~maskhi&ws2812_PORTREG;
- maskhi |= ws2812_PORTREG;
+ // masklo =~maskhi&ws2812_PORTREG;
+ // maskhi |= ws2812_PORTREG;
+ masklo =~maskhi&_SFR_IO8((RGB_DI_PIN >> 4) + 2);
+ maskhi |= _SFR_IO8((RGB_DI_PIN >> 4) + 2);
sreg_prev=SREG;
cli();
@@ -173,7 +182,7 @@ w_nop16
" dec %0 \n\t" // '1' [+2] '0' [+2]
" brne loop%=\n\t" // '1' [+3] '0' [+4]
: "=&d" (ctr)
- : "r" (curbyte), "I" (_SFR_IO_ADDR(ws2812_PORTREG)), "r" (maskhi), "r" (masklo)
+ : "r" (curbyte), "I" (_SFR_IO_ADDR(_SFR_IO8((RGB_DI_PIN >> 4) + 2))), "r" (maskhi), "r" (masklo)
);
}
diff --git a/quantum/quantum.c b/quantum/quantum.c
index d8e43a4655..d5b9753b76 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -93,16 +93,66 @@ bool process_record_quantum(keyrecord_t *record) {
*(uint16_t *)0x0800 = 0x7777; // these two are a-star-specific
#endif
bootloader_jump();
- return false;
}
+ return false;
break;
case DEBUG:
if (record->event.pressed) {
print("\nDEBUG: enabled.\n");
debug_enable = true;
- return false;
}
+ return false;
+ break;
+ #ifdef RGBLIGHT_ENABLE
+ case RGB_TOG:
+ if (record->event.pressed) {
+ rgblight_toggle();
+ }
+ return false;
+ break;
+ case RGB_MOD:
+ if (record->event.pressed) {
+ rgblight_step();
+ }
+ return false;
break;
+ case RGB_HUI:
+ if (record->event.pressed) {
+ rgblight_increase_hue();
+ }
+ return false;
+ break;
+ case RGB_HUD:
+ if (record->event.pressed) {
+ rgblight_decrease_hue();
+ }
+ return false;
+ break;
+ case RGB_SAI:
+ if (record->event.pressed) {
+ rgblight_increase_sat();
+ }
+ return false;
+ break;
+ case RGB_SAD:
+ if (record->event.pressed) {
+ rgblight_decrease_sat();
+ }
+ return false;
+ break;
+ case RGB_VAI:
+ if (record->event.pressed) {
+ rgblight_increase_val();
+ }
+ return false;
+ break;
+ case RGB_VAD:
+ if (record->event.pressed) {
+ rgblight_decrease_val();
+ }
+ return false;
+ break;
+ #endif
case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_UNSWAP_ALT_GUI:
if (record->event.pressed) {
// MAGIC actions (BOOTMAGIC without the boot)
@@ -162,6 +212,12 @@ bool process_record_quantum(keyrecord_t *record) {
register_mods(MOD_BIT(KC_LSFT));
}
else {
+ #ifdef DISABLE_SPACE_CADET_ROLLOVER
+ if (get_mods() & MOD_BIT(KC_RSFT)) {
+ shift_interrupted[0] = true;
+ shift_interrupted[1] = true;
+ }
+ #endif
if (!shift_interrupted[0]) {
register_code(LSPO_KEY);
unregister_code(LSPO_KEY);
@@ -178,6 +234,12 @@ bool process_record_quantum(keyrecord_t *record) {
register_mods(MOD_BIT(KC_RSFT));
}
else {
+ #ifdef DISABLE_SPACE_CADET_ROLLOVER
+ if (get_mods() & MOD_BIT(KC_LSFT)) {
+ shift_interrupted[0] = true;
+ shift_interrupted[1] = true;
+ }
+ #endif
if (!shift_interrupted[1]) {
register_code(RSPC_KEY);
unregister_code(RSPC_KEY);
diff --git a/quantum/rgblight.c b/quantum/rgblight.c
index c29ffedc38..b1b0f035d5 100644
--- a/quantum/rgblight.c
+++ b/quantum/rgblight.c
@@ -146,7 +146,9 @@ void rgblight_init(void) {
}
eeconfig_debug_rgblight(); // display current eeprom values
- rgblight_timer_init(); // setup the timer
+ #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
+ rgblight_timer_init(); // setup the timer
+ #endif
if (rgblight_config.enable) {
rgblight_mode(rgblight_config.mode);
@@ -192,14 +194,19 @@ void rgblight_mode(uint8_t mode) {
eeconfig_update_rgblight(rgblight_config.raw);
xprintf("rgblight mode: %u\n", rgblight_config.mode);
if (rgblight_config.mode == 1) {
- rgblight_timer_disable();
+ #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
+ rgblight_timer_disable();
+ #endif
} else if (rgblight_config.mode >=2 && rgblight_config.mode <=23) {
// MODE 2-5, breathing
// MODE 6-8, rainbow mood
// MODE 9-14, rainbow swirl
// MODE 15-20, snake
// MODE 21-23, knight
- rgblight_timer_enable();
+
+ #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
+ rgblight_timer_enable();
+ #endif
}
rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
}
@@ -211,7 +218,10 @@ void rgblight_toggle(void) {
if (rgblight_config.enable) {
rgblight_mode(rgblight_config.mode);
} else {
- rgblight_timer_disable();
+
+ #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
+ rgblight_timer_disable();
+ #endif
_delay_ms(50);
rgblight_set();
}
@@ -328,6 +338,9 @@ void rgblight_set(void) {
}
}
+
+#if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
+
// Animation timer -- AVR Timer3
void rgblight_timer_init(void) {
static uint8_t rgblight_timer_is_init = 0;
@@ -503,3 +516,5 @@ void rgblight_effect_knight(uint8_t interval) {
}
}
+
+#endif \ No newline at end of file
diff --git a/quantum/rgblight.h b/quantum/rgblight.h
index 64f92523e0..def26c428c 100644
--- a/quantum/rgblight.h
+++ b/quantum/rgblight.h
@@ -1,8 +1,11 @@
#ifndef RGBLIGHT_H
#define RGBLIGHT_H
-#ifndef RGBLIGHT_MODES
-#define RGBLIGHT_MODES 23
+
+#if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
+ #define RGBLIGHT_MODES 23
+#else
+ #define RGBLIGHT_MODES 1
#endif
#ifndef RGBLIGHT_EFFECT_SNAKE_LENGTH
diff --git a/quantum/template/template.c b/quantum/template/template.c
index dcc4b0a221..5ef349583c 100644
--- a/quantum/template/template.c
+++ b/quantum/template/template.c
@@ -18,7 +18,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
// put your per-action keyboard code here
// runs for every action, just before processing by the firmware
- return process_action_user(record);
+ return process_record_user(keycode, record);
}
void led_set_kb(uint8_t usb_led) {
diff --git a/quantum/visualizer/led_test.c b/quantum/visualizer/led_test.c
index c2ea30b55b..a9abace8df 100644
--- a/quantum/visualizer/led_test.c
+++ b/quantum/visualizer/led_test.c
@@ -89,8 +89,8 @@ static uint8_t crossfade_start_frame[NUM_ROWS][NUM_COLS];
static uint8_t crossfade_end_frame[NUM_ROWS][NUM_COLS];
static uint8_t compute_gradient_color(float t, float index, float num) {
- const float two_pi = 2.0f * PI;
- float normalized_index = (1.0f - index / (num - 1)) * two_pi;
+ const float two_pi = M_2_PI;
+ float normalized_index = (1.0f - index / (num - 1.0f)) * two_pi;
float x = t * two_pi + normalized_index;
float v = 0.5 * (cosf(x) + 1.0f);
return (uint8_t)(255.0f * v);
diff --git a/quantum/visualizer/visualizer.c b/quantum/visualizer/visualizer.c
index c240734055..54f6faaa42 100644
--- a/quantum/visualizer/visualizer.c
+++ b/quantum/visualizer/visualizer.c
@@ -29,9 +29,7 @@ SOFTWARE.
#include "ch.h"
#endif
-#ifdef LCD_ENABLE
#include "gfx.h"
-#endif
#ifdef LCD_BACKLIGHT_ENABLE
#include "lcd_backlight.h"
@@ -45,7 +43,7 @@ SOFTWARE.
#include "nodebug.h"
#endif
-#ifdef USE_SERIAL_LINK
+#ifdef SERIAL_LINK_ENABLE
#include "serial_link/protocol/transport.h"
#include "serial_link/system/serial_link.h"
#endif
@@ -75,7 +73,7 @@ static bool visualizer_enabled = false;
#define MAX_SIMULTANEOUS_ANIMATIONS 4
static keyframe_animation_t* animations[MAX_SIMULTANEOUS_ANIMATIONS] = {};
-#ifdef USE_SERIAL_LINK
+#ifdef SERIAL_LINK_ENABLE
MASTER_TO_ALL_SLAVES_OBJECT(current_status, visualizer_keyboard_status_t);
static remote_object_t* remote_objects[] = {
@@ -458,15 +456,13 @@ static DECLARE_THREAD_FUNCTION(visualizerThread, arg) {
}
void visualizer_init(void) {
-#ifdef LCD_ENABLE
gfxInit();
-#endif
#ifdef LCD_BACKLIGHT_ENABLE
lcd_backlight_init();
#endif
-#ifdef USE_SERIAL_LINK
+#ifdef SERIAL_LINK_ENABLE
add_remote_objects(remote_objects, sizeof(remote_objects) / sizeof(remote_object_t*) );
#endif
@@ -490,7 +486,7 @@ void update_status(bool changed) {
geventSendEvent(listener);
}
}
-#ifdef USE_SERIAL_LINK
+#ifdef SERIAL_LINK_ENABLE
static systime_t last_update = 0;
systime_t current_update = chVTGetSystemTimeX();
systime_t delta = current_update - last_update;
@@ -510,7 +506,7 @@ void visualizer_update(uint32_t default_state, uint32_t state, uint32_t leds) {
// Alternatively a mutex could be used instead of the volatile variables
bool changed = false;
-#ifdef USE_SERIAL_LINK
+#ifdef SERIAL_LINK_ENABLE
if (is_serial_link_connected ()) {
visualizer_keyboard_status_t* new_status = read_current_status();
if (new_status) {
diff --git a/quantum/visualizer/visualizer.h b/quantum/visualizer/visualizer.h
index 45cfa9aa97..53e250725c 100644
--- a/quantum/visualizer/visualizer.h
+++ b/quantum/visualizer/visualizer.h
@@ -28,9 +28,7 @@ SOFTWARE.
#include <stdint.h>
#include <stdbool.h>
-#ifdef LCD_ENABLE
#include "gfx.h"
-#endif
#ifdef LCD_BACKLIGHT_ENABLE
#include "lcd_backlight.h"
diff --git a/quantum/visualizer/visualizer.mk b/quantum/visualizer/visualizer.mk
index 56525ffd93..2f4a41d66f 100644
--- a/quantum/visualizer/visualizer.mk
+++ b/quantum/visualizer/visualizer.mk
@@ -20,41 +20,41 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-GFXLIB = $(VISUALIZER_DIR)/ugfx
SRC += $(VISUALIZER_DIR)/visualizer.c
-UINCDIR += $(GFXINC) $(VISUALIZER_DIR)
+EXTRAINCDIRS += $(GFXINC) $(VISUALIZER_DIR)
+GFXLIB = $(LIB_PATH)/ugfx
+VPATH += $(VISUALIZER_PATH)
+
+OPT_DEFS += -DVISUALIZER_ENABLE
ifdef LCD_ENABLE
-UDEFS += -DLCD_ENABLE
+OPT_DEFS += -DLCD_ENABLE
ULIBS += -lm
-USE_UGFX = yes
endif
ifdef LCD_BACKLIGHT_ENABLE
SRC += $(VISUALIZER_DIR)/lcd_backlight.c
-ifndef EMULATOR
-SRC += lcd_backlight_hal.c
-endif
-UDEFS += -DLCD_BACKLIGHT_ENABLE
+OPT_DEFS += -DLCD_BACKLIGHT_ENABLE
endif
ifdef LED_ENABLE
SRC += $(VISUALIZER_DIR)/led_test.c
-UDEFS += -DLED_ENABLE
-USE_UGFX = yes
+OPT_DEFS += -DLED_ENABLE
endif
-ifdef USE_UGFX
include $(GFXLIB)/gfx.mk
-SRC += $(GFXSRC)
-UDEFS += $(patsubst %,-D%,$(patsubst -D%,%,$(GFXDEFS)))
-ULIBS += $(patsubst %,-l%,$(patsubst -l%,%,$(GFXLIBS)))
-endif
+SRC += $(patsubst $(TOP_DIR)/%,%,$(GFXSRC))
+OPT_DEFS += $(patsubst %,-D%,$(patsubst -D%,%,$(GFXDEFS)))
-ifndef VISUALIZER_USER
-VISUALIZER_USER = visualizer_user.c
+ifneq ("$(wildcard $(KEYMAP_PATH)/visualizer.c)","")
+ SRC += keyboards/$(KEYBOARD)/keymaps/$(KEYMAP)/visualizer.c
+else
+ ifeq ("$(wildcard $(SUBPROJECT_PATH)/keymaps/$(KEYMAP)/visualizer.c)","")
+$(error "$(KEYMAP_PATH)/visualizer.c" does not exist)
+ else
+ SRC += keyboards/$(KEYBOARD)/$(SUBPROJECT)/keymaps/$(KEYMAP)/visualizer.c
+ endif
endif
-SRC += $(VISUALIZER_USER)
ifdef EMULATOR
UINCDIR += $(TMK_DIR)/common