From 00dd672fc80b802eb405d443b1d8f24416f0c943 Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Fri, 17 Jul 2015 15:33:58 +0900 Subject: [PATCH] redscarfII: Add support for RedScarfII+ --- keyboard/RedScarfII/Makefile | 20 +-- keyboard/RedScarfII/backlight.c | 28 ++-- keyboard/RedScarfII/config.h | 16 ++ keyboard/RedScarfII/keymap_common.h | 22 +-- keyboard/RedScarfII/keymap_default.c | 218 ++++++++++++++++++++++++--- keyboard/RedScarfII/led.c | 2 + keyboard/RedScarfII/ledmap.c | 28 +++- keyboard/RedScarfII/matrix.c | 8 + keyboard/RedScarfII/rgb.c | 181 ++++++++++++++++++++++ keyboard/RedScarfII/rgb.h | 82 ++++++++++ keyboard/RedScarfII/suspend.c | 35 +++++ keyboard/RedScarfII/yc059.c | 110 ++++++++++++++ keyboard/RedScarfII/yc059.h | 73 +++++++++ 13 files changed, 760 insertions(+), 63 deletions(-) create mode 100644 keyboard/RedScarfII/rgb.c create mode 100644 keyboard/RedScarfII/rgb.h create mode 100644 keyboard/RedScarfII/suspend.c create mode 100644 keyboard/RedScarfII/yc059.c create mode 100644 keyboard/RedScarfII/yc059.h diff --git a/keyboard/RedScarfII/Makefile b/keyboard/RedScarfII/Makefile index 2ad34c63..b6973d61 100644 --- a/keyboard/RedScarfII/Makefile +++ b/keyboard/RedScarfII/Makefile @@ -42,7 +42,7 @@ TARGET = RedScarfII_lufa # Directory common source filess exist -TOP_DIR = ../.. +TMK_DIR = ../../tmk_core_custom # Directory keyboard dependent files exist TARGET_DIR = . @@ -52,7 +52,10 @@ SRC = keymap_common.c \ matrix.c \ led.c \ backlight.c \ - ledmap.c + ledmap.c \ + yc059.c \ + rgb.c \ + suspend.c ifdef KEYMAP SRC := keymap_$(KEYMAP).c $(SRC) @@ -102,7 +105,7 @@ ARCH = AVR8 F_USB = $(F_CPU) # Interrupt driven control endpoint task(+60) -OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT +OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT -DREDSCARFII_PLUS # Boot Section Size in *bytes* @@ -122,7 +125,7 @@ endif # comment out to disable the options. # BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +#MOUSEKEY_ENABLE = yes # Mouse keys(+4700) EXTRAKEY_ENABLE = yes # Audio control and System control(+450) CONSOLE_ENABLE = yes # Console for debug(+400) COMMAND_ENABLE = yes # Commands for debug and configuration @@ -146,9 +149,8 @@ LEDMAP_IN_EEPROM_ENABLE = yes # Read LED mapping from eeprom # Search Path VPATH += $(TARGET_DIR) -VPATH += $(TOP_DIR) +VPATH += $(TMK_DIR) -include $(TOP_DIR)/protocol/lufa.mk -include $(TOP_DIR)/protocol.mk -include $(TOP_DIR)/common.mk -include $(TOP_DIR)/rules.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/keyboard/RedScarfII/backlight.c b/keyboard/RedScarfII/backlight.c index cbacce36..b10c2a0d 100644 --- a/keyboard/RedScarfII/backlight.c +++ b/keyboard/RedScarfII/backlight.c @@ -36,7 +36,7 @@ inline void backlight_set_raw(uint8_t raw); #ifdef SOFTPWM_LED_ENABLE #ifdef FADING_LED_ENABLE -static uint8_t backlight_mode; +extern backlight_config_t backlight_config; #endif #endif @@ -66,10 +66,6 @@ void backlight_disable(void) void backlight_set(uint8_t level) { -#ifdef FADING_LED_ENABLE - backlight_mode = level; -#endif - #ifdef BREATHING_LED_ENABLE switch (level) { case 1: @@ -187,14 +183,20 @@ void softpwm_led_off(uint8_t index) #ifdef FADING_LED_ENABLE void action_keyevent(keyevent_t event) { - if (backlight_mode == 7) { - if (event.pressed) { - softpwm_led_decrease_all(32); - } - } - if (backlight_mode == 8) { - if (event.pressed) { - softpwm_led_increase_all(32); + if (backlight_config.enable) { + switch (backlight_config.level) { + case 7: + if (event.pressed) { + fading_led_set_delay_all(64); + softpwm_led_decrease_all(32); + } + break;; + case 8: + if (event.pressed) { + fading_led_set_delay_all(64); + softpwm_led_increase_all(32); + } + break; } } } diff --git a/keyboard/RedScarfII/config.h b/keyboard/RedScarfII/config.h index bcc7b19c..72bdb360 100644 --- a/keyboard/RedScarfII/config.h +++ b/keyboard/RedScarfII/config.h @@ -22,10 +22,17 @@ along with this program. If not, see . /* USB Device descriptor parameter */ #define VENDOR_ID 0x5253 #define PRODUCT_ID 0x0002 +#ifdef REDSCARFII_PLUS +#define DEVICE_VER 0x0002 +#define MANUFACTURER Young Pioneers +#define PRODUCT Red Scarf II+ +#define DESCRIPTION t.m.k. keyboard firmware for Red Scarf II+ +#else #define DEVICE_VER 0x0001 #define MANUFACTURER Young Pioneers #define PRODUCT Red Scarf II #define DESCRIPTION t.m.k. keyboard firmware for Red Scarf II +#endif /* key matrix size */ #define MATRIX_ROWS 6 @@ -51,8 +58,15 @@ along with this program. If not, see . #else #define BACKLIGHT_LEVELS 3 #endif +#define BACKLIGHT_CUSTOM +/* number of leds */ +#ifdef REDSCARFII_PLUS +#define LED_COUNT 3 +#else #define LED_COUNT 4 +#endif +#define EECONFIG_LEDMAP_IN_EEPROM 8 /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ #define LOCKING_SUPPORT_ENABLE @@ -65,6 +79,8 @@ along with this program. If not, see . keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ ) +#define SUSPEND_ACTION + /* * Feature disable options * These options are also useful to firmware size reduction. diff --git a/keyboard/RedScarfII/keymap_common.h b/keyboard/RedScarfII/keymap_common.h index d3bef5bd..d2a7fd5b 100644 --- a/keyboard/RedScarfII/keymap_common.h +++ b/keyboard/RedScarfII/keymap_common.h @@ -39,18 +39,18 @@ extern const uint16_t fn_actions[]; * K3B and K2M are extra keys for ISO */ #define KEYMAP( \ - K5A, K5F, K0A, K0B, K0C, K0D, K0E, K0F, K0G, K0H, K0I, K0J, K0K, K0L, K0M, K0N, K0P, K0Q, K0R, K0S, \ - K5B, K5G, K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1M, K1N, K1P, K1Q, K1R, K1S, \ - K5C, K5H, K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2M, K2N, K2P, K2Q, K2R, K2S, \ - K5D, K5I, K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3P, K3Q, K3R, K3S, \ - K5E, K5J, K4A, K4B, K4C, K4J, K4K, K4L, K4M, K4N, K4P, K4Q, K4R, K4S \ + K5B, K5C, K0A, K0B, K0C, K0D, K0E, K0F, K0G, K0H, K0I, K0J, K0K, K0L, K0M, K0N, K0P, K0Q, K0R, K0S, \ + K5D, K5E, K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1M, K1N, K1P, K1Q, K1R, K1S, \ + K5F, K5G, K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2M, K2N, K2P, K2Q, K2R, K2S, \ + K5H, K5I, K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3P, K3Q, K3R, K3S, \ + K5J, K5K, K4A, K4B, K4C, K4J, K4K, K4L, K4H, K4M, K4N, K4P, K4Q, K4R, K4S \ ) { \ { KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F, KC_##K0G, KC_##K0H, KC_##K0I, KC_##K0J, KC_##K0K, KC_##K0L, KC_##K0M, KC_##K0N, KC_##K0P, KC_##K0Q, KC_##K0R, KC_##K0S }, \ { KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F, KC_##K1G, KC_##K1H, KC_##K1I, KC_##K1J, KC_##K1K, KC_##K1L, KC_##K1M, KC_##K1N, KC_##K1P, KC_##K1Q, KC_##K1R, KC_##K1S }, \ { KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F, KC_##K2G, KC_##K2H, KC_##K2I, KC_##K2J, KC_##K2K, KC_##K2L, KC_##K2M, KC_##K2N, KC_##K2P, KC_##K2Q, KC_##K2R, KC_##K2S }, \ { KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F, KC_##K3G, KC_##K3H, KC_##K3I, KC_##K3J, KC_##K3K, KC_##K3L, KC_##K3M, KC_##K3N, KC_##K3P, KC_##K3Q, KC_##K3R, KC_##K3S }, \ - { KC_##K4A, KC_##K4B, KC_##K4C, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K4J, KC_##K4K, KC_##K4L, KC_##K4M, KC_##K4N, KC_##K4P, KC_##K4Q, KC_##K4R, KC_##K4S }, \ - { KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F, KC_##K5G, KC_##K5H, KC_##K5I, KC_##K5J, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO } \ + { KC_##K4A, KC_##K4B, KC_##K4C, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K4H, KC_NO, KC_##K4J, KC_##K4K, KC_##K4L, KC_##K4M, KC_##K4N, KC_##K4P, KC_##K4Q, KC_##K4R, KC_##K4S }, \ + { KC_NO, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F, KC_##K5G, KC_##K5H, KC_##K5I, KC_##K5J, KC_##K5K, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO } \ } /* No extra F1-F10 keys */ @@ -59,13 +59,13 @@ extern const uint16_t fn_actions[]; K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1M, K1N, K1P, K1Q, K1R, K1S, \ K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2M, K2N, K2P, K2Q, K2R, K2S, \ K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3P, K3Q, K3R, K3S, \ - K4A, K4B, K4C, K4J, K4K, K4L, K4M, K4N, K4P, K4Q, K4R, K4S \ + K4A, K4B, K4C, K4J, K4K, K4L, K4H, K4M, K4N, K4P, K4Q, K4R, K4S \ ) KEYMAP( \ NO, NO, K0A, K0B, K0C, K0D, K0E, K0F, K0G, K0H, K0I, K0J, K0K, K0L, K0M, K0N, K0P, K0Q, K0R, K0S, \ NO, NO, K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1M, K1N, K1P, K1Q, K1R, K1S, \ NO, NO, K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2M, K2N, K2P, K2Q, K2R, K2S, \ NO, NO, K3A, K3B, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3P, K3Q, K3R, K3S, \ - NO, NO, K4A, K4B, K4C, K4J, K4K, K4L, K4M, K4N, K4P, K4Q, K4R, K4S \ + NO, NO, K4A, K4B, K4C, K4J, K4K, K4L, K4H, K4M, K4N, K4P, K4Q, K4R, K4S \ ) /* ANSI valiant. No extra keys for ISO */ @@ -74,13 +74,13 @@ extern const uint16_t fn_actions[]; K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1M, K1N, K1P, K1Q, K1R, \ K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, K2N, K2P, K2Q, K2R, K2S, \ K3A, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3P, K3Q, K3R, \ - K4A, K4B, K4C, K4I, K4K, K4L, K4M, K4N, K4P, K4Q, K4R, K4S \ + K4A, K4B, K4C, K4I, K4K, K4L, K4H, K4M, K4N, K4P, K4Q, K4R, K4S \ ) KEYMAP_NORMAL( \ K0A, K0B, K0C, K0D, K0E, K0F, K0G, K0H, K0I, K0J, K0K, K0L, K0M, K0N, K0P, K0Q, K0R, K0S, \ K1A, K1B, K1C, K1D, K1E, K1F, K1G, K1H, K1I, K1J, K1K, K1L, K1M, K1N, K1P, K1Q, K1R, NO, \ K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, K2J, K2K, K2L, NO, K2N, K2P, K2Q, K2R, K2S, \ K3A, NO, K3C, K3D, K3E, K3F, K3G, K3H, K3I, K3J, K3K, K3L, K3M, K3N, K3P, K3Q, K3R, NO, \ - K4A, K4B, K4C, K4I, K4K, K4L, K4M, K4N, K4P, K4Q, K4R, K4S \ + K4A, K4B, K4C, K4I, K4K, K4L, K4H, K4M, K4N, K4P, K4Q, K4R, K4S \ ) #endif diff --git a/keyboard/RedScarfII/keymap_default.c b/keyboard/RedScarfII/keymap_default.c index e0a030ff..549b08a4 100644 --- a/keyboard/RedScarfII/keymap_default.c +++ b/keyboard/RedScarfII/keymap_default.c @@ -1,4 +1,5 @@ #include "keymap_common.h" +#include "rgb.h" // Default #ifdef KEYMAP_SECTION_ENABLE @@ -6,7 +7,7 @@ const uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((s #else const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { #endif - /* Keymap 0: Default Layer + /* Keymap 0: ModelF/77 - OEM 1.25-1.25-1.25-6.25-1.25-1.25-1.25-1.25 * ,-----------------------------------------------------------------------------------. * | F1| F6|Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |Num| /| *| -| * |---+---+-----------------------------------------------------------+---+---+---+---| @@ -16,34 +17,129 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { * |---+---+-----------------------------------------------------------+---+---+---+---| * | F4| F9|Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn0| 1| 2| 3| | * |---+---+-----------------------------------------------------------+---+---+---|Ent| - * | F5|F10|Ctrl|Gui |Alt | Space |Alt |Gui |Fn0 |Ctrl| 0| 0| .| | + * | F5|F10|Ctrl|Gui |Alt | Space |Alt |Fn0 |Gui |Ctrl| 0| 0| .| | * `-----------------------------------------------------------------------------------' */ KEYMAP( - F1, F6, ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC,NLCK,PSLS,PAST,PMNS, \ - F2, F7, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS,P7, P8, P9, PPLS, \ - F3, F8, CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,GRV, ENT, P4, P5, P6, PPLS, \ - F4, F9, LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,FN0, P1, P2, P3, PENT, \ - F5, F10, LCTL,LGUI,LALT, SPC, RALT,FN0, RGUI,RCTL,P0, P0, PDOT,PENT ), - /* Keymap 1: Fn Layer + F1, F2, ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC,NLCK,PSLS,PAST,PMNS, \ + F3, F4, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS,P7, P8, P9, PPLS, \ + F5, F6, CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,GRV, ENT, P4, P5, P6, PPLS, \ + F7, F8, LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,FN0, P1, P2, P3, PENT, \ + F9, F10, LCTL,LGUI,LALT, SPC, RALT,FN0, RGUI,RGUI,RCTL,P0, P0, PDOT,PENT ), + /* Keymap 1: ModelF/77 - Winkeyless 1.5-1-1.5-7-1.5-1-1.5 * ,-----------------------------------------------------------------------------------. - * | | | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | | | | | + * | F1| F6|Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |Num| /| *| -| * |---+---+-----------------------------------------------------------+---+---+---+---| - * | | | | |Up | | | |Cal| |Ins| |Psc|Slk|Pau| | | | | | - * |---+---+-----------------------------------------------------------|---+---+---| | - * | | | |Lef|Dow|Rig| | | | | | |Hom|PgU| | | | | | - * |---+---+-----------------------------------------------------------|---+---+---+---| - * | | | | |App|Fn1|Fn2|Fn3|VoD|VoU|Mut|End|PgD| | | | | | | - * |---+---+-----------------------------------------------------------+---+---+---| | - * | | | | | | Fn4 | | | | | | | | | + * | F2| F7|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| 7| 8| 9| | + * |---+---+-----------------------------------------------------------+---+---+---| +| + * | F3| F8|Caps | A| S| D| F| G| H| J| K| L| ;| '|Return | 4| 5| 6| | + * |---+---+-----------------------------------------------------------+---+---+---+---| + * | F4| F9|Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn0| 1| 2| 3| | + * |---+---+-----------------------------------------------------------+---+---+---|Ent| + * | F5|F10|Ctrl |Gui|Alt | Space |Alt |Fn0|Ctrl | 0| 0| .| | * `-----------------------------------------------------------------------------------' */ KEYMAP( - TRNS,TRNS,GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, TRNS,TRNS,TRNS,TRNS, \ - TRNS,TRNS,TRNS,TRNS,UP, TRNS,TRNS,TRNS,CALC,TRNS,INS, TRNS,PSCR,SLCK,PAUS,TRNS,TRNS,TRNS,TRNS,TRNS, \ - TRNS,TRNS,TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,HOME,PGUP,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ - TRNS,TRNS,TRNS,TRNS,TRNS,APP, FN1, FN2, FN3, VOLD,VOLU,MUTE,END, PGDN,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ - TRNS,TRNS,TRNS,TRNS,TRNS, FN4, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS ), + F1, F2, ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC,NLCK,PSLS,PAST,PMNS, \ + F3, F4, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS,P7, P8, P9, PPLS, \ + F5, F6, CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,GRV, ENT, P4, P5, P6, PPLS, \ + F7, F8, LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,FN0, P1, P2, P3, PENT, \ + F9, F10, LCTL,LGUI,LALT, SPC, RALT,RALT,RGUI,FN0, RCTL,P0, P0, PDOT,PENT ), + /* Keymap 2: ModelF/77 - OEM + Arrow Keys 1.25-1.25-1.25-6.25-1-1-1-1-1 + * ,-----------------------------------------------------------------------------------. + * | F1| F6|Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |Num| /| *| -| + * |---+---+-----------------------------------------------------------+---+---+---+---| + * | F2| F7|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| 7| 8| 9| | + * |---+---+-----------------------------------------------------------+---+---+---| +| + * | F3| F8|Caps | A| S| D| F| G| H| J| K| L| ;| '|Return | 4| 5| 6| | + * |---+---+-----------------------------------------------------------+---+---+---+---| + * | F4| F9|Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | Up| 1| 2| 3| | + * |---+---+-----------------------------------------------------------+---+---+---|Ent| + * | F5|F10|Ctrl|Gui |Alt | Space |Alt|Fn0|Ctr|Lef|Dow|Rig| 0| .| | + * `-----------------------------------------------------------------------------------' + */ + KEYMAP( + F1, F2, ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC,NLCK,PSLS,PAST,PMNS, \ + F3, F4, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS,P7, P8, P9, PPLS, \ + F5, F6, CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,GRV, ENT, P4, P5, P6, PPLS, \ + F7, F8, LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,UP, P1, P2, P3, PENT, \ + F9, F10, LCTL,LGUI,LALT, SPC, RALT,FN0, RCTL,LEFT,DOWN,RGHT,P0, PDOT,PENT ), + /* Keymap 3: ModelF/77 - 18xx 1.5-1.5-7-1.5-1.5-1-1 + * ,-----------------------------------------------------------------------------------. + * | F1| F6|Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |Num| /| *| -| + * |---+---+-----------------------------------------------------------+---+---+---+---| + * | F2| F7|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| 7| 8| 9| | + * |---+---+-----------------------------------------------------------+---+---+---| +| + * | F3| F8|Caps | A| S| D| F| G| H| J| K| L| ;| '|Return | 4| 5| 6| | + * |---+---+-----------------------------------------------------------+---+---+---+---| + * | F4| F9|Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | Up| 1| 2| 3| | + * |---+---+-----------------------------------------------------------+---+---+---|Ent| + * | F5|F10|Ctrl |Alt | Space |Alt |Ctrl |Lef|Dow|Rig| 0| .| | + * `-----------------------------------------------------------------------------------' + */ + KEYMAP( + F1, F2, ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC,NLCK,PSLS,PAST,FN0, \ + F3, F4, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS,P7, P8, P9, PMNS, \ + F5, F6, CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,GRV, ENT, P4, P5, P6, PPLS, \ + F7, F8, LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,UP, P1, P2, P3, PENT, \ + F9, F10, LCTL,LGUI,LALT, SPC, RALT,FN0, RCTL,LEFT,DOWN,RGHT,P0, PDOT,PENT ), + /* Keymap 4: Mini/68 - OEM 1.25-1.25-1.25-6.25-1-1-1 + * ,-----------------------------------------------------------------------. + * | F1| F6|Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |Hom| + * |---+---+-----------------------------------------------------------+---| + * | F2| F7|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \|PgU| + * |---+---+-----------------------------------------------------------+---| + * | F3| F8|Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |PgD| + * |---+---+-----------------------------------------------------------+---| + * | F4| F9|Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | Up|End| + * |---+---+-----------------------------------------------------------+---| + * | F5|F10|Ctrl|Gui |Alt | Space |Alt|Fn0|Ctr|Lef|Dow|Rig| + * `-----------------------------------------------------------------------' + */ + KEYMAP( + F1, F2, ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC,HOME,PSLS,PAST,FN0, \ + F3, F4, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS,PGUP,P8, P9, PMNS, \ + F5, F6, CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,GRV, ENT, PGDN,P5, P6, PPLS, \ + F7, F8, LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,UP, END, P2, P3, PENT, \ + F9, F10, LCTL,LGUI,LALT, SPC, RALT,FN0, RCTL,LEFT,DOWN,RGHT,P0, PDOT,PENT ), + /* Keymap 5: Mini/68 - 18xx 1.5-1.5-7-1.5-1.5 + * ,-----------------------------------------------------------------------. + * | F1| F6|Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | `| + * |---+---+-----------------------------------------------------------+---| + * | F2| F7|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \|PgU| + * |---+---+-----------------------------------------------------------+---| + * | F3| F8|Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |PgD| + * |---+---+-----------------------------------------------------------+---| + * | F4| F9|Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | Up|Fn0| + * |---+---+-----------------------------------------------------------+---| + * | F5|F10|Ctrl |Alt | Space |Alt |Ctrl |Lef|Dow|Rig| + * `-----------------------------------------------------------------------' + */ + KEYMAP( + F1, F2, ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC,GRV, PSLS,PAST,FN0, \ + F3, F4, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS,PGUP,P8, P9, PMNS, \ + F5, F6, CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,GRV, ENT, PGDN,P5, P6, PPLS, \ + F7, F8, LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,UP, FN0, P2, P3, PENT, \ + F9, F10, LCTL,LGUI,LALT, SPC, RALT,FN0, RCTL,LEFT,DOWN,RGHT,P0, PDOT,PENT ), + /* Keymap 6: Fn Layer + * ,-----------------------------------------------------------------------------------. + * |n17|n24| `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete |n10|n11|n12|n13| + * |---+---+-----------------------------------------------------------+---+---+---+---| + * |n10|n22| | |Up |Fn5|Fn6|Fn7|Cal| |Ins| |Psc|Slk|Pau| |n14|n15|n16| | + * |---+---+-----------------------------------------------------------|---+---+---|n17| + * |n14|n16| |Lef|Dow|Rig|Fn8|Fn9| | | | |Hom|PgU| |n18|n19|n20| | + * |---+---+-----------------------------------------------------------|---+---+---+---| + * |n25|n27| | |App|Fn1|Fn2|Fn3|VoD|VoU|Mut|End|PgD| | |n22|n23|n24| | + * |---+---+-----------------------------------------------------------+---+---+---|n25| + * |n15|n13| | | | | | | | |n26|n27|n28| | + * `-----------------------------------------------------------------------------------' + */ + KEYMAP( + FN10,FN14,GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, FN10,FN11,FN12,FN13, \ + FN26,FN15,TRNS,TRNS,UP, FN5, FN6, FN7, CALC,TRNS,INS, TRNS,PSCR,SLCK,PAUS,TRNS,FN14,FN15,FN16,FN17, \ + FN23,FN16,TRNS,LEFT,DOWN,RGHT,FN8, FN9, TRNS,TRNS,TRNS,TRNS,HOME,PGUP,TRNS,TRNS,FN18,FN19,FN20,FN21, \ + FN28,FN13,TRNS,TRNS,TRNS,APP, FN1, FN2, FN3, VOLD,VOLU,MUTE,END, PGDN,TRNS,TRNS,FN22,FN23,FN24,FN25, \ + FN17,FN25,TRNS,TRNS,TRNS, FN4, TRNS,TRNS,TRNS,TRNS,TRNS,FN26,FN27,FN28,FN29 ), /* Keymap 2: Arrow key Overlayer * ,-----------------------------------------------------------------------------------. * | | | | | | | | | | | | | | | | | | | | | @@ -57,12 +153,28 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { * | | | | | | | | | | |Lef|Dow|Rig| | * `-----------------------------------------------------------------------------------' */ + /* KEYMAP( TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,UP, TRNS,TRNS, \ - TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,LEFT,DOWN,RGHT,TRNS ), + TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,LEFT,DOWN,RGHT,TRNS ), + */ +}; + +/* + * Action function definition + */ +enum function_id { + AF_RGB_ON = 0, + AF_RGB_OFF, + AF_RGB_TOGGLE, + AF_RGB_INCREASE, + AF_RGB_DECREASE, + AF_RGB_FIXED, + AF_RGB_VARIABLE, + AF_RGB_STEP }; /* @@ -73,12 +185,36 @@ const uint16_t fn_actions[FN_ACTIONS_COUNT] __attribute__ ((section (".keymap.fn #else const uint16_t fn_actions[] PROGMEM = { #endif - /* Poker2 Layout */ - [0] = ACTION_LAYER_MOMENTARY(1), + [0] = ACTION_LAYER_MOMENTARY(6), [1] = ACTION_BACKLIGHT_DECREASE(), [2] = ACTION_BACKLIGHT_TOGGLE(), [3] = ACTION_BACKLIGHT_INCREASE(), - [4] = ACTION_LAYER_TOGGLE(2) + [5] = ACTION_FUNCTION(AF_RGB_TOGGLE), + /*[4] = ACTION_LAYER_TOGGLE(2),*/ + [6] = ACTION_FUNCTION_OPT(AF_RGB_STEP, RGB_FIXED), + [7] = ACTION_FUNCTION_OPT(AF_RGB_STEP, RGB_VARIABLE), + [8] = ACTION_FUNCTION(AF_RGB_DECREASE), + [9] = ACTION_FUNCTION(AF_RGB_INCREASE), + [10] = ACTION_FUNCTION_OPT(AF_RGB_FIXED, RGB_FIXED_RED), + [11] = ACTION_FUNCTION_OPT(AF_RGB_FIXED, RGB_FIXED_GREEN), + [12] = ACTION_FUNCTION_OPT(AF_RGB_FIXED, RGB_FIXED_BLUE), + [13] = ACTION_FUNCTION_OPT(AF_RGB_FIXED, RGB_FIXED_WHITE), + [14] = ACTION_FUNCTION_OPT(AF_RGB_FIXED, RGB_FIXED_RED_1), + [15] = ACTION_FUNCTION_OPT(AF_RGB_FIXED, RGB_FIXED_GREEN_1), + [16] = ACTION_FUNCTION_OPT(AF_RGB_FIXED, RGB_FIXED_BLUE_1), + [17] = ACTION_FUNCTION_OPT(AF_RGB_VARIABLE, RGB_VARIABLE_FLASH), + [18] = ACTION_FUNCTION_OPT(AF_RGB_FIXED, RGB_FIXED_RED_2), + [19] = ACTION_FUNCTION_OPT(AF_RGB_FIXED, RGB_FIXED_GREEN_2), + [20] = ACTION_FUNCTION_OPT(AF_RGB_FIXED, RGB_FIXED_BLUE_2), + [21] = ACTION_FUNCTION_OPT(AF_RGB_VARIABLE, RGB_VARIABLE_STROBE), + [22] = ACTION_FUNCTION_OPT(AF_RGB_FIXED, RGB_FIXED_RED_3), + [23] = ACTION_FUNCTION_OPT(AF_RGB_FIXED, RGB_FIXED_GREEN_3), + [24] = ACTION_FUNCTION_OPT(AF_RGB_FIXED, RGB_FIXED_BLUE_3), + [25] = ACTION_FUNCTION_OPT(AF_RGB_VARIABLE, RGB_VARIABLE_FADE), + [26] = ACTION_FUNCTION_OPT(AF_RGB_FIXED, RGB_FIXED_RED_4), + [27] = ACTION_FUNCTION_OPT(AF_RGB_FIXED, RGB_FIXED_GREEN_4), + [28] = ACTION_FUNCTION_OPT(AF_RGB_FIXED, RGB_FIXED_BLUE_4), + [29] = ACTION_FUNCTION_OPT(AF_RGB_VARIABLE, RGB_VARIABLE_SMOOTH), }; #ifdef KEYMAP_IN_EEPROM_ENABLE @@ -91,6 +227,38 @@ uint16_t fn_actions_count(void) { } #endif +void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + if (record->event.pressed) { + switch (id) { + case AF_RGB_ON: + rgb_on(); + break; + case AF_RGB_OFF: + rgb_off(); + break; + case AF_RGB_TOGGLE: + rgb_toggle(); + break; + case AF_RGB_INCREASE: + rgb_increase(); + break; + case AF_RGB_DECREASE: + rgb_decrease(); + break; + case AF_RGB_FIXED: + rgb_set(RGB_FIXED, opt); + break; + case AF_RGB_VARIABLE: + rgb_set(RGB_VARIABLE, opt); + break; + case AF_RGB_STEP: + rgb_step(opt); + break; + } + } +} + /* * Action macro definition */ diff --git a/keyboard/RedScarfII/led.c b/keyboard/RedScarfII/led.c index 4d4439e9..83c9c392 100644 --- a/keyboard/RedScarfII/led.c +++ b/keyboard/RedScarfII/led.c @@ -47,6 +47,7 @@ void led_set(uint8_t usb_led) DDRE &= ~(1<. #ifdef LEDMAP_ENABLE static const uint16_t ledmaps[LED_COUNT] PROGMEM = { - [0] = LEDMAP_CAPS_LOCK, // CapsLock - [1] = LEDMAP_NUM_LOCK, // NumLock - [2] = LEDMAP_SCROLL_LOCK, // Logo - [3] = LEDMAP_BACKLIGHT, // Backlight + [0] = LEDMAP_CAPS_LOCK | LEDMAP_BACKLIGHT, // CapsLock + [1] = LEDMAP_NUM_LOCK | LEDMAP_BACKLIGHT, // NumLock +#ifdef REDSCARFII_PLUS + [2] = LEDMAP_BACKLIGHT, // Backlight +#else + [2] = LEDMAP_SCROLL_LOCK | LEDMAP_BACKLIGHT, // Logo + [3] = LEDMAP_BACKLIGHT, // Backlight +#endif }; ledmap_t ledmap_get_code(uint8_t index) @@ -44,8 +48,10 @@ void ledmap_led_init(void) PORTC |= (1<. #include "print.h" #include "debug.h" #include "util.h" +#ifdef REDSCARFII_PLUS +#include "rgb.h" +#endif #include "matrix.h" #ifndef DEBOUNCE @@ -60,6 +63,11 @@ void matrix_init(void) MCUCR = (1< + +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 . +*/ + +#include +#include "yc059.h" +#include "rgb.h" + +static rgb_config_t rgb_config; + +void rgb_init(void) +{ + DDRE |= (1< + +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 . +*/ + +#ifndef RGB_H +#define RGB_H + +#include +#include + +enum rgb_mode_id { + RGB_FIXED = 0, + RGB_VARIABLE +}; + +enum rgb_fixed_id { + RGB_FIXED_WHITE = 0, + RGB_FIXED_RED, + RGB_FIXED_GREEN, + RGB_FIXED_BLUE, + RGB_FIXED_RED_1, + RGB_FIXED_GREEN_1, + RGB_FIXED_BLUE_1, + RGB_FIXED_RED_2, + RGB_FIXED_GREEN_2, + RGB_FIXED_BLUE_2, + RGB_FIXED_RED_3, + RGB_FIXED_GREEN_3, + RGB_FIXED_BLUE_3, + RGB_FIXED_RED_4, + RGB_FIXED_GREEN_4, + RGB_FIXED_BLUE_4, + RGB_FIXED_COUNT +}; + +enum rgb_variable_id { + RGB_VARIABLE_FLASH = 0, + RGB_VARIABLE_STROBE, + RGB_VARIABLE_FADE, + RGB_VARIABLE_SMOOTH, + RGB_VARIABLE_COUNT +}; + +typedef union { + uint8_t raw; + struct { + uint8_t id :4; + uint8_t mode :3; + bool enable :1; + }; +} rgb_config_t; + +#define EECONFIG_RGB (uint8_t *)7 +#define RGB_UNCONFIGURED 0xFF + +void rgb_init(void); +void rgb_resume(void); +void rgb_read_config(void); +void rgb_write_config(void); +void rgb_on(void); +void rgb_off(void); +void rgb_toggle(void); +void rgb_increase(void); +void rgb_decrease(void); +void rgb_set(uint8_t mode, uint8_t id); +void rgb_step(uint8_t mode); +uint8_t rgb_to_yc059(uint8_t mode, uint8_t id); + +#endif diff --git a/keyboard/RedScarfII/suspend.c b/keyboard/RedScarfII/suspend.c new file mode 100644 index 00000000..8be25efb --- /dev/null +++ b/keyboard/RedScarfII/suspend.c @@ -0,0 +1,35 @@ +/* +Copyright 2014 Kai Ryu + +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 . +*/ + +#include +#include "suspend.h" +#include "rgb.h" + +#ifdef SUSPEND_ACTION + +void suspend_power_down_action(void) +{ + DDRE &= ~(1< + +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 . +*/ + +#include +#include +#include +#include "yc059.h" + +inline +void yc059_ir_enable(void) +{ + YC059_IR_DDR |= (1<>= 1; + } +} + +void yc059_send_word(uint16_t word) +{ + yc059_send_byte((word & 0xFF00) >> 8); + yc059_send_byte(word & 0xFF); +} diff --git a/keyboard/RedScarfII/yc059.h b/keyboard/RedScarfII/yc059.h new file mode 100644 index 00000000..61111585 --- /dev/null +++ b/keyboard/RedScarfII/yc059.h @@ -0,0 +1,73 @@ +/* +Copyright 2014 Kai Ryu + +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 . +*/ + +#ifndef YC059_H +#define YC059_H + +#include + +#define YC059_FREQ 38000 +#define YC059_ADDRESS 0x00EF + +#define YC059_HDR_MARK 9000 +#define YC059_HDR_SPACE 4500 +#define YC059_BIT_MARK 560 +#define YC059_ONE_SPACE 1600 +#define YC059_ZERO_SPACE 560 +#define YC059_RPT_SPACE 2250 + +#define YC059_IR_DDR DDRC +#define YC059_IR_PORT PORTC +#define YC059_IR_BIT PC6 + +enum yc059_id { + YC059_INCREASE = 0, + YC059_DECREASE, + YC059_OFF, + YC059_ON, + YC059_FIXED_RED, + YC059_FIXED_GREEN, + YC059_FIXED_BLUE, + YC059_FIXED_WHITE, + YC059_FIXED_RED_1, + YC059_FIXED_GREEN_1, + YC059_FIXED_BLUE_1, + YC059_FLASH, + YC059_FIXED_RED_2, + YC059_FIXED_GREEN_2, + YC059_FIXED_BLUE_2, + YC059_STROBE, + YC059_FIXED_RED_3, + YC059_FIXED_GREEN_3, + YC059_FIXED_BLUE_3, + YC059_FADE, + YC059_FIXED_RED_4, + YC059_FIXED_GREEN_4, + YC059_FIXED_BLUE_4, + YC059_SMOOTH, + YC059_ERROR = 0xFF +}; + +void yc059_init(void); +void yc059_send(uint8_t data); +void yc059_send_header(void); +void yc059_send_address(void); +void yc059_send_byte(uint8_t byte); +void yc059_send_word(uint16_t word); +void yc059_send_stop(void); + +#endif