Merge pull request #1 from jackhumbert/master

Update
daktil_thumb_popravljen
kuel 2016-08-03 11:24:29 -05:00 committed by GitHub
commit 8d8709fb79
7 changed files with 562 additions and 499 deletions

View File

@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CONFIG_H #ifndef CONFIG_H
#define CONFIG_H #define CONFIG_H
#define PREVENT_STUCK_MODIFIERS
/* USB Device descriptor parameter */ /* USB Device descriptor parameter */
#define VENDOR_ID 0xFEED #define VENDOR_ID 0xFEED
@ -50,9 +51,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
) )
/* Keymap for Infiity prototype */ /* Keymap for Infinity prototype */
#define INFINITY_PROTOTYPE //#define INFINITY_PROTOTYPE
/* Keymap for Infinity 1.1a (first revision with LED support) */
//#define INFINITY_LED
/* /*
* Feature disable options * Feature disable options

View File

@ -29,15 +29,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
K54, K64, K74, K84, K05, K15, K25, K35, K45, K55, K65, K75, K85, \ K54, K64, K74, K84, K05, K15, K25, K35, K45, K55, K65, K75, K85, \
K06, K16, K26, K36, K46, K56, K66, K76 \ K06, K16, K26, K36, K46, K56, K66, K76 \
) { \ ) { \
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06 }, \ { K00, K01, K02, K03, K04, K05, K06 }, \
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16 }, \ { K10, K11, K12, K13, K14, K15, K16 }, \
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26 }, \ { K20, K21, K22, K23, K24, K25, K26 }, \
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36 }, \ { K30, K31, K32, K33, K34, K35, K36 }, \
{ KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46 }, \ { K40, K41, K42, K43, K44, K45, K46 }, \
{ KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56 }, \ { K50, K51, K52, K53, K54, K55, K56 }, \
{ KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66 }, \ { K60, K61, K62, K63, K64, K65, K66 }, \
{ KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76 }, \ { K70, K71, K72, K73, K74, K75, K76 }, \
{ KC_##K80, KC_##K81, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_##K86 } \ { K80, K81, K82, K83, K84, K85, K86 } \
} }
#else #else
@ -50,15 +50,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
K64, K74, K84, K05, K15, K25, K35, K45, K55, K65, K75, K85, K06, \ K64, K74, K84, K05, K15, K25, K35, K45, K55, K65, K75, K85, K06, \
K16, K26, K36, K46, K56, K66, K76, K86 \ K16, K26, K36, K46, K56, K66, K76, K86 \
) { \ ) { \
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06 }, \ { K00, K01, K02, K03, K04, K05, K06 }, \
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16 }, \ { K10, K11, K12, K13, K14, K15, K16 }, \
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26 }, \ { K20, K21, K22, K23, K24, K25, K26 }, \
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36 }, \ { K30, K31, K32, K33, K34, K35, K36 }, \
{ KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46 }, \ { K40, K41, K42, K43, K44, K45, K46 }, \
{ KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56 }, \ { K50, K51, K52, K53, K54, K55, K56 }, \
{ KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66 }, \ { K60, K61, K62, K63, K64, K65, K66 }, \
{ KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76 }, \ { K70, K71, K72, K73, K74, K75, K76 }, \
{ KC_##K80, KC_##K81, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_##K86 } \ { K80, K81, K82, K83, K84, K85, K86 } \
} }
#endif #endif

View File

@ -14,12 +14,12 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* | |Gui|Alt | Space |Alt |Gui| | | * | |Gui|Alt | Space |Alt |Gui| | |
* `-----------------------------------------------------------' * `-----------------------------------------------------------'
*/ */
[0] = [0] = KEYMAP(
KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS, GRV, \ KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,KC_EQL, KC_BSLS, KC_GRV, \
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,KC_RBRC,KC_BSPC, \
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, \ KC_LCTL,KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT,KC_ENT, \
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,FN0, \ KC_LSFT,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH,KC_RSFT,MO(1), \
NO, LGUI,LALT, SPC, RALT,RGUI,NO, NO), KC_NO, KC_LGUI,KC_LALT, KC_SPC, KC_RALT,KC_RGUI,KC_NO, KC_NO),
/* Layer 1: HHKB mode (HHKB Fn) /* Layer 1: HHKB mode (HHKB Fn)
* ,-----------------------------------------------------------. * ,-----------------------------------------------------------.
@ -34,15 +34,15 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* | |Gui|Alt | Space |Alt |Gui| | | * | |Gui|Alt | Space |Alt |Gui| | |
* `-----------------------------------------------------------' * `-----------------------------------------------------------'
*/ */
[1] = [1] = KEYMAP(
KEYMAP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ KC_PWR, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_INS, KC_DEL, \
CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS, UP, TRNS, BSPC, \ KC_CAPS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_PSCR,KC_SLCK,KC_PAUS, KC_UP, KC_TRNS, KC_BSPC, \
TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,PENT, \ KC_TRNS,KC_VOLD,KC_VOLU,KC_MUTE,KC_TRNS,KC_TRNS,KC_PAST,KC_PSLS,KC_HOME,KC_PGUP,KC_LEFT,KC_RGHT,KC_PENT, \
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,TRNS,TRNS, \ KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_PPLS,KC_PMNS,KC_END, KC_PGDN,KC_DOWN,KC_TRNS,KC_TRNS, \
TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS), KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS),
}; };
const uint16_t fn_actions[] = { const uint16_t fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1),
}; };

View File

@ -0,0 +1,82 @@
#include "infinity_chibios.h"
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Layer 0: Default Layer
* ,-----------------------------------------------------------.
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `|
* |-----------------------------------------------------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| Bksp|
* |-----------------------------------------------------------|
* |Contro| A| S| D| F| G| H| J| K| L| ;| '|Enter |
* |-----------------------------------------------------------|
* |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn2|
* |-----------------------------------------------------------'
* |Fn2 |Gui |Alt | Space |RAlt|Prv|PlPs|Next|
* `-----------------------------------------------------------'
*/
[0] = KEYMAP(
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSLS, KC_GRV, \
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSPC, \
KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, LT(5, KC_ENT), \
KC_LSPO, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSPC, MO(4), \
MO(4), KC_LGUI, KC_LALT, LT(3, KC_SPC), KC_RALT, KC_MPRV, KC_MPLY, KC_MNXT),
/* Layer 1: "Toggle" off SpaceFn for League of Legends
*/
[1] = KEYMAP(
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSLS, KC_GRV, \
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSPC, \
KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, \
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, MO(4), \
MO(4), KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_MPRV, KC_MPLY, KC_MNXT),
/* Layer 2: "Toggle" off SpaceFn for MapleRoyals
*/
[2] = KEYMAP(
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSLS, KC_GRV, \
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSPC, \
KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, \
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_UP, KC_LSFT, \
MO(4), KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_LEFT, KC_DOWN, KC_RGHT),
/* Layer 3: FN layer 1
*/
[3] = KEYMAP(
KC_NO, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NO, KC_NO, \
KC_NO, KC_BTN1, KC_MS_U, KC_BTN2, LALT(KC_F4), KC_HOME, KC_PGUP, KC_PSCR, KC_SLCK, KC_UP, KC_NO, KC_LPRN, KC_RPRN, KC_DEL, \
MO(6), KC_MS_L, KC_MS_D, KC_MS_R, KC_NO, KC_END, KC_PGDN, KC_TILD, KC_LEFT, KC_DOWN, KC_RGHT, KC_NO, KC_NO, \
LGUI(KC_SPC), KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_CALC, KC_MENU, KC_TRNS, TG(4), \
KC_TRNS, KC_TRNS, KC_TRNS, LT(3, KC_SPC), KC_TRNS, KC_VOLD, KC_MUTE, KC_VOLU),
/* Layer 4: FN layer 2
*/
[4] = KEYMAP(
KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_PMNS, KC_PPLS, KC_PSLS, TG(2), \
KC_CAPS, KC_NO, KC_UP, KC_NO, KC_NO, KC_NO, KC_NO, KC_PSCR, KC_NO, KC_P7, KC_P8, KC_P9, KC_PAST, KC_BSPC, \
KC_LCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_P4, KC_P5, KC_P6, KC_PENT, \
KC_LSFT, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_P1, KC_P2, KC_P3, KC_RSFT, MO(4), \
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_P0, KC_PDOT, KC_NO, TG(1)),
/* Layer 5: FN layer 3
*/
[5] = KEYMAP(
KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \
KC_TAB , KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_F13, KC_F14, KC_F15, KC_F16, KC_NO, KC_TRNS, \
KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_F17, KC_F18, KC_F19, KC_F20, LT(5, KC_ENT), \
KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_F21, KC_F22, KC_F23, KC_F24, KC_TRNS, KC_TRNS, \
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_RALT, KC_NO, KC_NO, KC_NO),
/* Layer 6: FN layer 4
*/
[6] = KEYMAP(
KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \
LCTL(LSFT(KC_TAB)), KC_NO, LGUI(KC_UP), KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \
MO(6), LGUI(KC_LEFT), LGUI(KC_DOWN), LGUI(KC_RGHT), KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \
KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_TRNS, KC_TRNS, \
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_NO, KC_NO, KC_NO),
};
const uint16_t PROGMEM fn_actions[] = {
};

