aboutsummaryrefslogtreecommitdiff
path: root/keyboards/staryu
diff options
context:
space:
mode:
authorzvecr <git@zvecr.com>2019-03-27 01:39:09 +0000
committerDrashna Jaelre <drashna@live.com>2019-03-26 18:39:09 -0700
commit9ef21d2e1c26b4153368fb3fe887ea7117c5b49b (patch)
tree6fb7e565b65f6df97755aae4f58e000862280bdb /keyboards/staryu
parenta0270b55e1e5326ff097644ffe617574f2311d61 (diff)
downloadqmk_firmware-9ef21d2e1c26b4153368fb3fe887ea7117c5b49b.tar.gz
qmk_firmware-9ef21d2e1c26b4153368fb3fe887ea7117c5b49b.zip
Refactor staryu to current standards and enable support for backlight keycodes (#5487)
Diffstat (limited to 'keyboards/staryu')
-rw-r--r--keyboards/staryu/backlight_staryu.c52
-rw-r--r--keyboards/staryu/backlight_staryu.h25
-rwxr-xr-xkeyboards/staryu/config.h60
-rwxr-xr-xkeyboards/staryu/keymaps/default/keymap.c119
-rwxr-xr-xkeyboards/staryu/rules.mk50
-rwxr-xr-xkeyboards/staryu/staryu.c34
-rwxr-xr-xkeyboards/staryu/staryu.h12
7 files changed, 183 insertions, 169 deletions
diff --git a/keyboards/staryu/backlight_staryu.c b/keyboards/staryu/backlight_staryu.c
deleted file mode 100644
index 6fb9713f3..000000000
--- a/keyboards/staryu/backlight_staryu.c
+++ /dev/null
@@ -1,52 +0,0 @@
1#include "backlight.h"
2#include <avr/pgmspace.h>
3
4/* backlighting */
5void init_backlight_led(void)
6{
7 DDRC |= (1<<PC2 | 1<<PC7);
8 DDRD |= (1<<PD5 | 1<<PD6);
9 DDRB |= (1<<PB0);
10}
11
12void backlight_led_off(uint8_t index)
13{
14 switch (index) {
15 case 0:
16 PORTC |= (1<<PC2);
17 break;
18 case 1:
19 PORTC |= (1<<PC7);
20 break;
21 case 2:
22 PORTD |= (1<<PD5);
23 break;
24 case 3:
25 PORTD |= (1<<PD6);
26 break;
27 case 4:
28 PORTB |= (1<<PB0);
29 break;
30 }
31}
32
33void backlight_led_on(uint8_t index)
34{
35 switch (index) {
36 case 0:
37 PORTC &= ~(1<<PC2);
38 break;
39 case 1:
40 PORTC &= ~(1<<PC7);
41 break;
42 case 2:
43 PORTD &= ~(1<<PD5);
44 break;
45 case 3:
46 PORTD &= ~(1<<PD6);
47 break;
48 case 4:
49 PORTB &= ~(1<<PB0);
50 break;
51 }
52}
diff --git a/keyboards/staryu/backlight_staryu.h b/keyboards/staryu/backlight_staryu.h
index f718b970c..3272283e9 100644
--- a/keyboards/staryu/backlight_staryu.h
+++ b/keyboards/staryu/backlight_staryu.h
@@ -1,12 +1,21 @@
1#ifndef STARYU_BL 1/*
2#define STARYU_BL 2Copyright 2019
3 3
4#include <stdint.h> 4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
5 8
6void init_backlight_led(void); 9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
7 13
8void backlight_led_on(uint8_t index); 14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#pragma once
9 18
10void backlight_led_off(uint8_t index); 19// Add backwards compatibility for existing keymaps
11 20#define backlight_led_off(i) backlight_set_value(i, 0)
12#endif 21#define backlight_led_on(i) backlight_set_value(i, 1) \ No newline at end of file
diff --git a/keyboards/staryu/config.h b/keyboards/staryu/config.h
index 268fe991a..7f8b39ba7 100755
--- a/keyboards/staryu/config.h
+++ b/keyboards/staryu/config.h
@@ -14,8 +14,7 @@ GNU General Public License for more details.
14You should have received a copy of the GNU General Public License 14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>. 15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17#ifndef CONFIG_H 17#pragma once
18#define CONFIG_H
19 18
20#include "config_common.h" 19#include "config_common.h"
21 20
@@ -32,43 +31,38 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
32#define MATRIX_COLS 5 31#define MATRIX_COLS 5
33 32
34/* key matrix pins */ 33/* key matrix pins */
35#define MATRIX_ROW_PINS { } 34#define MATRIX_ROW_PINS { NO_PIN }
36#define MATRIX_COL_PINS { D0, D1, D2, D3, D4 } 35#define MATRIX_COL_PINS { D0, D1, D2, D3, D4 }
37#define UNUSED_PINS 36#define UNUSED_PINS
38 37
39// from light_ws2812_config @ 38/* COL2ROW or ROW2COL */
40// https://github.com/kairyu/tmk_keyboard_custom/tree/master/keyboard/staryu 39#define DIODE_DIRECTION COL2ROW
40
41#define RGB_DI_PIN C6 41#define RGB_DI_PIN C6
42#define RGBLIGHT_ANIMATIONS
43#define RGBLED_NUM 1 // Number of LEDs 42#define RGBLED_NUM 1 // Number of LEDs
43#define RGBLIGHT_ANIMATIONS
44// #ifdef RGB_DI_PIN
45// #define RGBLIGHT_HUE_STEP 8
46// #define RGBLIGHT_SAT_STEP 8
47// #define RGBLIGHT_VAL_STEP 8
48// #define RGBLIGHT_LIMIT_VAL 255 /* The maximum brightness level */
49// #define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */
50// /*== all animations enable ==*/
51// #define RGBLIGHT_ANIMATIONS
52// /*== or choose animations ==*/
53// #define RGBLIGHT_EFFECT_BREATHING
54// #define RGBLIGHT_EFFECT_RAINBOW_MOOD
55// #define RGBLIGHT_EFFECT_RAINBOW_SWIRL
56// #define RGBLIGHT_EFFECT_SNAKE
57// #define RGBLIGHT_EFFECT_KNIGHT
58// #define RGBLIGHT_EFFECT_CHRISTMAS
59// #define RGBLIGHT_EFFECT_STATIC_GRADIENT
60// #define RGBLIGHT_EFFECT_RGB_TEST
61// #define RGBLIGHT_EFFECT_ALTERNATING
62// #endif
44 63
45/* COL2ROW or ROW2COL */ 64#define BACKLIGHT_LEVELS 1 // either on/off
46#define DIODE_DIRECTION COL2ROW 65#define RGBLIGHT_LIMIT_VAL 200
47 66
48/* Set 0 if debouncing isn't needed */ 67/* Set 0 if debouncing isn't needed */
49#define DEBOUNCING_DELAY 5 68#define DEBOUNCING_DELAY 5
50
51// TODO backlighting
52#define BACKLIGHT_LEVELS 10
53// #define BACKLIGHT_PIN B7
54/*
55Backlight: C2, C7, D5, D6, B0
56switch (index) {
57 case 0:
58 PORTC &= ~(1<<PC2);
59 break;
60 case 1:
61 PORTC &= ~(1<<PC7);
62 break;
63 case 2:
64 PORTD &= ~(1<<PD5);
65 break;
66 case 3:
67 PORTD &= ~(1<<PD6);
68 break;
69 case 4:
70 PORTB &= ~(1<<PB0);
71 break;
72*/
73
74#endif
diff --git a/keyboards/staryu/keymaps/default/keymap.c b/keyboards/staryu/keymaps/default/keymap.c
index d68eb4287..8c47ff44a 100755
--- a/keyboards/staryu/keymaps/default/keymap.c
+++ b/keyboards/staryu/keymaps/default/keymap.c
@@ -20,62 +20,85 @@ enum layers {
20 _LAYER0, 20 _LAYER0,
21 _LAYER1, 21 _LAYER1,
22 _LAYER2, 22 _LAYER2,
23 _LAYER3 23 _LAYER3,
24 _LAYER4
24}; 25};
25 26
27const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
28
29 [_LAYER0] = LAYOUT(
30/* ┌─────────┬─────────┬─────────┐ */
31 KC_UP, TO(_LAYER1),
32/* ├─────────┼─────────┼─────────┤ */
33 KC_LEFT, KC_DOWN, KC_RIGHT
34/* └─────────┴─────────┴─────────┘ */
35 ),
36
37 [_LAYER1] = LAYOUT(
38/* ┌─────────┬─────────┬─────────┐ */
39 KC_PGUP, TO(_LAYER2),
40/* ├─────────┼─────────┼─────────┤ */
41 KC_HOME, KC_PGDN, KC_END
42/* └─────────┴─────────┴─────────┘ */
43 ),
44
45 [_LAYER2] = LAYOUT(
46/* ┌─────────┬─────────┬─────────┐ */
47 KC_MSEL, TO(_LAYER3),
48/* ├─────────┼─────────┼─────────┤ */
49 KC_MPRV, KC_MPLY, KC_MNXT
50/* └─────────┴─────────┴─────────┘ */
51 ),
52
53 [_LAYER3] = LAYOUT(
54/* ┌─────────┬─────────┬─────────┐ */
55 KC_MS_U, TO(_LAYER4),
56/* ├─────────┼─────────┼─────────┤ */
57 KC_MS_L, KC_MS_D, KC_MS_R
58/* └─────────┴─────────┴─────────┘ */
59 ),
60
61 [_LAYER4] = LAYOUT(
62/* ┌─────────┬─────────┬─────────┐ */
63 XXXXXXX, TO(_LAYER0),
64/* ├─────────┼─────────┼─────────┤ */
65 RGB_TOG, BL_TOGG, BL_STEP
66/* └─────────┴─────────┴─────────┘ */
67 ),
26 68
27const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
28 /* Keymap 0
29 * ,-----------.
30 * | |Up |Fn0|
31 * |---+---+---|
32 * |Lef|Dow|Rig|
33 * `-----------'
34 */
35 LAYOUT( KC_UP, TO(_LAYER1), KC_LEFT,KC_DOWN,KC_RIGHT ),
36 /* Keymap 1
37 * ,-----------.
38 * | |PgU|Fn1|
39 * |---+---+---|
40 * |Hom|PgD|End|
41 * `-----------'
42 */
43 LAYOUT( KC_PGUP,TO(_LAYER2), KC_HOME,KC_PGDN,KC_END ),
44 /* Keymap 2
45 * ,-----------.
46 * | |Sel|Fn2|
47 * |---+---+---|
48 * |Pre|Pla|Nex|
49 * `-----------'
50 */
51 LAYOUT( KC_MSEL,TO(_LAYER3), KC_MPRV,KC_MPLY,KC_MNXT ),
52 /* Keymap 3
53 * ,-----------.
54 * | |MsU|Fn3|
55 * |---+---+---|
56 * |MsL|MsD|MsR|
57 * `-----------'
58 */
59 LAYOUT( KC_MS_U,TO(_LAYER0), KC_MS_L,KC_MS_D,KC_MS_R ),
60 // /* Keymap 4
61 // * ,-----------.
62 // * | |Fn6|Fn4|
63 // * |---+---+---|
64 // * |Fn7|Fn5|Fn8|
65 // * `-----------'
66 // */
67 // LAYOUT( FN6, FN4, FN7, FN5, FN8 ),
68}; 69};
69 70
70const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { 71void eeconfig_init_user(void) {
71 return MACRO_NONE ; 72 // use the non noeeprom versions, to write these values to EEPROM too
72} 73 rgblight_enable();
74 rgblight_mode(RGBLIGHT_MODE_BREATHING+1);
73 75
74void matrix_init_user(void) { 76 backlight_enable();
75} 77}
76 78
77void matrix_scan_user(void) { 79void keyboard_post_init_user(void) {
80 //layer_state_set_user is not called for inital state - set it here
81 rgblight_sethsv_noeeprom_white();
78} 82}
79 83
80void led_set_user(uint8_t usb_led) { 84uint32_t layer_state_set_user(uint32_t state) {
85 switch (biton32(state)) {
86 case _LAYER1:
87 rgblight_sethsv_noeeprom_cyan();
88 break;
89 case _LAYER2:
90 rgblight_sethsv_noeeprom_magenta();
91 break;
92 case _LAYER3:
93 rgblight_sethsv_noeeprom_red();
94 break;
95 case _LAYER4:
96 rgblight_sethsv_noeeprom_orange();
97 break;
98 case _LAYER0:
99 default: // for any other layers, or the default layer
100 rgblight_sethsv_noeeprom_white();
101 break;
102 }
103 return state;
81} 104}
diff --git a/keyboards/staryu/rules.mk b/keyboards/staryu/rules.mk
index 3e043bbcd..ad4873a39 100755
--- a/keyboards/staryu/rules.mk
+++ b/keyboards/staryu/rules.mk
@@ -1,10 +1,6 @@
1# MCU name 1# MCU name
2MCU = atmega32u2 2MCU = atmega32u2
3 3
4BOOTLOADER = lufa-dfu
5
6SRC = backlight_staryu.c
7
8# Processor frequency. 4# Processor frequency.
9# This will define a symbol, F_CPU, in all source code files equal to the 5# This will define a symbol, F_CPU, in all source code files equal to the
10# processor frequency in Hz. You can then use this symbol in your source code to 6# processor frequency in Hz. You can then use this symbol in your source code to
@@ -40,21 +36,43 @@ F_USB = $(F_CPU)
40# Interrupt driven control endpoint task(+60) 36# Interrupt driven control endpoint task(+60)
41OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT 37OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
42 38
39# Bootloader selection
40# Teensy halfkay
41# Pro Micro caterina
42# Atmel DFU atmel-dfu
43# LUFA DFU lufa-dfu
44# QMK DFU qmk-dfu
45# atmega32a bootloadHID
46BOOTLOADER = lufa-dfu
47
43 48
44# Boot Section Size in *bytes* 49# If you don't know the bootloader type, then you can specify the
45OPT_DEFS += -DBOOTLOADER_SIZE=4096 50# Boot Section Size in *bytes* by uncommenting out the OPT_DEFS line
51# Teensy halfKay 512
52# Teensy++ halfKay 1024
53# Atmel DFU loader 4096
54# LUFA bootloader 4096
55# USBaspLoader 2048
56# OPT_DEFS += -DBOOTLOADER_SIZE=4096
46 57
47 58
48# Build Options 59# Build Options
49# comment out to disable the options. 60# comment out to disable the options.
50# 61#
51BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) 62BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration(+1000)
52MOUSEKEY_ENABLE = no # Mouse keys(+4700) 63MOUSEKEY_ENABLE = no # Mouse keys(+4700)
53EXTRAKEY_ENABLE = yes # Audio control and System control(+450) 64EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
54CONSOLE_ENABLE = yes # Console for debug(+400) 65CONSOLE_ENABLE = no # Console for debug(+400)
55COMMAND_ENABLE = no # Commands for debug and configuration 66COMMAND_ENABLE = no # Commands for debug and configuration
56SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend 67# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
57NKRO_ENABLE = no # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work 68SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
58BACKLIGHT_ENABLE = yes # In-switch LEDs 69# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
59AUDIO_ENABLE = no # There is no available timer or pin for audio on the NovelPad 70NKRO_ENABLE = no # USB Nkey Rollover
60RGBLIGHT_ENABLE = yes # RGB LEDs for underglow, installed and enabled by default for the NovelPad 71BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality on B7 by default
72RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
73MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config)
74UNICODE_ENABLE = no # Unicode
75BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
76AUDIO_ENABLE = no # Audio output on port C6
77FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
78HD44780_ENABLE = no # Enable support for HD44780 based LCDs (+400)
diff --git a/keyboards/staryu/staryu.c b/keyboards/staryu/staryu.c
index 6dcaaea0e..20334c0b7 100755
--- a/keyboards/staryu/staryu.c
+++ b/keyboards/staryu/staryu.c
@@ -15,12 +15,30 @@ You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>. 15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17#include "staryu.h" 17#include "staryu.h"
18#include "backlight_staryu.h" 18
19 19#ifdef BACKLIGHT_ENABLE
20// for keyboard subdirectory level init functions 20
21// @Override 21#ifdef BACKLIGHT_PIN
22void matrix_init_kb(void) { 22 #pragma error "BACKLIGHT_PIN must stay undefined otherwise software pwm is incorrectly used"
23 // call user level keymaps, if any 23#endif
24 init_backlight_led(); 24
25 matrix_init_user(); 25#define BACKLIGHT_PIN_COUNT 5
26static const pin_t backlight_pins[BACKLIGHT_PIN_COUNT] = { C2, C7, D5, D6, B0 };
27
28void backlight_init_ports(void) {
29 for (uint8_t index = 0; index < BACKLIGHT_PIN_COUNT; index++) {
30 setPinOutput(backlight_pins[index]);
31 }
26} 32}
33
34void backlight_set_value(uint8_t index, uint8_t level) {
35 writePin(backlight_pins[index], !!level);
36}
37
38void backlight_set(uint8_t level) {
39 for (uint8_t index = 0; index < BACKLIGHT_PIN_COUNT; index++) {
40 backlight_set_value(index, level);
41 }
42}
43
44#endif //BACKLIGHT_ENABLE
diff --git a/keyboards/staryu/staryu.h b/keyboards/staryu/staryu.h
index 12b8be92e..f404dff28 100755
--- a/keyboards/staryu/staryu.h
+++ b/keyboards/staryu/staryu.h
@@ -14,15 +14,19 @@ GNU General Public License for more details.
14You should have received a copy of the GNU General Public License 14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>. 15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17#ifndef KB_H 17#pragma once
18#define KB_H
19#include "quantum.h" 18#include "quantum.h"
20 19
21#define LAYOUT( \ 20#define LAYOUT( \
22 K00, K01, \ 21 K00, K01, \
23 K10, K11, K12 \ 22 K10, K11, K12 \
24) { \ 23) { \
25 { K00, K01, K12, K11, K10 }, \ 24 { K00, K01, K12, K11, K10 }, \
26} 25}
27 26
27
28#ifdef BACKLIGHT_ENABLE
29
30void backlight_set_value(uint8_t index, uint8_t level);
31
28#endif 32#endif