diff options
author | Florian Didron <fdidron@users.noreply.github.com> | 2019-12-06 09:25:39 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-06 09:25:39 +0900 |
commit | 13e1dd3d53a75840cce9c7fa52fd6d8d26a36a9a (patch) | |
tree | a51a6bd431d848279d8c03357ac05ecfb25312ce /quantum | |
parent | 1d600f09a8b813f77d8b6ff4cc55484b7154ae25 (diff) | |
parent | 038cef3054a816021a797c217d147057c8edd926 (diff) |
Merge pull request #222 from zsa/staging
Firmware 15
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/backlight/backlight.c | 193 | ||||
-rw-r--r-- | quantum/backlight/backlight.h | 58 | ||||
-rw-r--r-- | quantum/color.c | 10 | ||||
-rw-r--r-- | quantum/config_common.h | 21 | ||||
-rw-r--r-- | quantum/encoder.c | 42 | ||||
-rw-r--r-- | quantum/keymap_common.c | 5 | ||||
-rw-r--r-- | quantum/keymap_extras/keymap_italian.h | 55 | ||||
-rw-r--r-- | quantum/keymap_extras/keymap_italian_osx_ansi.h | 113 | ||||
-rw-r--r-- | quantum/keymap_extras/keymap_italian_osx_iso.h | 113 | ||||
-rw-r--r-- | quantum/led_tables.c | 44 | ||||
-rw-r--r-- | quantum/process_keycode/process_tap_dance.c | 2 | ||||
-rw-r--r-- | quantum/process_keycode/process_tap_dance.h | 10 | ||||
-rw-r--r-- | quantum/quantum.c | 86 | ||||
-rw-r--r-- | quantum/quantum_keycodes.h | 6 | ||||
-rw-r--r-- | quantum/rgb_matrix_drivers.c | 22 | ||||
-rw-r--r-- | quantum/rgblight.c | 3 | ||||
-rw-r--r-- | quantum/template/ps2avrgb/rules.mk | 6 | ||||
-rw-r--r-- | quantum/template/ps2avrgb/template.c | 44 |
18 files changed, 703 insertions, 130 deletions
diff --git a/quantum/backlight/backlight.c b/quantum/backlight/backlight.c new file mode 100644 index 0000000000..708022f68f --- /dev/null +++ b/quantum/backlight/backlight.c @@ -0,0 +1,193 @@ +/* +Copyright 2013 Mathias Andersson <wraul@dbox.se> + +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/>. +*/ + +#include "backlight.h" +#include "eeconfig.h" +#include "debug.h" + +backlight_config_t backlight_config; + +/** \brief Backlight initialization + * + * FIXME: needs doc + */ +void backlight_init(void) { + /* check signature */ + if (!eeconfig_is_enabled()) { + eeconfig_init(); + } + backlight_config.raw = eeconfig_read_backlight(); + if (backlight_config.level > BACKLIGHT_LEVELS) { + backlight_config.level = BACKLIGHT_LEVELS; + } + backlight_set(backlight_config.enable ? backlight_config.level : 0); +} + +/** \brief Backlight increase + * + * FIXME: needs doc + */ +void backlight_increase(void) { + if (backlight_config.level < BACKLIGHT_LEVELS) { + backlight_config.level++; + } + backlight_config.enable = 1; + eeconfig_update_backlight(backlight_config.raw); + dprintf("backlight increase: %u\n", backlight_config.level); + backlight_set(backlight_config.level); +} + +/** \brief Backlight decrease + * + * FIXME: needs doc + */ +void backlight_decrease(void) { + if (backlight_config.level > 0) { + backlight_config.level--; + backlight_config.enable = !!backlight_config.level; + eeconfig_update_backlight(backlight_config.raw); + } + dprintf("backlight decrease: %u\n", backlight_config.level); + backlight_set(backlight_config.level); +} + +/** \brief Backlight toggle + * + * FIXME: needs doc + */ +void backlight_toggle(void) { + bool enabled = backlight_config.enable; + dprintf("backlight toggle: %u\n", enabled); + if (enabled) + backlight_disable(); + else + backlight_enable(); +} + +/** \brief Enable backlight + * + * FIXME: needs doc + */ +void backlight_enable(void) { + if (backlight_config.enable) return; // do nothing if backlight is already on + + backlight_config.enable = true; + if (backlight_config.raw == 1) // enabled but level == 0 + backlight_config.level = 1; + eeconfig_update_backlight(backlight_config.raw); + dprintf("backlight enable\n"); + backlight_set(backlight_config.level); +} + +/** \brief Disable backlight + * + * FIXME: needs doc + */ +void backlight_disable(void) { + if (!backlight_config.enable) return; // do nothing if backlight is already off + + backlight_config.enable = false; + eeconfig_update_backlight(backlight_config.raw); + dprintf("backlight disable\n"); + backlight_set(0); +} + +/** /brief Get the backlight status + * + * FIXME: needs doc + */ +bool is_backlight_enabled(void) { return backlight_config.enable; } + +/** \brief Backlight step through levels + * + * FIXME: needs doc + */ +void backlight_step(void) { + backlight_config.level++; + if (backlight_config.level > BACKLIGHT_LEVELS) { + backlight_config.level = 0; + } + backlight_config.enable = !!backlight_config.level; + eeconfig_update_backlight(backlight_config.raw); + dprintf("backlight step: %u\n", backlight_config.level); + backlight_set(backlight_config.level); +} + +/** \brief Backlight set level + * + * FIXME: needs doc + */ +void backlight_level(uint8_t level) { + if (level > BACKLIGHT_LEVELS) level = BACKLIGHT_LEVELS; + backlight_config.level = level; + backlight_config.enable = !!backlight_config.level; + eeconfig_update_backlight(backlight_config.raw); + backlight_set(backlight_config.level); +} + +/** \brief Get backlight level + * + * FIXME: needs doc + */ +uint8_t get_backlight_level(void) { return backlight_config.level; } + +#ifdef BACKLIGHT_BREATHING +/** \brief Backlight breathing toggle + * + * FIXME: needs doc + */ +void backlight_toggle_breathing(void) { + bool breathing = backlight_config.breathing; + dprintf("backlight breathing toggle: %u\n", breathing); + if (breathing) + backlight_disable_breathing(); + else + backlight_enable_breathing(); +} + +/** \brief Enable backlight breathing + * + * FIXME: needs doc + */ +void backlight_enable_breathing(void) { + if (backlight_config.breathing) return; // do nothing if breathing is already on + + backlight_config.breathing = true; + eeconfig_update_backlight(backlight_config.raw); + dprintf("backlight breathing enable\n"); + breathing_enable(); +} + +/** \brief Disable backlight breathing + * + * FIXME: needs doc + */ +void backlight_disable_breathing(void) { + if (!backlight_config.breathing) return; // do nothing if breathing is already off + + backlight_config.breathing = false; + eeconfig_update_backlight(backlight_config.raw); + dprintf("backlight breathing disable\n"); + breathing_disable(); +} + +/** \brief Get the backlight breathing status + * + * FIXME: needs doc + */ +bool is_backlight_breathing(void) { return backlight_config.breathing; } +#endif diff --git a/quantum/backlight/backlight.h b/quantum/backlight/backlight.h new file mode 100644 index 0000000000..bb1f897ee8 --- /dev/null +++ b/quantum/backlight/backlight.h @@ -0,0 +1,58 @@ +/* +Copyright 2013 Mathias Andersson <wraul@dbox.se> + +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/>. +*/ + +#pragma once + +#include <stdint.h> +#include <stdbool.h> + +#ifndef BACKLIGHT_LEVELS +# define BACKLIGHT_LEVELS 3 +#elif BACKLIGHT_LEVELS > 31 +# error "Maximum value of BACKLIGHT_LEVELS is 31" +#endif + +typedef union { + uint8_t raw; + struct { + bool enable : 1; + bool breathing : 1; + uint8_t reserved : 1; // Reserved for possible future backlight modes + uint8_t level : 5; + }; +} backlight_config_t; + +void backlight_init(void); +void backlight_increase(void); +void backlight_decrease(void); +void backlight_toggle(void); +void backlight_enable(void); +void backlight_disable(void); +bool is_backlight_enabled(void); +void backlight_step(void); +void backlight_set(uint8_t level); +void backlight_level(uint8_t level); +uint8_t get_backlight_level(void); + +#ifdef BACKLIGHT_BREATHING +void backlight_toggle_breathing(void); +void backlight_enable_breathing(void); +void backlight_disable_breathing(void); +bool is_backlight_breathing(void); +void breathing_enable(void); +void breathing_disable(void); +#endif diff --git a/quantum/color.c b/quantum/color.c index 847129736d..1f398e2403 100644 --- a/quantum/color.c +++ b/quantum/color.c @@ -36,7 +36,11 @@ RGB hsv_to_rgb(HSV hsv) { h = hsv.h; s = hsv.s; +#ifdef USE_CIE1931_CURVE + v = pgm_read_byte(&CIE1931_CURVE[hsv.v]); +#else v = hsv.v; +#endif region = h * 6 / 255; remainder = (h * 2 - region * 85) * 3; @@ -79,11 +83,5 @@ RGB hsv_to_rgb(HSV hsv) { break; } -#ifdef USE_CIE1931_CURVE - rgb.r = pgm_read_byte(&CIE1931_CURVE[rgb.r]); - rgb.g = pgm_read_byte(&CIE1931_CURVE[rgb.g]); - rgb.b = pgm_read_byte(&CIE1931_CURVE[rgb.b]); -#endif - return rgb; } diff --git a/quantum/config_common.h b/quantum/config_common.h index fb9f1fd00a..f42df6357d 100644 --- a/quantum/config_common.h +++ b/quantum/config_common.h @@ -175,7 +175,7 @@ // LEDs (only D5/C13 uses an actual LED) # ifdef CONVERT_TO_PROTON_C_RXLED -# define D5 PAL_LINE(GPIOC, 13) +# define D5 PAL_LINE(GPIOC, 14) # define B0 PAL_LINE(GPIOC, 13) # else # define D5 PAL_LINE(GPIOC, 13) @@ -303,6 +303,25 @@ UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ sei(); \ } while (0) +# elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)) +# define SERIAL_UART_BAUD 115200 +# define SERIAL_UART_DATA UDR1 + /* UBRR should result in ~16 and set UCSR1A = _BV(U2X1) as per rn42 documentation. HC05 needs baudrate configured accordingly */ +# define SERIAL_UART_UBRR (F_CPU / (8UL * SERIAL_UART_BAUD) - 1) +# define SERIAL_UART_RXD_VECT USART1_RX_vect +# define SERIAL_UART_TXD_READY (UCSR1A & _BV(UDRE1)) +# define SERIAL_UART_INIT() do { \ + UCSR1A = _BV(U2X1); \ + /* baud rate */ \ + UBRR1L = SERIAL_UART_UBRR; \ + /* baud rate */ \ + UBRR1H = SERIAL_UART_UBRR >> 8; \ + /* enable TX */ \ + UCSR1B = _BV(TXEN1); \ + /* 8-bit data */ \ + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ + sei(); \ + } while(0) # else # error "USART configuration is needed." # endif diff --git a/quantum/encoder.c b/quantum/encoder.c index b3b1cd9f2b..36a6403b36 100644 --- a/quantum/encoder.c +++ b/quantum/encoder.c @@ -40,8 +40,10 @@ static int8_t encoder_LUT[] = {0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, static uint8_t encoder_state[NUMBER_OF_ENCODERS] = {0}; #ifdef SPLIT_KEYBOARD -// slave half encoders come over as second set of encoders +// right half encoders come over as second set of encoders static int8_t encoder_value[NUMBER_OF_ENCODERS * 2] = {0}; +// row offsets for each hand +static uint8_t thisHand, thatHand; #else static int8_t encoder_value[NUMBER_OF_ENCODERS] = {0}; #endif @@ -68,20 +70,33 @@ void encoder_init(void) { encoder_state[i] = (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1); } + +#ifdef SPLIT_KEYBOARD + thisHand = isLeftHand ? 0 : NUMBER_OF_ENCODERS; + thatHand = NUMBER_OF_ENCODERS - thisHand; +#endif +} + +static void encoder_update(int8_t index, uint8_t state) { + encoder_value[index] += encoder_LUT[state & 0xF]; + if (encoder_value[index] >= ENCODER_RESOLUTION) { + encoder_update_kb(index, false); + } + if (encoder_value[index] <= -ENCODER_RESOLUTION) { // direction is arbitrary here, but this clockwise + encoder_update_kb(index, true); + } + encoder_value[index] %= ENCODER_RESOLUTION; } void encoder_read(void) { for (int i = 0; i < NUMBER_OF_ENCODERS; i++) { encoder_state[i] <<= 2; encoder_state[i] |= (readPin(encoders_pad_a[i]) << 0) | (readPin(encoders_pad_b[i]) << 1); - encoder_value[i] += encoder_LUT[encoder_state[i] & 0xF]; - if (encoder_value[i] >= ENCODER_RESOLUTION) { - encoder_update_kb(i, false); - } - if (encoder_value[i] <= -ENCODER_RESOLUTION) { // direction is arbitrary here, but this clockwise - encoder_update_kb(i, true); - } - encoder_value[i] %= ENCODER_RESOLUTION; +#if SPLIT_KEYBOARD + encoder_update(i + thisHand, encoder_state[i]); +#else + encoder_update(i, encoder_state[i]); +#endif } } @@ -90,14 +105,7 @@ void encoder_state_raw(uint8_t* slave_state) { memcpy(slave_state, encoder_state void encoder_update_raw(uint8_t* slave_state) { for (int i = 0; i < NUMBER_OF_ENCODERS; i++) { - encoder_value[NUMBER_OF_ENCODERS + i] += encoder_LUT[slave_state[i] & 0xF]; - if (encoder_value[NUMBER_OF_ENCODERS + i] >= ENCODER_RESOLUTION) { - encoder_update_kb(NUMBER_OF_ENCODERS + i, false); - } - if (encoder_value[NUMBER_OF_ENCODERS + i] <= -ENCODER_RESOLUTION) { // direction is arbitrary here, but this clockwise - encoder_update_kb(NUMBER_OF_ENCODERS + i, true); - } - encoder_value[NUMBER_OF_ENCODERS + i] %= ENCODER_RESOLUTION; + encoder_update(i + thatHand, slave_state[i]); } } #endif diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 9af9510081..4fa45ac37b 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -26,9 +26,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "action.h" #include "action_macro.h" #include "debug.h" -#include "backlight.h" #include "quantum.h" +#ifdef BACKLIGHT_ENABLE +# include "backlight.h" +#endif + #ifdef MIDI_ENABLE # include "process_midi.h" #endif diff --git a/quantum/keymap_extras/keymap_italian.h b/quantum/keymap_extras/keymap_italian.h index 544ae94086..a8c03b884f 100644 --- a/quantum/keymap_extras/keymap_italian.h +++ b/quantum/keymap_extras/keymap_italian.h @@ -78,35 +78,36 @@ #define IT_MINS KC_SLSH // - and _ // shifted characters -#define IT_PIPE LSFT(IT_BKSL) // ° -#define IT_EXLM LSFT(KC_1) // ! -#define IT_DQOT LSFT(KC_2) // " -#define IT_STRL LSFT(KC_3) // £ -#define IT_DLR LSFT(KC_4) // $ -#define IT_PERC LSFT(KC_5) // % -#define IT_AMPR LSFT(KC_6) // & -#define IT_SLSH LSFT(KC_7) // / -#define IT_LPRN LSFT(KC_8) // ( -#define IT_RPRN LSFT(KC_9) // ) -#define IT_EQL LSFT(KC_0) // = -#define IT_QST LSFT(IT_APOS) // ? -#define IT_CRC LSFT(IT_IACC) // ^ -#define IT_ASTR LSFT(IT_PLUS) // * -#define IT_MORE LSFT(IT_LESS) // > -#define IT_COLN LSFT(IT_DOT) // : -#define IT_SCLN LSFT(IT_COMM) // ; -#define IT_UNDS LSFT(IT_MINS) // _ +#define IT_DEGR LSFT(IT_AACC) // ° +#define IT_EXLM LSFT(KC_1) // ! +#define IT_DQOT LSFT(KC_2) // " +#define IT_STRL LSFT(KC_3) // £ +#define IT_DLR LSFT(KC_4) // $ +#define IT_PERC LSFT(KC_5) // % +#define IT_AMPR LSFT(KC_6) // & +#define IT_SLSH LSFT(KC_7) // / +#define IT_LPRN LSFT(KC_8) // ( +#define IT_RPRN LSFT(KC_9) // ) +#define IT_EQL LSFT(KC_0) // = +#define IT_QST LSFT(IT_APOS) // ? +#define IT_CRC LSFT(IT_IACC) // ^ +#define IT_ASTR LSFT(IT_PLUS) // * +#define IT_MORE LSFT(IT_LESS) // > +#define IT_COLN LSFT(IT_DOT) // : +#define IT_SCLN LSFT(IT_COMM) // ; +#define IT_UNDS LSFT(IT_MINS) // _ // Alt Gr-ed characters -#define IT_LCBR ALGR(KC_7) // { -#define IT_LBRC ALGR(IT_EACC) // [ -#define IT_RBRC ALGR(IT_PLUS) // ] -#define IT_RCBR ALGR(KC_0) // } -#define IT_AT ALGR(IT_OACC) // @ -#define IT_EURO ALGR(KC_E) // € -#define IT_PIPE LSFT(IT_BKSL) // | -#define IT_SHRP ALGR(IT_AACC) // # +#define IT_LCBR ALGR(KC_7) // { +#define IT_LBRC ALGR(IT_EACC) // [ +#define IT_RBRC ALGR(IT_PLUS) // ] +#define IT_RCBR ALGR(KC_0) // } +#define IT_AT ALGR(IT_OACC) // @ +#define IT_EURO ALGR(KC_E) // € +#define IT_PIPE LSFT(IT_BSLS) // | +#define IT_SHRP ALGR(IT_AACC) // # -#define IT_X_PLUS X_RBRACKET // # +// Deprecated +#define IT_X_PLUS X_RBRACKET // # #endif diff --git a/quantum/keymap_extras/keymap_italian_osx_ansi.h b/quantum/keymap_extras/keymap_italian_osx_ansi.h new file mode 100644 index 0000000000..2b7160ff33 --- /dev/null +++ b/quantum/keymap_extras/keymap_italian_osx_ansi.h @@ -0,0 +1,113 @@ +/* Copyright 2015-2016 Matthias Schmidtt + * + * 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/>. + */ + +// This is a clone of quantum/keymap_extra/keymap_italian.h intended to be used with Apple devices + +#ifndef KEYMAP_ITALIAN +#define KEYMAP_ITALIAN + +#include "keymap.h" + +// normal characters +#define IT_A KC_A +#define IT_B KC_B +#define IT_C KC_C +#define IT_D KC_D +#define IT_E KC_E +#define IT_F KC_F +#define IT_G KC_G +#define IT_H KC_H +#define IT_I KC_I +#define IT_J KC_J +#define IT_K KC_K +#define IT_L KC_L +#define IT_M KC_M +#define IT_N KC_N +#define IT_O KC_O +#define IT_P KC_P +#define IT_Q KC_Q +#define IT_R KC_R +#define IT_S KC_S +#define IT_T KC_T +#define IT_U KC_U +#define IT_V KC_V +#define IT_W KC_W +#define IT_X KC_X +#define IT_Y KC_Y +#define IT_Z KC_Z + +#define IT_0 KC_0 +#define IT_1 KC_1 +#define IT_2 KC_2 +#define IT_3 KC_3 +#define IT_4 KC_4 +#define IT_5 KC_5 +#define IT_6 KC_6 +#define IT_7 KC_7 +#define IT_8 KC_8 +#define IT_9 KC_9 + +// punctuation +#define IT_DOT KC_DOT // . and : +#define IT_COMM KC_COMM // , and ; +#define IT_APOS KC_MINS // ' and ? +#define IT_BSLS KC_NUBS // \ and | +#define IT_LESS KC_GRV // < and > +#define IT_MINS KC_SLSH // - and _ + +// accented vowels (regular, with shift, with option, with option and shift) +#define IT_EACC KC_LBRC // è, é, [, { +#define IT_PLUS KC_RBRC // +, *, ], } +#define IT_OACC KC_SCLN // ò, ç, @, Ç +#define IT_AACC KC_QUOT // à, °, #, ∞ +#define IT_UACC KC_BSLS // ù, §, ¶, ◊ +#define IT_IACC KC_EQL // ì, ^, ˆ, ± + +// shifted characters +#define IT_EXLM LSFT(KC_1) // ! +#define IT_DQOT LSFT(KC_2) // " +#define IT_STRL LSFT(KC_3) // £ +#define IT_DLR LSFT(KC_4) // $ +#define IT_PERC LSFT(KC_5) // % +#define IT_AMPR LSFT(KC_6) // & +#define IT_SLSH LSFT(KC_7) // / +#define IT_LPRN LSFT(KC_8) // ( +#define IT_RPRN LSFT(KC_9) // ) +#define IT_EQL LSFT(KC_0) // = +#define IT_DEGR LSFT(IT_AACC) // ° +#define IT_QST LSFT(IT_APOS) // ? +#define IT_CRC LSFT(IT_IACC) // ^ +#define IT_ASTR LSFT(IT_PLUS) // * +#define IT_MORE LSFT(IT_LESS) // > +#define IT_COLN LSFT(IT_DOT) // : +#define IT_SCLN LSFT(IT_COMM) // ; +#define IT_UNDS LSFT(IT_MINS) // _ +#define IT_LCBR LSFT(IT_LBRC) // { +#define IT_RCBR LSFT(IT_RBRC) // } +#define IT_PIPE LSFT(IT_BSLS) // | + +// Alt -ed characters +#define IT_LBRC LALT(IT_EACC) // [ +#define IT_RBRC LALT(IT_PLUS) // ] +#define IT_AT LALT(IT_OACC) // @ +#define IT_EURO LALT(KC_E) // € +#define IT_SHRP LALT(IT_AACC ) // # +#define IT_ACUT LALT(KC_8) // ´ +#define IT_GRAVE LALT(KC_9) // ` +#define IT_TILDE LALT(KC_5) // ~ +#define IT_PLMN LALT(LSFT(IT_IACC)) // ± + +#endif diff --git a/quantum/keymap_extras/keymap_italian_osx_iso.h b/quantum/keymap_extras/keymap_italian_osx_iso.h new file mode 100644 index 0000000000..5c920014a1 --- /dev/null +++ b/quantum/keymap_extras/keymap_italian_osx_iso.h @@ -0,0 +1,113 @@ +/* Copyright 2015-2016 Matthias Schmidtt + * + * 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/>. + */ + +// This is a clone of quantum/keymap_extra/keymap_italian.h intended to be used with Apple devices + +#ifndef KEYMAP_ITALIAN +#define KEYMAP_ITALIAN + +#include "keymap.h" + +// normal characters +#define IT_A KC_A +#define IT_B KC_B +#define IT_C KC_C +#define IT_D KC_D +#define IT_E KC_E +#define IT_F KC_F +#define IT_G KC_G +#define IT_H KC_H +#define IT_I KC_I +#define IT_J KC_J +#define IT_K KC_K +#define IT_L KC_L +#define IT_M KC_M +#define IT_N KC_N +#define IT_O KC_O +#define IT_P KC_P +#define IT_Q KC_Q +#define IT_R KC_R +#define IT_S KC_S +#define IT_T KC_T +#define IT_U KC_U +#define IT_V KC_V +#define IT_W KC_W +#define IT_X KC_X +#define IT_Y KC_Y +#define IT_Z KC_Z + +#define IT_0 KC_0 +#define IT_1 KC_1 +#define IT_2 KC_2 +#define IT_3 KC_3 +#define IT_4 KC_4 +#define IT_5 KC_5 +#define IT_6 KC_6 +#define IT_7 KC_7 +#define IT_8 KC_8 +#define IT_9 KC_9 + +// punctuation +#define IT_DOT KC_DOT // . and : +#define IT_COMM KC_COMM // , and ; +#define IT_APOS KC_MINS // ' and ? +#define IT_BSLS KC_GRV // \ and | +#define IT_LESS KC_NUBS// < and > +#define IT_MINS KC_SLSH // - and _ + +// accented vowels (regular, with shift, with option, with option and shift) +#define IT_EACC KC_LBRC // è, é, [, { +#define IT_PLUS KC_RBRC // +, *, ], } +#define IT_OACC KC_SCLN // ò, ç, @, Ç +#define IT_AACC KC_QUOT // à, °, #, ∞ +#define IT_UACC KC_BSLS // ù, §, ¶, ◊ +#define IT_IACC KC_EQL // ì, ^, ˆ, ± + +// shifted characters +#define IT_EXLM LSFT(KC_1) // ! +#define IT_DQOT LSFT(KC_2) // " +#define IT_STRL LSFT(KC_3) // £ +#define IT_DLR LSFT(KC_4) // $ +#define IT_PERC LSFT(KC_5) // % +#define IT_AMPR LSFT(KC_6) // & +#define IT_SLSH LSFT(KC_7) // / +#define IT_LPRN LSFT(KC_8) // ( +#define IT_RPRN LSFT(KC_9) // ) +#define IT_EQL LSFT(KC_0) // = +#define IT_DEGR LSFT(IT_AACC) // ° +#define IT_QST LSFT(IT_APOS) // ? +#define IT_CRC LSFT(IT_IACC) // ^ +#define IT_ASTR LSFT(IT_PLUS) // * +#define IT_MORE LSFT(IT_LESS) // > +#define IT_COLN LSFT(IT_DOT) // : +#define IT_SCLN LSFT(IT_COMM) // ; +#define IT_UNDS LSFT(IT_MINS) // _ +#define IT_LCBR LSFT(IT_LBRC) // { +#define IT_RCBR LSFT(IT_RBRC) // } +#define IT_PIPE LSFT(IT_BSLS) // | + +// Alt -ed characters +#define IT_LBRC LALT(IT_EACC) // [ +#define IT_RBRC LALT(IT_PLUS) // ] +#define IT_AT LALT(IT_OACC) // @ +#define IT_EURO LALT(KC_E) // € +#define IT_SHRP LALT(IT_AACC ) // # +#define IT_ACUT LALT(KC_8) // ´ +#define IT_GRAVE LALT(KC_9) // ` +#define IT_TILDE LALT(KC_5) // ~ +#define IT_PLMN LALT(LSFT(IT_IACC)) // ± + +#endif diff --git a/quantum/led_tables.c b/quantum/led_tables.c index 8cbf6f4c02..6eb2c09dc8 100644 --- a/quantum/led_tables.c +++ b/quantum/led_tables.c @@ -15,14 +15,50 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "led_tables.h" +// clang-format off + #ifdef USE_CIE1931_CURVE // Lightness curve using the CIE 1931 lightness formula // Generated by the python script provided in http://jared.geek.nz/2013/feb/linear-led-pwm -const uint8_t CIE1931_CURVE[256] PROGMEM = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 28, 28, 29, 29, 30, 31, 31, 32, 33, 33, 34, 35, 35, 36, 37, 37, 38, 39, 40, 40, 41, 42, 43, 44, 44, 45, 46, - 47, 48, 49, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 87, 88, 89, 90, 92, 93, 94, 96, 97, 99, 100, 101, 103, 104, 106, 107, 108, 110, 111, 113, 114, 116, 118, 119, 121, 122, 124, 125, 127, 129, 130, 132, 134, 135, 137, 139, 141, 142, 144, 146, 148, 149, 151, 153, 155, 157, 159, 161, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 185, 187, 189, 191, 193, 195, 197, 200, 202, 204, 206, 208, 211, 213, 215, 218, 220, 222, 225, 227, 230, 232, 234, 237, 239, 242, 244, 247, 249, 252, 255}; +const uint8_t CIE1931_CURVE[256] PROGMEM = { + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, + 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, + 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, + 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 17, 17, 17, + 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, + 26, 26, 27, 27, 28, 29, 29, 30, 30, 31, 32, 32, 33, 34, 34, 35, + 36, 36, 37, 38, 38, 39, 40, 41, 41, 42, 43, 44, 45, 45, 46, 47, + 48, 49, 50, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 76, 77, 78, 79, + 80, 81, 83, 84, 85, 86, 88, 89, 90, 91, 93, 94, 95, 97, 98, 100, + 101, 102, 104, 105, 107, 108, 109, 111, 112, 114, 115, 117, 119, 120, 122, 123, + 125, 126, 128, 130, 131, 133, 135, 136, 138, 140, 142, 143, 145, 147, 149, 150, + 152, 154, 156, 158, 160, 162, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181, + 183, 186, 188, 190, 192, 194, 196, 198, 201, 203, 205, 207, 209, 212, 214, 216, + 219, 221, 223, 226, 228, 231, 233, 235, 238, 240, 243, 245, 248, 250, 253, 255 +}; #endif #ifdef USE_LED_BREATHING_TABLE -const uint8_t LED_BREATHING_TABLE[256] 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 LED_BREATHING_TABLE[256] 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 +}; #endif + +// clang-format on diff --git a/quantum/process_keycode/process_tap_dance.c b/quantum/process_keycode/process_tap_dance.c index c27fe48347..16756e59c2 100644 --- a/quantum/process_keycode/process_tap_dance.c +++ b/quantum/process_keycode/process_tap_dance.c @@ -71,7 +71,7 @@ void qk_tap_dance_dual_role_finished(qk_tap_dance_state_t *state, void *user_dat if (state->count == 1) { register_code16(pair->kc); } else if (state->count == 2) { - layer_move(pair->layer); + pair->layer_function(pair->layer); } } diff --git a/quantum/process_keycode/process_tap_dance.h b/quantum/process_keycode/process_tap_dance.h index b2d0cb8297..8d227dfd70 100644 --- a/quantum/process_keycode/process_tap_dance.h +++ b/quantum/process_keycode/process_tap_dance.h @@ -56,13 +56,19 @@ typedef struct { typedef struct { uint16_t kc; uint8_t layer; + void (*layer_function)(uint8_t); } qk_tap_dance_dual_role_t; # define ACTION_TAP_DANCE_DOUBLE(kc1, kc2) \ { .fn = {qk_tap_dance_pair_on_each_tap, qk_tap_dance_pair_finished, qk_tap_dance_pair_reset}, .user_data = (void *)&((qk_tap_dance_pair_t){kc1, kc2}), } # define ACTION_TAP_DANCE_DUAL_ROLE(kc, layer) \ - { .fn = {qk_tap_dance_dual_role_on_each_tap, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset}, .user_data = (void *)&((qk_tap_dance_dual_role_t){kc, layer}), } + { .fn = { qk_tap_dance_dual_role_on_each_tap, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset }, .user_data = (void *)&((qk_tap_dance_dual_role_t) { kc, layer, layer_move }), } + +# define ACTION_TAP_DANCE_TOGGLE_LAYER(kc, layer) \ + { .fn = { NULL, qk_tap_dance_dual_role_finished, qk_tap_dance_dual_role_reset }, .user_data = (void *)&((qk_tap_dance_dual_role_t) { kc, layer, layer_invert }), } + +# define ACTION_TAP_DANCE_LAYER_MOVE(kc, layer) ACTION_TAP_DANCE_DUAL_ROLE(kc, layer) # define ACTION_TAP_DANCE_FN(user_fn) \ { .fn = {NULL, user_fn, NULL}, .user_data = NULL, } @@ -73,6 +79,8 @@ typedef struct { # define ACTION_TAP_DANCE_FN_ADVANCED_TIME(user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset, tap_specific_tapping_term) \ { .fn = {user_fn_on_each_tap, user_fn_on_dance_finished, user_fn_on_dance_reset}, .user_data = NULL, .custom_tapping_term = tap_specific_tapping_term, } + + extern qk_tap_dance_action_t tap_dance_actions[]; /* To be used internally */ diff --git a/quantum/quantum.c b/quantum/quantum.c index 90df0293b7..82c7a5265b 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -28,8 +28,10 @@ # define BREATHING_PERIOD 6 #endif -#include "backlight.h" -extern backlight_config_t backlight_config; +#ifdef BACKLIGHT_ENABLE +# include "backlight.h" + extern backlight_config_t backlight_config; +#endif #ifdef FAUXCLICKY_ENABLE # include "fauxclicky.h" @@ -55,6 +57,10 @@ extern backlight_config_t backlight_config; # include "encoder.h" #endif +#ifdef WEBUSB_ENABLE +# include "webusb.h" +#endif + #ifdef AUDIO_ENABLE # ifndef GOODBYE_SONG # define GOODBYE_SONG SONG(GOODBYE_SOUND) @@ -89,44 +95,28 @@ static void do_code16(uint16_t code, void (*f)(uint8_t)) { return; } - if (code & QK_LCTL) f(KC_LCTL); - if (code & QK_LSFT) f(KC_LSFT); - if (code & QK_LALT) f(KC_LALT); - if (code & QK_LGUI) f(KC_LGUI); - - if (code < QK_RMODS_MIN) return; - - if (code & QK_RCTL) f(KC_RCTL); - if (code & QK_RSFT) f(KC_RSFT); - if (code & QK_RALT) f(KC_RALT); - if (code & QK_RGUI) f(KC_RGUI); -} - -static inline void qk_register_weak_mods(uint8_t kc) { - add_weak_mods(MOD_BIT(kc)); - send_keyboard_report(); -} - -static inline void qk_unregister_weak_mods(uint8_t kc) { - del_weak_mods(MOD_BIT(kc)); - send_keyboard_report(); -} + uint8_t mods_to_send = 0; -static inline void qk_register_mods(uint8_t kc) { - add_weak_mods(MOD_BIT(kc)); - send_keyboard_report(); -} + if (code & QK_RMODS_MIN) { // Right mod flag is set + if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_RCTL); + if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RSFT); + if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RALT); + if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_RGUI); + } else { + if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_LCTL); + if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_LSFT); + if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_LALT); + if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_LGUI); + } -static inline void qk_unregister_mods(uint8_t kc) { - del_weak_mods(MOD_BIT(kc)); - send_keyboard_report(); + f(mods_to_send); } void register_code16(uint16_t code) { if (IS_MOD(code) || code == KC_NO) { - do_code16(code, qk_register_mods); + do_code16(code, register_mods); } else { - do_code16(code, qk_register_weak_mods); + do_code16(code, register_weak_mods); } register_code(code); } @@ -134,9 +124,9 @@ void register_code16(uint16_t code) { void unregister_code16(uint16_t code) { unregister_code(code); if (IS_MOD(code) || code == KC_NO) { - do_code16(code, qk_unregister_mods); + do_code16(code, unregister_mods); } else { - do_code16(code, qk_unregister_weak_mods); + do_code16(code, unregister_weak_mods); } } @@ -581,6 +571,7 @@ bool process_record_quantum(keyrecord_t *record) { keymap_config.swap_backslash_backspace = true; break; case MAGIC_HOST_NKRO: + clear_keyboard(); // clear first buffer to prevent stuck keys keymap_config.nkro = true; break; case MAGIC_SWAP_ALT_GUI: @@ -623,6 +614,7 @@ bool process_record_quantum(keyrecord_t *record) { keymap_config.swap_backslash_backspace = false; break; case MAGIC_UNHOST_NKRO: + clear_keyboard(); // clear first buffer to prevent stuck keys keymap_config.nkro = false; break; case MAGIC_UNSWAP_ALT_GUI: @@ -660,6 +652,7 @@ bool process_record_quantum(keyrecord_t *record) { #endif break; case MAGIC_TOGGLE_NKRO: + clear_keyboard(); // clear first buffer to prevent stuck keys keymap_config.nkro = !keymap_config.nkro; break; default: @@ -724,6 +717,13 @@ bool process_record_quantum(keyrecord_t *record) { return false; } #endif +#ifdef WEBUSB_ENABLE + case WEBUSB_PAIR: + if (record->event.pressed) { + webusb_state.pairing = true; + } + return false; +#endif } return process_action_kb(record); @@ -1104,6 +1104,22 @@ void matrix_scan_quantum() { # define COMxx1 COM1A1 # define OCRxx OCR1A # endif +# elif defined(__AVR_ATmega328P__) && (BACKLIGHT_PIN == B1 || BACKLIGHT_PIN == B2) +# define HARDWARE_PWM +# define ICRx ICR1 +# define TCCRxA TCCR1A +# define TCCRxB TCCR1B +# define TIMERx_OVF_vect TIMER1_OVF_vect +# define TIMSKx TIMSK1 +# define TOIEx TOIE1 + +# if BACKLIGHT_PIN == B1 +# define COMxx1 COM1A1 +# define OCRxx OCR1A +# elif BACKLIGHT_PIN == B2 +# define COMxx1 COM1B1 +# define OCRxx OCR1B +# endif # else # if !defined(BACKLIGHT_CUSTOM_DRIVER) # if !defined(B5_AUDIO) && !defined(B6_AUDIO) && !defined(B7_AUDIO) diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index f5dca02e6b..872aa89bc4 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -473,6 +473,9 @@ enum quantum_keycodes { HPT_BUZ, HPT_MODI, HPT_MODD, + HPT_CONT, + HPT_CONI, + HPT_COND, HPT_DWLI, HPT_DWLD, @@ -500,6 +503,9 @@ enum quantum_keycodes { MAGIC_UNSWAP_CTL_GUI, MAGIC_TOGGLE_CTL_GUI, +#ifdef WEBUSB_ENABLE + WEBUSB_PAIR, +#endif // always leave at the end SAFE_RANGE }; diff --git a/quantum/rgb_matrix_drivers.c b/quantum/rgb_matrix_drivers.c index 5b54bd5956..503f97014f 100644 --- a/quantum/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix_drivers.c @@ -97,19 +97,33 @@ const rgb_matrix_driver_t rgb_matrix_driver = { #elif defined(WS2812) -extern LED_TYPE led[DRIVER_LED_TOTAL]; +// LED color buffer +LED_TYPE led[DRIVER_LED_TOTAL]; + +static void init(void) {} static void flush(void) { // Assumes use of RGB_DI_PIN ws2812_setleds(led, DRIVER_LED_TOTAL); } -static void init(void) {} +// Set an led in the buffer to a color +static inline void setled(int i, uint8_t r, uint8_t g, uint8_t b) { + led[i].r = r; + led[i].g = g; + led[i].b = b; +} + +static void setled_all(uint8_t r, uint8_t g, uint8_t b) { + for (int i = 0; i < sizeof(led) / sizeof(led[0]); i++) { + setled(i, r, g, b); + } +} const rgb_matrix_driver_t rgb_matrix_driver = { .init = init, .flush = flush, - .set_color = ws2812_setled, - .set_color_all = ws2812_setled_all, + .set_color = setled, + .set_color_all = setled_all, }; #endif diff --git a/quantum/rgblight.c b/quantum/rgblight.c index a094863fe9..1c197827f2 100644 --- a/quantum/rgblight.c +++ b/quantum/rgblight.c @@ -910,6 +910,9 @@ void rgblight_effect_snake(animation_status_t *anim) { ledp->b = 0; for (j = 0; j < RGBLIGHT_EFFECT_SNAKE_LENGTH; j++) { k = pos + j * increment; + if (k > RGBLED_NUM) { + k = k % RGBLED_NUM; + } if (k < 0) { k = k + effect_num_leds; } diff --git a/quantum/template/ps2avrgb/rules.mk b/quantum/template/ps2avrgb/rules.mk index 69554cd308..52d9988125 100644 --- a/quantum/template/ps2avrgb/rules.mk +++ b/quantum/template/ps2avrgb/rules.mk @@ -14,9 +14,7 @@ EXTRAKEY_ENABLE = yes CONSOLE_ENABLE = yes COMMAND_ENABLE = yes BACKLIGHT_ENABLE = no -RGBLIGHT_ENABLE = no -RGBLIGHT_CUSTOM_DRIVER = yes +RGBLIGHT_ENABLE = yes +WS2812_DRIVER = i2c OPT_DEFS = -DDEBUG_LEVEL=0 - -SRC += i2c_master.c diff --git a/quantum/template/ps2avrgb/template.c b/quantum/template/ps2avrgb/template.c index acc8698f56..503da7ca71 100644 --- a/quantum/template/ps2avrgb/template.c +++ b/quantum/template/ps2avrgb/template.c @@ -15,44 +15,30 @@ */ #include "%KEYBOARD%.h" -#ifdef RGBLIGHT_ENABLE -# include <string.h> -# include "i2c_master.h" -# include "rgblight.h" +// Optional override functions below. +// You can leave any or all of these undefined. +// These are only required if you want to perform custom actions. -extern rgblight_config_t rgblight_config; +/* void matrix_init_kb(void) { - i2c_init(); - // call user level keymaps, if any - matrix_init_user(); -} - -// custom RGB driver -void rgblight_set(void) { - if (!rgblight_config.enable) { - memset(led, 0, 3 * RGBLED_NUM); - } + // put your keyboard start-up code here + // runs once when the firmware starts up - i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100); + matrix_init_user(); } -bool rgb_init = false; - void matrix_scan_kb(void) { - // if LEDs were previously on before poweroff, turn them back on - if (rgb_init == false && rgblight_config.enable) { - i2c_transmit(0xb0, (uint8_t*)led, 3 * RGBLED_NUM, 100); - rgb_init = true; - } - - rgblight_task(); - matrix_scan_user(); + // put your looping keyboard code here + // runs every cycle (a lot) + + matrix_scan_user(); } -#endif +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 -__attribute__ ((weak)) -void matrix_scan_user(void) { + return process_record_user(keycode, record); } |