View File

@ -14,12 +14,12 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* | |Gui|Alt | Space |Alt |Gui| | | * | |Gui|Alt | Space |Alt |Gui| | |
* `-----------------------------------------------------------' * `-----------------------------------------------------------'
*/ */
[0] = [0] = KEYMAP(
KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \ KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,KC_EQL, KC_BSLS,KC_GRV, \
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,KC_RBRC,KC_BSPC, \
LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,FN6, \ KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, LT(3, KC_SCLN), KC_QUOT,MT(KC_RCTL, KC_ENT), \
FN7, Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT,FN1, \ OSM(MOD_LSFT), KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, LT(2, KC_SLSH), KC_RSFT,TG(1), \
NO, LGUI,LALT, FN4, FN5, RGUI,NO, NO), KC_NO, KC_LGUI,KC_LALT, LT(4, KC_SPC), MO(4), KC_RGUI,KC_NO, KC_NO),
/* Layer 1: HHKB mode (HHKB Fn) /* Layer 1: HHKB mode (HHKB Fn)
* ,-----------------------------------------------------------. * ,-----------------------------------------------------------.
@ -34,12 +34,12 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* | |Gui|Alt | Space |Alt |Gui| | | * | |Gui|Alt | Space |Alt |Gui| | |
* `-----------------------------------------------------------' * `-----------------------------------------------------------'
*/ */
[1] = [1] = KEYMAP(
KEYMAP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ KC_PWR, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_INS, KC_DEL, \
CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS, UP, TRNS,BSPC, \ KC_CAPS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_PSCR,KC_SLCK,KC_PAUS, KC_UP, KC_TRNS,KC_BSPC, \
LCTL,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \ KC_LCTL,KC_VOLD,KC_VOLU,KC_MUTE,KC_TRNS,KC_TRNS,KC_PAST,KC_PSLS,KC_HOME,KC_PGUP,KC_LEFT,KC_RGHT,KC_ENT, \
LSFT,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,RSFT,TRNS, \ KC_LSFT,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_PPLS,KC_PMNS,KC_END, KC_PGDN,KC_DOWN,KC_RSFT,KC_TRNS, \
TRNS,LGUI,LALT, TRNS, RALT,RGUI,TRNS,TRNS), KC_TRNS,KC_LGUI,KC_LALT, KC_TRNS, KC_RALT,KC_RGUI,KC_TRNS,KC_TRNS),
/* Layer 2: Vi mode[Slash] /* Layer 2: Vi mode[Slash]
* ,-----------------------------------------------------------. * ,-----------------------------------------------------------.
@ -54,12 +54,12 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |Gui|Alt | Space |Alt |Gui| * |Gui|Alt | Space |Alt |Gui|
* `-------------------------------------------' * `-------------------------------------------'
*/ */
[2] = \ [2] = KEYMAP(
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_INS, KC_DEL, \
TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, BSPC, \ KC_TAB, KC_HOME,KC_PGDN,KC_UP, KC_PGUP,KC_END, KC_HOME,KC_PGDN,KC_PGUP,KC_END, KC_NO, KC_NO, KC_NO, KC_BSPC, \
LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, \ KC_LCTL,KC_NO, KC_LEFT,KC_DOWN,KC_RGHT,KC_NO, KC_LEFT,KC_DOWN,KC_UP, KC_RGHT,KC_NO, KC_NO, KC_ENT, \
LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT,TRNS, \ KC_LSFT,KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_HOME,KC_PGDN,KC_PGUP,KC_END, LT(2, KC_SLSH), KC_RSFT,KC_TRNS, \
TRNS,LGUI,LALT, SPC, RALT,RGUI,TRNS,TRNS), KC_TRNS,KC_LGUI,KC_LALT, KC_SPC, KC_RALT,KC_RGUI,KC_TRNS, KC_TRNS),
/* Layer 3: Mouse mode(IJKL)[Semicolon] /* Layer 3: Mouse mode(IJKL)[Semicolon]
* ,-----------------------------------------------------------. * ,-----------------------------------------------------------.
@ -75,12 +75,12 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* `--------------------------------------------' * `--------------------------------------------'
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
*/ */
[3] = \ [3] = KEYMAP(
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_INS, KC_DEL, \
FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,FN9, FN10,FN8, \ LALT(KC_TAB), KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_WH_L,KC_WH_D,KC_MS_U, KC_WH_U, KC_WH_R, ALT_T(KC_LEFT), ALT_T(KC_RGHT),LALT(KC_TAB), \
LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,FN3, NO, ENT, \ KC_LCTL, KC_ACL0,KC_ACL1,KC_ACL2,KC_ACL2,KC_NO, KC_NO, KC_MS_L,KC_MS_D, KC_MS_R, LT(3, KC_SCLN), KC_NO, KC_ENT, \
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \ KC_LSFT, KC_NO, KC_NO, KC_NO, KC_NO, KC_BTN3,KC_BTN2,KC_BTN1,ALT_T(KC_LEFT), ALT_T(KC_RGHT), KC_NO, KC_RSFT, KC_TRNS, \
TRNS,LGUI,LALT, BTN1, TRNS,TRNS,TRNS,TRNS), KC_TRNS, KC_LGUI,KC_LALT, KC_BTN1, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS),
/* Layer 4: Mouse mode(IJKL)[Space] /* Layer 4: Mouse mode(IJKL)[Space]
* ,-----------------------------------------------------------. * ,-----------------------------------------------------------.
@ -96,104 +96,18 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* `--------------------------------------------' * `--------------------------------------------'
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
*/ */
[4] = \ [4] = KEYMAP(
KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_INS, KC_DEL, \
FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,BTN4,BTN5,FN8, \ LALT(KC_TAB), KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_WH_L,KC_WH_D,KC_MS_U, KC_WH_U, KC_WH_R,KC_BTN4,KC_BTN5,LALT(KC_TAB), \
LCTL,VOLD,VOLU,MUTE,NO, NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT, \ KC_LCTL, KC_VOLD,KC_VOLU,KC_MUTE,KC_NO, KC_NO, KC_NO, KC_MS_L,KC_MS_D, KC_MS_R, KC_BTN1,KC_NO, KC_ENT, \
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \ KC_LSFT, KC_NO, KC_NO, KC_NO, KC_NO, KC_BTN3,KC_BTN2,KC_BTN1,ALT_T(KC_LEFT),ALT_T(KC_RGHT),KC_NO, KC_RSFT,KC_TRNS, \
TRNS,LGUI,LALT, TRNS, TRNS,TRNS,TRNS,TRNS), KC_TRNS, KC_LGUI,KC_LALT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS),
}; };
/* id for user defined functions */
enum function_id {
LSHIFT_LPAREN,
};
enum macro_id {
HELLO,
VOLUP,
ALT_TAB,
};
/* /*
* Fn action definition * Fn action definition
*/ */
const uint16_t fn_actions[] = { const uint16_t fn_actions[] = {
[0] = ACTION_DEFAULT_LAYER_SET(0), // Default layer(not used)
[1] = ACTION_LAYER_TAP_TOGGLE(1), // HHKB layer(toggle with 5 taps)
[2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH), // Cursor layer with Slash*
[3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN), // Mousekey layer with Semicolon*
[4] = ACTION_LAYER_TAP_KEY(4, KC_SPC), // Mousekey layer with Space
[5] = ACTION_LAYER_MOMENTARY(4), // Mousekey layer(IJKL)
[6] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT), // RControl with tap Enter
[7] = ACTION_MODS_ONESHOT(MOD_LSFT), // Oneshot Shift
[8] = ACTION_MACRO(ALT_TAB), // Application switching
[9] = ACTION_MODS_KEY(MOD_LALT, KC_LEFT),
[10] = ACTION_MODS_KEY(MOD_LALT, KC_RIGHT),
}; };
/*
* Macro definition
*/
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
switch (id) {
case HELLO:
return (record->event.pressed ?
MACRO( I(0), T(H), T(E), T(L), T(L), W(255), T(O), END ) :
MACRO_NONE );
case VOLUP:
return (record->event.pressed ?
MACRO( D(VOLU), U(VOLU), END ) :
MACRO_NONE );
case ALT_TAB:
return (record->event.pressed ?
MACRO( D(LALT), D(TAB), END ) :
MACRO( U(TAB), END ));
}
return MACRO_NONE;
}
/*
* user defined action function
*/
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
if (record->event.pressed) dprint("P"); else dprint("R");
dprintf("%d", record->tap.count);
if (record->tap.interrupted) dprint("i");
dprint("\n");
switch (id) {
case LSHIFT_LPAREN:
// Shift parentheses example: LShft + tap '('
// http://stevelosh.com/blog/2012/10/a-modern-space-cadet/#shift-parentheses
// http://geekhack.org/index.php?topic=41989.msg1304899#msg1304899
if (record->event.pressed) {
if (record->tap.count > 0 && !record->tap.interrupted) {
if (record->tap.interrupted) {
dprint("tap interrupted\n");
register_mods(MOD_BIT(KC_LSHIFT));
}
} else {
register_mods(MOD_BIT(KC_LSHIFT));
}
} else {
if (record->tap.count > 0 && !(record->tap.interrupted)) {
add_weak_mods(MOD_BIT(KC_LSHIFT));
send_keyboard_report();
register_code(KC_9);
unregister_code(KC_9);
del_weak_mods(MOD_BIT(KC_LSHIFT));
send_keyboard_report();
record->tap.count = 0; // ad hoc: cancel tap
} else {
unregister_mods(MOD_BIT(KC_LSHIFT));
}
}
break;
}
}

View File

@ -12,9 +12,12 @@
* Infinity Pinusage: * Infinity Pinusage:
* Column pins are input with internal pull-down. Row pins are output and strobe with high. * Column pins are input with internal pull-down. Row pins are output and strobe with high.
* Key is high or 1 when it turns on. * Key is high or 1 when it turns on.
* * INFINITY PRODUCTION (NO LED)
* col: { PTD1, PTD2, PTD3, PTD4, PTD5, PTD6, PTD7 } * col: { PTD1, PTD2, PTD3, PTD4, PTD5, PTD6, PTD7 }
* row: { PTB0, PTB1, PTB2, PTB3, PTB16, PTB17, PTC4, PTC5, PTD0 } * row: { PTB0, PTB1, PTB2, PTB3, PTB16, PTB17, PTC4, PTC5, PTD0 }
* INFINITY PRODUCTION (WITH LED)
* col: { PTD1, PTD2, PTD3, PTD4, PTD5, PTD6, PTD7 }
* row: { PTC0, PTC1, PTC2, PTC3, PTC4, PTC5, PTC6, PTC7, PTD0 }
*/ */
/* matrix state(1:on, 0:off) */ /* matrix state(1:on, 0:off) */
static matrix_row_t matrix[MATRIX_ROWS]; static matrix_row_t matrix[MATRIX_ROWS];
@ -34,6 +37,18 @@ void matrix_init(void)
palSetPadMode(GPIOD, 6, PAL_MODE_INPUT_PULLDOWN); palSetPadMode(GPIOD, 6, PAL_MODE_INPUT_PULLDOWN);
palSetPadMode(GPIOD, 7, PAL_MODE_INPUT_PULLDOWN); palSetPadMode(GPIOD, 7, PAL_MODE_INPUT_PULLDOWN);
#ifdef INFINITY_LED
/* Row(strobe) */
palSetPadMode(GPIOC, 0, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOC, 1, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOC, 2, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOC, 3, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOC, 4, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOC, 5, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOC, 6, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOC, 7, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOD, 0, PAL_MODE_OUTPUT_PUSHPULL);
#else
/* Row(strobe) */ /* Row(strobe) */
palSetPadMode(GPIOB, 0, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOB, 0, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOB, 1, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOB, 1, PAL_MODE_OUTPUT_PUSHPULL);
@ -44,7 +59,7 @@ void matrix_init(void)
palSetPadMode(GPIOC, 4, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOC, 4, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOC, 5, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOC, 5, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOD, 0, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOD, 0, PAL_MODE_OUTPUT_PUSHPULL);
#endif
memset(matrix, 0, MATRIX_ROWS); memset(matrix, 0, MATRIX_ROWS);
memset(matrix_debouncing, 0, MATRIX_ROWS); memset(matrix_debouncing, 0, MATRIX_ROWS);
} }
@ -53,7 +68,20 @@ uint8_t matrix_scan(void)
{ {
for (int row = 0; row < MATRIX_ROWS; row++) { for (int row = 0; row < MATRIX_ROWS; row++) {
matrix_row_t data = 0; matrix_row_t data = 0;
#ifdef INFINITY_LED
// strobe row
switch (row) {
case 0: palSetPad(GPIOC, 0); break;
case 1: palSetPad(GPIOC, 1); break;
case 2: palSetPad(GPIOC, 2); break;
case 3: palSetPad(GPIOC, 3); break;
case 4: palSetPad(GPIOC, 4); break;
case 5: palSetPad(GPIOC, 5); break;
case 6: palSetPad(GPIOC, 6); break;
case 7: palSetPad(GPIOC, 7); break;
case 8: palSetPad(GPIOD, 0); break;
}
#else
// strobe row // strobe row
switch (row) { switch (row) {
case 0: palSetPad(GPIOB, 0); break; case 0: palSetPad(GPIOB, 0); break;
@ -66,12 +94,26 @@ uint8_t matrix_scan(void)
case 7: palSetPad(GPIOC, 5); break; case 7: palSetPad(GPIOC, 5); break;
case 8: palSetPad(GPIOD, 0); break; case 8: palSetPad(GPIOD, 0); break;
} }
#endif
wait_us(1); // need wait to settle pin state wait_us(1); // need wait to settle pin state
// read col data // read col data
data = (palReadPort(GPIOD)>>1); data = (palReadPort(GPIOD)>>1);
#ifdef INFINITY_LED
// un-strobe row
switch (row) {
case 0: palClearPad(GPIOC, 0); break;
case 1: palClearPad(GPIOC, 1); break;
case 2: palClearPad(GPIOC, 2); break;
case 3: palClearPad(GPIOC, 3); break;
case 4: palClearPad(GPIOC, 4); break;
case 5: palClearPad(GPIOC, 5); break;
case 6: palClearPad(GPIOC, 6); break;
case 7: palClearPad(GPIOC, 7); break;
case 8: palClearPad(GPIOD, 0); break;
}
#else
// un-strobe row // un-strobe row
switch (row) { switch (row) {
case 0: palClearPad(GPIOB, 0); break; case 0: palClearPad(GPIOB, 0); break;
@ -84,6 +126,7 @@ uint8_t matrix_scan(void)
case 7: palClearPad(GPIOC, 5); break; case 7: palClearPad(GPIOC, 5); break;
case 8: palClearPad(GPIOD, 0); break; case 8: palClearPad(GPIOD, 0); break;
} }
#endif
if (matrix_debouncing[row] != data) { if (matrix_debouncing[row] != data) {
matrix_debouncing[row] = data; matrix_debouncing[row] = data;

View File

@ -7,24 +7,41 @@
#include "debug.h" #include "debug.h"
const uint8_t DIM_CURVE[] PROGMEM = { const uint8_t DIM_CURVE[] PROGMEM = {
0, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 0, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6,
6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8,
8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11,
11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15,
15, 15, 16, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 15, 15, 16, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20,
20, 20, 21, 21, 22, 22, 22, 23, 23, 24, 24, 25, 25, 25, 26, 26, 20, 20, 21, 21, 22, 22, 22, 23, 23, 24, 24, 25, 25, 25, 26, 26,
27, 27, 28, 28, 29, 29, 30, 30, 31, 32, 32, 33, 33, 34, 35, 35, 27, 27, 28, 28, 29, 29, 30, 30, 31, 32, 32, 33, 33, 34, 35, 35,
36, 36, 37, 38, 38, 39, 40, 40, 41, 42, 43, 43, 44, 45, 46, 47, 36, 36, 37, 38, 38, 39, 40, 40, 41, 42, 43, 43, 44, 45, 46, 47,
48, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 48, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
63, 64, 65, 66, 68, 69, 70, 71, 73, 74, 75, 76, 78, 79, 81, 82, 63, 64, 65, 66, 68, 69, 70, 71, 73, 74, 75, 76, 78, 79, 81, 82,
83, 85, 86, 88, 90, 91, 93, 94, 96, 98, 99, 101, 103, 105, 107, 109, 83, 85, 86, 88, 90, 91, 93, 94, 96, 98, 99, 101, 103, 105, 107, 109,
110, 112, 114, 116, 118, 121, 123, 125, 127, 129, 132, 134, 136, 139, 141, 144, 110, 112, 114, 116, 118, 121, 123, 125, 127, 129, 132, 134, 136, 139, 141, 144,
146, 149, 151, 154, 157, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, 190, 146, 149, 151, 154, 157, 159, 162, 165, 168, 171, 174, 177, 180, 183, 186, 190,
193, 196, 200, 203, 207, 211, 214, 218, 222, 226, 230, 234, 238, 242, 248, 255, 193, 196, 200, 203, 207, 211, 214, 218, 222, 226, 230, 234, 238, 242, 248, 255
};
const uint8_t RGBLED_BREATHING_TABLE[] PROGMEM = {
0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 5, 6, 7, 9,
10, 11, 12, 14, 15, 17, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35,
37, 40, 42, 44, 47, 49, 52, 54, 57, 59, 62, 65, 67, 70, 73, 76,
79, 82, 85, 88, 90, 93, 97, 100, 103, 106, 109, 112, 115, 118, 121, 124,
127, 131, 134, 137, 140, 143, 146, 149, 152, 155, 158, 162, 165, 167, 170, 173,
176, 179, 182, 185, 188, 190, 193, 196, 198, 201, 203, 206, 208, 211, 213, 215,
218, 220, 222, 224, 226, 228, 230, 232, 234, 235, 237, 238, 240, 241, 243, 244,
245, 246, 248, 249, 250, 250, 251, 252, 253, 253, 254, 254, 254, 255, 255, 255,
255, 255, 255, 255, 254, 254, 254, 253, 253, 252, 251, 250, 250, 249, 248, 246,
245, 244, 243, 241, 240, 238, 237, 235, 234, 232, 230, 228, 226, 224, 222, 220,
218, 215, 213, 211, 208, 206, 203, 201, 198, 196, 193, 190, 188, 185, 182, 179,
176, 173, 170, 167, 165, 162, 158, 155, 152, 149, 146, 143, 140, 137, 134, 131,
128, 124, 121, 118, 115, 112, 109, 106, 103, 100, 97, 93, 90, 88, 85, 82,
79, 76, 73, 70, 67, 65, 62, 59, 57, 54, 52, 49, 47, 44, 42, 40,
37, 35, 33, 31, 29, 27, 25, 23, 21, 20, 18, 17, 15, 14, 12, 11,
10, 9, 7, 6, 5, 5, 4, 3, 2, 2, 1, 1, 1, 0, 0, 0
}; };
const uint8_t RGBLED_BREATHING_TABLE[] PROGMEM = {0,0,0,0,1,1,1,2,2,3,4,5,5,6,7,9,10,11,12,14,15,17,18,20,21,23,25,27,29,31,33,35,37,40,42,44,47,49,52,54,57,59,62,65,67,70,73,76,79,82,85,88,90,93,97,100,103,106,109,112,115,118,121,124,127,131,134,137,140,143,146,149,152,155,158,162,165,167,170,173,176,179,182,185,188,190,193,196,198,201,203,206,208,211,213,215,218,220,222,224,226,228,230,232,234,235,237,238,240,241,243,244,245,246,248,249,250,250,251,252,253,253,254,254,254,255,255,255,255,255,255,255,254,254,254,253,253,252,251,250,250,249,248,246,245,244,243,241,240,238,237,235,234,232,230,228,226,224,222,220,218,215,213,211,208,206,203,201,198,196,193,190,188,185,182,179,176,173,170,167,165,162,158,155,152,149,146,143,140,137,134,131,128,124,121,118,115,112,109,106,103,100,97,93,90,88,85,82,79,76,73,70,67,65,62,59,57,54,52,49,47,44,42,40,37,35,33,31,29,27,25,23,21,20,18,17,15,14,12,11,10,9,7,6,5,5,4,3,2,2,1,1,1,0,0,0};
const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5}; const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5};
const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[] PROGMEM = {120, 60, 30}; const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[] PROGMEM = {120, 60, 30};
const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[] PROGMEM = {100, 50, 20}; const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[] PROGMEM = {100, 50, 20};
@ -38,63 +55,56 @@ uint8_t rgblight_inited = 0;
void sethsv(uint16_t hue, uint8_t sat, uint8_t val, struct cRGB *led1) { void sethsv(uint16_t hue, uint8_t sat, uint8_t val, struct cRGB *led1) {
/* convert hue, saturation and brightness ( HSB/HSV ) to RGB // Convert hue, saturation, and value (HSV/HSB) to RGB. DIM_CURVE is used only
The DIM_CURVE is used only on brightness/value and on saturation (inverted). // on value and saturation (inverted). This looks the most natural.
This looks the most natural. uint8_t r = 0, g = 0, b = 0, base, color;
*/
uint8_t r = 0, g = 0, b = 0;
val = pgm_read_byte(&DIM_CURVE[val]); val = pgm_read_byte(&DIM_CURVE[val]);
sat = 255 - pgm_read_byte(&DIM_CURVE[255 - sat]); sat = 255 - pgm_read_byte(&DIM_CURVE[255 - sat]);
uint8_t base; if (sat == 0) { // Acromatic color (gray). Hue doesn't mind.
r = val;
g = val;
b = val;
} else {
base = ((255 - sat) * val) >> 8;
color = (val - base) * (hue % 60) / 60;
if (sat == 0) { // Acromatic color (gray). Hue doesn't mind. switch (hue / 60) {
r = val; case 0:
g = val; r = val;
b = val; g = base + color;
} else { b = base;
base = ((255 - sat) * val) >> 8; break;
case 1:
r = val - color;
g = val;
b = base;
break;
case 2:
r = base;
g = val;
b = base + color;
break;
case 3:
r = base;
g = val - color;
b = val;
break;
case 4:
r = base + color;
g = base;
b = val;
break;
case 5:
r = val;
g = base;
b = val - color;
break;
}
}
switch (hue / 60) { setrgb(r, g, b, led1);
case 0:
r = val;
g = (((val - base)*hue) / 60) + base;
b = base;
break;
case 1:
r = (((val - base)*(60 - (hue % 60))) / 60) + base;
g = val;
b = base;
break;
case 2:
r = base;
g = val;
b = (((val - base)*(hue % 60)) / 60) + base;
break;
case 3:
r = base;
g = (((val - base)*(60 - (hue % 60))) / 60) + base;
b = val;
break;
case 4:
r = (((val - base)*(hue % 60)) / 60) + base;
g = base;
b = val;
break;
case 5:
r = val;
g = base;
b = (((val - base)*(60 - (hue % 60))) / 60) + base;
break;
}
}
setrgb(r,g,b, led1);
} }
void setrgb(uint8_t r, uint8_t g, uint8_t b, struct cRGB *led1) { void setrgb(uint8_t r, uint8_t g, uint8_t b, struct cRGB *led1) {
@ -111,44 +121,44 @@ void eeconfig_update_rgblight(uint32_t val) {
eeprom_update_dword(EECONFIG_RGBLIGHT, val); eeprom_update_dword(EECONFIG_RGBLIGHT, val);
} }
void eeconfig_update_rgblight_default(void) { void eeconfig_update_rgblight_default(void) {
dprintf("eeconfig_update_rgblight_default\n"); dprintf("eeconfig_update_rgblight_default\n");
rgblight_config.enable = 1; rgblight_config.enable = 1;
rgblight_config.mode = 1; rgblight_config.mode = 1;
rgblight_config.hue = 200; rgblight_config.hue = 200;
rgblight_config.sat = 204; rgblight_config.sat = 204;
rgblight_config.val = 204; rgblight_config.val = 204;
eeconfig_update_rgblight(rgblight_config.raw); eeconfig_update_rgblight(rgblight_config.raw);
} }
void eeconfig_debug_rgblight(void) { void eeconfig_debug_rgblight(void) {
dprintf("rgblight_config eprom\n"); dprintf("rgblight_config eprom\n");
dprintf("rgblight_config.enable = %d\n", rgblight_config.enable); dprintf("rgblight_config.enable = %d\n", rgblight_config.enable);
dprintf("rghlight_config.mode = %d\n", rgblight_config.mode); dprintf("rghlight_config.mode = %d\n", rgblight_config.mode);
dprintf("rgblight_config.hue = %d\n", rgblight_config.hue); dprintf("rgblight_config.hue = %d\n", rgblight_config.hue);
dprintf("rgblight_config.sat = %d\n", rgblight_config.sat); dprintf("rgblight_config.sat = %d\n", rgblight_config.sat);
dprintf("rgblight_config.val = %d\n", rgblight_config.val); dprintf("rgblight_config.val = %d\n", rgblight_config.val);
} }
void rgblight_init(void) { void rgblight_init(void) {
debug_enable = 1; // Debug ON! debug_enable = 1; // Debug ON!
dprintf("rgblight_init called.\n"); dprintf("rgblight_init called.\n");
rgblight_inited = 1; rgblight_inited = 1;
dprintf("rgblight_init start!\n"); dprintf("rgblight_init start!\n");
if (!eeconfig_is_enabled()) { if (!eeconfig_is_enabled()) {
dprintf("rgblight_init eeconfig is not enabled.\n"); dprintf("rgblight_init eeconfig is not enabled.\n");
eeconfig_init(); eeconfig_init();
eeconfig_update_rgblight_default(); eeconfig_update_rgblight_default();
} }
rgblight_config.raw = eeconfig_read_rgblight(); rgblight_config.raw = eeconfig_read_rgblight();
if (!rgblight_config.mode) { if (!rgblight_config.mode) {
dprintf("rgblight_init rgblight_config.mode = 0. Write default values to EEPROM.\n"); dprintf("rgblight_init rgblight_config.mode = 0. Write default values to EEPROM.\n");
eeconfig_update_rgblight_default(); eeconfig_update_rgblight_default();
rgblight_config.raw = eeconfig_read_rgblight(); rgblight_config.raw = eeconfig_read_rgblight();
} }
eeconfig_debug_rgblight(); // display current eeprom values eeconfig_debug_rgblight(); // display current eeprom values
#if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER) #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
rgblight_timer_init(); // setup the timer rgblight_timer_init(); // setup the timer
#endif #endif
if (rgblight_config.enable) { if (rgblight_config.enable) {
rgblight_mode(rgblight_config.mode); rgblight_mode(rgblight_config.mode);
@ -156,58 +166,57 @@ void rgblight_init(void) {
} }
void rgblight_increase(void) { void rgblight_increase(void) {
uint8_t mode = 0; uint8_t mode = 0;
if (rgblight_config.mode < RGBLIGHT_MODES) { if (rgblight_config.mode < RGBLIGHT_MODES) {
mode = rgblight_config.mode + 1; mode = rgblight_config.mode + 1;
} }
rgblight_mode(mode); rgblight_mode(mode);
} }
void rgblight_decrease(void) { void rgblight_decrease(void) {
uint8_t mode = 0; uint8_t mode = 0;
if (rgblight_config.mode > 1) { //mode will never < 1, if mode is less than 1, eeprom need to be initialized. // Mode will never be < 1. If it ever is, eeprom needs to be initialized.
mode = rgblight_config.mode-1; if (rgblight_config.mode > 1) {
mode = rgblight_config.mode - 1;
} }
rgblight_mode(mode); rgblight_mode(mode);
} }
void rgblight_step(void) { void rgblight_step(void) {
uint8_t mode = 0; uint8_t mode = 0;
mode = rgblight_config.mode + 1; mode = rgblight_config.mode + 1;
if (mode > RGBLIGHT_MODES) { if (mode > RGBLIGHT_MODES) {
mode = 1; mode = 1;
} }
rgblight_mode(mode); rgblight_mode(mode);
} }
void rgblight_mode(uint8_t mode) { void rgblight_mode(uint8_t mode) {
if (!rgblight_config.enable) { if (!rgblight_config.enable) {
return; return;
} }
if (mode<1) { if (mode < 1) {
rgblight_config.mode = 1; rgblight_config.mode = 1;
} else if (mode > RGBLIGHT_MODES) { } else if (mode > RGBLIGHT_MODES) {
rgblight_config.mode = RGBLIGHT_MODES; rgblight_config.mode = RGBLIGHT_MODES;
} else { } else {
rgblight_config.mode = mode; rgblight_config.mode = mode;
} }
eeconfig_update_rgblight(rgblight_config.raw); eeconfig_update_rgblight(rgblight_config.raw);
xprintf("rgblight mode: %u\n", rgblight_config.mode); xprintf("rgblight mode: %u\n", rgblight_config.mode);
if (rgblight_config.mode == 1) { if (rgblight_config.mode == 1) {
#if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER) #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
rgblight_timer_disable(); rgblight_timer_disable();
#endif #endif
} else if (rgblight_config.mode >=2 && rgblight_config.mode <=23) { } else if (rgblight_config.mode >= 2 && rgblight_config.mode <= 23) {
// MODE 2-5, breathing // MODE 2-5, breathing
// MODE 6-8, rainbow mood // MODE 6-8, rainbow mood
// MODE 9-14, rainbow swirl // MODE 9-14, rainbow swirl
// MODE 15-20, snake // MODE 15-20, snake
// MODE 21-23, knight // MODE 21-23, knight
#if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER) #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
rgblight_timer_enable(); rgblight_timer_enable();
#endif #endif
} }
rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
} }
@ -215,306 +224,318 @@ void rgblight_toggle(void) {
rgblight_config.enable ^= 1; rgblight_config.enable ^= 1;
eeconfig_update_rgblight(rgblight_config.raw); eeconfig_update_rgblight(rgblight_config.raw);
xprintf("rgblight toggle: rgblight_config.enable = %u\n", rgblight_config.enable); xprintf("rgblight toggle: rgblight_config.enable = %u\n", rgblight_config.enable);
if (rgblight_config.enable) { if (rgblight_config.enable) {
rgblight_mode(rgblight_config.mode); rgblight_mode(rgblight_config.mode);
} else { } else {
#if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
#if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER) rgblight_timer_disable();
rgblight_timer_disable(); #endif
#endif _delay_ms(50);
_delay_ms(50); rgblight_set();
rgblight_set(); }
}
} }
void rgblight_increase_hue(void){ void rgblight_increase_hue(void) {
uint16_t hue; uint16_t hue;
hue = (rgblight_config.hue+RGBLIGHT_HUE_STEP) % 360; hue = (rgblight_config.hue+RGBLIGHT_HUE_STEP) % 360;
rgblight_sethsv(hue, rgblight_config.sat, rgblight_config.val); rgblight_sethsv(hue, rgblight_config.sat, rgblight_config.val);
} }
void rgblight_decrease_hue(void){ void rgblight_decrease_hue(void) {
uint16_t hue; uint16_t hue;
if (rgblight_config.hue-RGBLIGHT_HUE_STEP <0 ) { if (rgblight_config.hue-RGBLIGHT_HUE_STEP < 0) {
hue = (rgblight_config.hue+360-RGBLIGHT_HUE_STEP) % 360; hue = (rgblight_config.hue + 360 - RGBLIGHT_HUE_STEP) % 360;
} else { } else {
hue = (rgblight_config.hue-RGBLIGHT_HUE_STEP) % 360; hue = (rgblight_config.hue - RGBLIGHT_HUE_STEP) % 360;
} }
rgblight_sethsv(hue, rgblight_config.sat, rgblight_config.val); rgblight_sethsv(hue, rgblight_config.sat, rgblight_config.val);
} }
void rgblight_increase_sat(void) { void rgblight_increase_sat(void) {
uint8_t sat; uint8_t sat;
if (rgblight_config.sat + RGBLIGHT_SAT_STEP > 255) { if (rgblight_config.sat + RGBLIGHT_SAT_STEP > 255) {
sat = 255; sat = 255;
} else { } else {
sat = rgblight_config.sat+RGBLIGHT_SAT_STEP; sat = rgblight_config.sat + RGBLIGHT_SAT_STEP;
} }
rgblight_sethsv(rgblight_config.hue, sat, rgblight_config.val); rgblight_sethsv(rgblight_config.hue, sat, rgblight_config.val);
} }
void rgblight_decrease_sat(void){ void rgblight_decrease_sat(void) {
uint8_t sat; uint8_t sat;
if (rgblight_config.sat - RGBLIGHT_SAT_STEP < 0) { if (rgblight_config.sat - RGBLIGHT_SAT_STEP < 0) {
sat = 0; sat = 0;
} else { } else {
sat = rgblight_config.sat-RGBLIGHT_SAT_STEP; sat = rgblight_config.sat - RGBLIGHT_SAT_STEP;
} }
rgblight_sethsv(rgblight_config.hue, sat, rgblight_config.val); rgblight_sethsv(rgblight_config.hue, sat, rgblight_config.val);
} }
void rgblight_increase_val(void){ void rgblight_increase_val(void) {
uint8_t val; uint8_t val;
if (rgblight_config.val + RGBLIGHT_VAL_STEP > 255) { if (rgblight_config.val + RGBLIGHT_VAL_STEP > 255) {
val = 255; val = 255;
} else { } else {
val = rgblight_config.val+RGBLIGHT_VAL_STEP; val = rgblight_config.val + RGBLIGHT_VAL_STEP;
} }
rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, val); rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, val);
} }
void rgblight_decrease_val(void) { void rgblight_decrease_val(void) {
uint8_t val; uint8_t val;
if (rgblight_config.val - RGBLIGHT_VAL_STEP < 0) { if (rgblight_config.val - RGBLIGHT_VAL_STEP < 0) {
val = 0; val = 0;
} else { } else {
val = rgblight_config.val-RGBLIGHT_VAL_STEP; val = rgblight_config.val - RGBLIGHT_VAL_STEP;
} }
rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, val); rgblight_sethsv(rgblight_config.hue, rgblight_config.sat, val);
} }
void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val){ void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) {
inmem_config.raw = rgblight_config.raw; inmem_config.raw = rgblight_config.raw;
if (rgblight_config.enable) { if (rgblight_config.enable) {
struct cRGB tmp_led; struct cRGB tmp_led;
sethsv(hue, sat, val, &tmp_led); sethsv(hue, sat, val, &tmp_led);
inmem_config.hue = hue; inmem_config.hue = hue;
inmem_config.sat = sat; inmem_config.sat = sat;
inmem_config.val = val; inmem_config.val = val;
// dprintf("rgblight set hue [MEMORY]: %u,%u,%u\n", inmem_config.hue, inmem_config.sat, inmem_config.val); // dprintf("rgblight set hue [MEMORY]: %u,%u,%u\n", inmem_config.hue, inmem_config.sat, inmem_config.val);
rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b); rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b);
} }
} }
void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val){ void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val) {
if (rgblight_config.enable) { if (rgblight_config.enable) {
if (rgblight_config.mode == 1) { if (rgblight_config.mode == 1) {
// same static color // same static color
rgblight_sethsv_noeeprom(hue, sat, val); rgblight_sethsv_noeeprom(hue, sat, val);
} else { } else {
// all LEDs in same color // all LEDs in same color
if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) { if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) {
// breathing mode, ignore the change of val, use in memory value instead // breathing mode, ignore the change of val, use in memory value instead
val = rgblight_config.val; val = rgblight_config.val;
} else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 14) { } else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 14) {
// rainbow mood and rainbow swirl, ignore the change of hue // rainbow mood and rainbow swirl, ignore the change of hue
hue = rgblight_config.hue; hue = rgblight_config.hue;
} }
} }
rgblight_config.hue = hue; rgblight_config.hue = hue;
rgblight_config.sat = sat; rgblight_config.sat = sat;
rgblight_config.val = val; rgblight_config.val = val;
eeconfig_update_rgblight(rgblight_config.raw); eeconfig_update_rgblight(rgblight_config.raw);
xprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val); xprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
} }
} }
void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b){ void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) {
// dprintf("rgblight set rgb: %u,%u,%u\n", r,g,b); // dprintf("rgblight set rgb: %u,%u,%u\n", r,g,b);
for (uint8_t i=0;i<RGBLED_NUM;i++) { for (uint8_t i = 0; i < RGBLED_NUM; i++) {
led[i].r = r; led[i].r = r;
led[i].g = g; led[i].g = g;
led[i].b = b; led[i].b = b;
} }
rgblight_set(); rgblight_set();
} }
void rgblight_set(void) { void rgblight_set(void) {
if (rgblight_config.enable) { if (rgblight_config.enable) {
ws2812_setleds(led, RGBLED_NUM); ws2812_setleds(led, RGBLED_NUM);
} else { } else {
for (uint8_t i=0;i<RGBLED_NUM;i++) { for (uint8_t i = 0; i < RGBLED_NUM; i++) {
led[i].r = 0; led[i].r = 0;
led[i].g = 0; led[i].g = 0;
led[i].b = 0; led[i].b = 0;
} }
ws2812_setleds(led, RGBLED_NUM); ws2812_setleds(led, RGBLED_NUM);
} }
} }
#if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER) #if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
// Animation timer -- AVR Timer3 // Animation timer -- AVR Timer3
void rgblight_timer_init(void) { void rgblight_timer_init(void) {
static uint8_t rgblight_timer_is_init = 0; static uint8_t rgblight_timer_is_init = 0;
if (rgblight_timer_is_init) { if (rgblight_timer_is_init) {
return; return;
} }
rgblight_timer_is_init = 1; rgblight_timer_is_init = 1;
/* Timer 3 setup */ /* Timer 3 setup */
TCCR3B = _BV(WGM32) //CTC mode OCR3A as TOP TCCR3B = _BV(WGM32) //CTC mode OCR3A as TOP
| _BV(CS30); //Clock selelct: clk/1 | _BV(CS30); //Clock selelct: clk/1
/* Set TOP value */ /* Set TOP value */
uint8_t sreg = SREG; uint8_t sreg = SREG;
cli(); cli();
OCR3AH = (RGBLED_TIMER_TOP>>8)&0xff; OCR3AH = (RGBLED_TIMER_TOP >> 8) & 0xff;
OCR3AL = RGBLED_TIMER_TOP&0xff; OCR3AL = RGBLED_TIMER_TOP & 0xff;
SREG = sreg; SREG = sreg;
} }
void rgblight_timer_enable(void) { void rgblight_timer_enable(void) {
TIMSK3 |= _BV(OCIE3A); TIMSK3 |= _BV(OCIE3A);
dprintf("TIMER3 enabled.\n"); dprintf("TIMER3 enabled.\n");
} }
void rgblight_timer_disable(void) { void rgblight_timer_disable(void) {
TIMSK3 &= ~_BV(OCIE3A); TIMSK3 &= ~_BV(OCIE3A);
dprintf("TIMER3 disabled.\n"); dprintf("TIMER3 disabled.\n");
} }
void rgblight_timer_toggle(void) { void rgblight_timer_toggle(void) {
TIMSK3 ^= _BV(OCIE3A); TIMSK3 ^= _BV(OCIE3A);
dprintf("TIMER3 toggled.\n"); dprintf("TIMER3 toggled.\n");
} }
ISR(TIMER3_COMPA_vect) { ISR(TIMER3_COMPA_vect) {
// Mode = 1, static light, do nothing here // mode = 1, static light, do nothing here
if (rgblight_config.mode>=2 && rgblight_config.mode<=5) { if (rgblight_config.mode >= 2 && rgblight_config.mode <= 5) {
// mode = 2 to 5, breathing mode // mode = 2 to 5, breathing mode
rgblight_effect_breathing(rgblight_config.mode-2); rgblight_effect_breathing(rgblight_config.mode - 2);
} else if (rgblight_config.mode >= 6 && rgblight_config.mode <= 8) {
} else if (rgblight_config.mode>=6 && rgblight_config.mode<=8) { // mode = 6 to 8, rainbow mood mod
rgblight_effect_rainbow_mood(rgblight_config.mode-6); rgblight_effect_rainbow_mood(rgblight_config.mode - 6);
} else if (rgblight_config.mode>=9 && rgblight_config.mode<=14) { } else if (rgblight_config.mode >= 9 && rgblight_config.mode <= 14) {
rgblight_effect_rainbow_swirl(rgblight_config.mode-9); // mode = 9 to 14, rainbow swirl mode
} else if (rgblight_config.mode>=15 && rgblight_config.mode<=20) { rgblight_effect_rainbow_swirl(rgblight_config.mode - 9);
rgblight_effect_snake(rgblight_config.mode-15); } else if (rgblight_config.mode >= 15 && rgblight_config.mode <= 20) {
} else if (rgblight_config.mode>=21 && rgblight_config.mode<=23) { // mode = 15 to 20, snake mode
rgblight_effect_knight(rgblight_config.mode-21); rgblight_effect_snake(rgblight_config.mode - 15);
} } else if (rgblight_config.mode >= 21 && rgblight_config.mode <= 23) {
// mode = 21 to 23, knight mode
rgblight_effect_knight(rgblight_config.mode - 21);
}
} }
// effects // Effects
void rgblight_effect_breathing(uint8_t interval) { void rgblight_effect_breathing(uint8_t interval) {
static uint8_t pos = 0; static uint8_t pos = 0;
static uint16_t last_timer = 0; static uint16_t last_timer = 0;
if (timer_elapsed(last_timer)<pgm_read_byte(&RGBLED_BREATHING_INTERVALS[interval])) return; if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_BREATHING_INTERVALS[interval])) {
last_timer = timer_read(); return;
}
last_timer = timer_read();
rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, pgm_read_byte(&RGBLED_BREATHING_TABLE[pos])); rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, pgm_read_byte(&RGBLED_BREATHING_TABLE[pos]));
pos = (pos+1) % 256; pos = (pos + 1) % 256;
} }
void rgblight_effect_rainbow_mood(uint8_t interval) { void rgblight_effect_rainbow_mood(uint8_t interval) {
static uint16_t current_hue=0; static uint16_t current_hue = 0;
static uint16_t last_timer = 0; static uint16_t last_timer = 0;
if (timer_elapsed(last_timer)<pgm_read_byte(&RGBLED_RAINBOW_MOOD_INTERVALS[interval])) return; if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_RAINBOW_MOOD_INTERVALS[interval])) {
last_timer = timer_read(); return;
rgblight_sethsv_noeeprom(current_hue, rgblight_config.sat, rgblight_config.val); }
current_hue = (current_hue+1) % 360; last_timer = timer_read();
rgblight_sethsv_noeeprom(current_hue, rgblight_config.sat, rgblight_config.val);
current_hue = (current_hue + 1) % 360;
} }
void rgblight_effect_rainbow_swirl(uint8_t interval) { void rgblight_effect_rainbow_swirl(uint8_t interval) {
static uint16_t current_hue=0; static uint16_t current_hue = 0;
static uint16_t last_timer = 0; static uint16_t last_timer = 0;
uint16_t hue; uint16_t hue;
uint8_t i; uint8_t i;
if (timer_elapsed(last_timer)<pgm_read_byte(&RGBLED_RAINBOW_MOOD_INTERVALS[interval/2])) return; if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_RAINBOW_MOOD_INTERVALS[interval / 2])) {
last_timer = timer_read(); return;
for (i=0; i<RGBLED_NUM; i++) { }
hue = (360/RGBLED_NUM*i+current_hue)%360; last_timer = timer_read();
sethsv(hue, rgblight_config.sat, rgblight_config.val, &led[i]); for (i = 0; i < RGBLED_NUM; i++) {
} hue = (360 / RGBLED_NUM * i + current_hue) % 360;
rgblight_set(); sethsv(hue, rgblight_config.sat, rgblight_config.val, &led[i]);
}
rgblight_set();
if (interval % 2) { if (interval % 2) {
current_hue = (current_hue+1) % 360; current_hue = (current_hue + 1) % 360;
} else { } else {
if (current_hue -1 < 0) { if (current_hue - 1 < 0) {
current_hue = 359; current_hue = 359;
} else { } else {
current_hue = current_hue - 1; current_hue = current_hue - 1;
} }
}
}
} }
void rgblight_effect_snake(uint8_t interval) { void rgblight_effect_snake(uint8_t interval) {
static uint8_t pos=0; static uint8_t pos = 0;
static uint16_t last_timer = 0; static uint16_t last_timer = 0;
uint8_t i,j; uint8_t i, j;
int8_t k; int8_t k;
int8_t increament = 1; int8_t increment = 1;
if (interval%2) increament = -1; if (interval % 2) {
if (timer_elapsed(last_timer)<pgm_read_byte(&RGBLED_SNAKE_INTERVALS[interval/2])) return; increment = -1;
last_timer = timer_read(); }
for (i=0;i<RGBLED_NUM;i++) { if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_SNAKE_INTERVALS[interval / 2])) {
led[i].r=0; return;
led[i].g=0; }
led[i].b=0; last_timer = timer_read();
for (j=0;j<RGBLIGHT_EFFECT_SNAKE_LENGTH;j++) { for (i = 0; i < RGBLED_NUM; i++) {
k = pos+j*increament; led[i].r = 0;
if (k<0) k = k+RGBLED_NUM; led[i].g = 0;
if (i==k) { led[i].b = 0;
sethsv(rgblight_config.hue, rgblight_config.sat, (uint8_t)(rgblight_config.val*(RGBLIGHT_EFFECT_SNAKE_LENGTH-j)/RGBLIGHT_EFFECT_SNAKE_LENGTH), &led[i]); for (j = 0; j < RGBLIGHT_EFFECT_SNAKE_LENGTH; j++) {
} k = pos + j * increment;
} if (k < 0) {
} k = k + RGBLED_NUM;
rgblight_set(); }
if (increament == 1) { if (i == k) {
if (pos - 1 < 0) { sethsv(rgblight_config.hue, rgblight_config.sat, (uint8_t)(rgblight_config.val*(RGBLIGHT_EFFECT_SNAKE_LENGTH-j)/RGBLIGHT_EFFECT_SNAKE_LENGTH), &led[i]);
pos = RGBLED_NUM-1; }
} else { }
pos -= 1; }
} rgblight_set();
} else { if (increment == 1) {
pos = (pos+1)%RGBLED_NUM; if (pos - 1 < 0) {
} pos = RGBLED_NUM - 1;
} else {
pos -= 1;
}
} else {
pos = (pos + 1) % RGBLED_NUM;
}
} }
void rgblight_effect_knight(uint8_t interval) { void rgblight_effect_knight(uint8_t interval) {
static int8_t pos=0; static int8_t pos = 0;
static uint16_t last_timer = 0; static uint16_t last_timer = 0;
uint8_t i,j,cur; uint8_t i, j, cur;
int8_t k; int8_t k;
struct cRGB preled[RGBLED_NUM]; struct cRGB preled[RGBLED_NUM];
static int8_t increament = -1; static int8_t increment = -1;
if (timer_elapsed(last_timer)<pgm_read_byte(&RGBLED_KNIGHT_INTERVALS[interval])) return; if (timer_elapsed(last_timer) < pgm_read_byte(&RGBLED_KNIGHT_INTERVALS[interval])) {
last_timer = timer_read(); return;
for (i=0;i<RGBLED_NUM;i++) { }
preled[i].r=0; last_timer = timer_read();
preled[i].g=0; for (i = 0; i < RGBLED_NUM; i++) {
preled[i].b=0; preled[i].r = 0;
for (j=0;j<RGBLIGHT_EFFECT_KNIGHT_LENGTH;j++) { preled[i].g = 0;
k = pos+j*increament; preled[i].b = 0;
if (k<0) k = 0; for (j = 0; j < RGBLIGHT_EFFECT_KNIGHT_LENGTH; j++) {
if (k>=RGBLED_NUM) k=RGBLED_NUM-1; k = pos + j * increment;
if (i==k) { if (k < 0) {
sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, &preled[i]); k = 0;
} }
} if (k >= RGBLED_NUM) {
} k = RGBLED_NUM - 1;
if (RGBLIGHT_EFFECT_KNIGHT_OFFSET) { }
for (i=0;i<RGBLED_NUM;i++) { if (i == k) {
cur = (i+RGBLIGHT_EFFECT_KNIGHT_OFFSET) % RGBLED_NUM; sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, &preled[i]);
led[i].r = preled[cur].r; }
led[i].g = preled[cur].g; }
led[i].b = preled[cur].b; }
} if (RGBLIGHT_EFFECT_KNIGHT_OFFSET) {
} for (i = 0; i < RGBLED_NUM; i++) {
rgblight_set(); cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % RGBLED_NUM;
if (increament == 1) { led[i].r = preled[cur].r;
if (pos - 1 < 0 - RGBLIGHT_EFFECT_KNIGHT_LENGTH) { led[i].g = preled[cur].g;
pos = 0- RGBLIGHT_EFFECT_KNIGHT_LENGTH; led[i].b = preled[cur].b;
increament = -1; }
} else { }
pos -= 1; rgblight_set();
} if (increment == 1) {
} else { if (pos - 1 < 0 - RGBLIGHT_EFFECT_KNIGHT_LENGTH) {
if (pos+1>RGBLED_NUM+RGBLIGHT_EFFECT_KNIGHT_LENGTH) { pos = 0 - RGBLIGHT_EFFECT_KNIGHT_LENGTH;
pos = RGBLED_NUM+RGBLIGHT_EFFECT_KNIGHT_LENGTH-1; increment = -1;
increament = 1; } else {
} else { pos -= 1;
pos += 1; }
} } else {
} if (pos + 1 > RGBLED_NUM + RGBLIGHT_EFFECT_KNIGHT_LENGTH) {
pos = RGBLED_NUM + RGBLIGHT_EFFECT_KNIGHT_LENGTH - 1;
increment = 1;
} else {
pos += 1;
}
}
} }
#endif #endif