summaryrefslogtreecommitdiffstats
path: root/keyboards
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
parenta0270b55e1e5326ff097644ffe617574f2311d61 (diff)
Refactor staryu to current standards and enable support for backlight keycodes (#5487)
Diffstat (limited to 'keyboards')
-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 6fb9713f3a..0000000000
--- a/keyboards/staryu/backlight_staryu.c
+++ /dev/null
@@ -1,52 +0,0 @@
-#include "backlight.h"
-#include <avr/pgmspace.h>
-
-/* backlighting */
-void init_backlight_led(void)
-{
- DDRC |= (1<<PC2 | 1<<PC7);
- DDRD |= (1<<PD5 | 1<<PD6);
- DDRB |= (1<<PB0);
-}
-
-void backlight_led_off(uint8_t index)
-{
- switch (index) {
- case 0:
- PORTC |= (1<<PC2);
- break;
- case 1:
- PORTC |= (1<<PC7);
- break;
- case 2:
- PORTD |= (1<<PD5);
- break;
- case 3:
- PORTD |= (1<<PD6);
- break;
- case 4:
- PORTB |= (1<<PB0);
- break;
- }
-}
-
-void backlight_led_on(uint8_t index)
-{
- switch (index) {
- case 0:
- PORTC &= ~(1<<PC2);
- break;
- case 1:
- PORTC &= ~(1<<PC7);
- break;
- case 2:
- PORTD &= ~(1<<PD5);
- break;
- case 3:
- PORTD &= ~(1<<PD6);
- break;
- case 4:
- PORTB &= ~(1<<PB0);
- break;
- }
-}
diff --git a/keyboards/staryu/backlight_staryu.h b/keyboards/staryu/backlight_staryu.h
index f718b970c2..3272283e99 100644
--- a/keyboards/staryu/backlight_staryu.h
+++ b/keyboards/staryu/backlight_staryu.h
@@ -1,12 +1,21 @@
-#ifndef STARYU_BL
-#define STARYU_BL
+/*
+Copyright 2019
-#include <stdint.h>
+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.
-void init_backlight_led(void);
+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.
-void backlight_led_on(uint8_t index);
+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
-void backlight_led_off(uint8_t index);
-
-#endif
+// Add backwards compatibility for existing keymaps
+#define backlight_led_off(i) backlight_set_value(i, 0)
+#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 268fe991ac..7f8b39ba7b 100755
--- a/keyboards/staryu/config.h
+++ b/keyboards/staryu/config.h
@@ -14,8 +14,7 @@ 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/>.
*/
-#ifndef CONFIG_H
-#define CONFIG_H
+#pragma once
#include "config_common.h"
@@ -32,43 +31,38 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MATRIX_COLS 5
/* key matrix pins */
-#define MATRIX_ROW_PINS { }
+#define MATRIX_ROW_PINS { NO_PIN }
#define MATRIX_COL_PINS { D0, D1, D2, D3, D4 }
#define UNUSED_PINS
-// from light_ws2812_config @
-// https://github.com/kairyu/tmk_keyboard_custom/tree/master/keyboard/staryu
+/* COL2ROW or ROW2COL */
+#define DIODE_DIRECTION COL2ROW
+
#define RGB_DI_PIN C6
-#define RGBLIGHT_ANIMATIONS
#define RGBLED_NUM 1 // Number of LEDs
+#define RGBLIGHT_ANIMATIONS
+// #ifdef RGB_DI_PIN
+// #define RGBLIGHT_HUE_STEP 8
+// #define RGBLIGHT_SAT_STEP 8
+// #define RGBLIGHT_VAL_STEP 8
+// #define RGBLIGHT_LIMIT_VAL 255 /* The maximum brightness level */
+// #define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */
+// /*== all animations enable ==*/
+// #define RGBLIGHT_ANIMATIONS
+// /*== or choose animations ==*/
+// #define RGBLIGHT_EFFECT_BREATHING
+// #define RGBLIGHT_EFFECT_RAINBOW_MOOD
+// #define RGBLIGHT_EFFECT_RAINBOW_SWIRL
+// #define RGBLIGHT_EFFECT_SNAKE
+// #define RGBLIGHT_EFFECT_KNIGHT
+// #define RGBLIGHT_EFFECT_CHRISTMAS
+// #define RGBLIGHT_EFFECT_STATIC_GRADIENT
+// #define RGBLIGHT_EFFECT_RGB_TEST
+// #define RGBLIGHT_EFFECT_ALTERNATING
+// #endif
-/* COL2ROW or ROW2COL */
-#define DIODE_DIRECTION COL2ROW
+#define BACKLIGHT_LEVELS 1 // either on/off
+#define RGBLIGHT_LIMIT_VAL 200
/* Set 0 if debouncing isn't needed */
#define DEBOUNCING_DELAY 5
-
-// TODO backlighting
-#define BACKLIGHT_LEVELS 10
-// #define BACKLIGHT_PIN B7
-/*
-Backlight: C2, C7, D5, D6, B0
-switch (index) {
- case 0:
- PORTC &= ~(1<<PC2);
- break;
- case 1:
- PORTC &= ~(1<<PC7);
- break;
- case 2:
- PORTD &= ~(1<<PD5);
- break;
- case 3:
- PORTD &= ~(1<<PD6);
- break;
- case 4:
- PORTB &= ~(1<<PB0);
- break;
-*/
-
-#endif
diff --git a/keyboards/staryu/keymaps/default/keymap.c b/keyboards/staryu/keymaps/default/keymap.c
index d68eb42872..8c47ff44ab 100755
--- a/keyboards/staryu/keymaps/default/keymap.c
+++ b/keyboards/staryu/keymaps/default/keymap.c
@@ -20,62 +20,85 @@ enum layers {
_LAYER0,
_LAYER1,
_LAYER2,
- _LAYER3
+ _LAYER3,
+ _LAYER4
};
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+
+ [_LAYER0] = LAYOUT(
+/* ┌─────────┬─────────┬─────────┐ */
+ KC_UP, TO(_LAYER1),
+/* ├─────────┼─────────┼─────────┤ */
+ KC_LEFT, KC_DOWN, KC_RIGHT
+/* └─────────┴─────────┴─────────┘ */
+ ),
+
+ [_LAYER1] = LAYOUT(
+/* ┌─────────┬─────────┬─────────┐ */
+ KC_PGUP, TO(_LAYER2),
+/* ├─────────┼─────────┼─────────┤ */
+ KC_HOME, KC_PGDN, KC_END
+/* └─────────┴─────────┴─────────┘ */
+ ),
+
+ [_LAYER2] = LAYOUT(
+/* ┌─────────┬─────────┬─────────┐ */
+ KC_MSEL, TO(_LAYER3),
+/* ├─────────┼─────────┼─────────┤ */
+ KC_MPRV, KC_MPLY, KC_MNXT
+/* └─────────┴─────────┴─────────┘ */
+ ),
+
+ [_LAYER3] = LAYOUT(
+/* ┌─────────┬─────────┬─────────┐ */
+ KC_MS_U, TO(_LAYER4),
+/* ├─────────┼─────────┼─────────┤ */
+ KC_MS_L, KC_MS_D, KC_MS_R
+/* └─────────┴─────────┴─────────┘ */
+ ),
+
+ [_LAYER4] = LAYOUT(
+/* ┌─────────┬─────────┬─────────┐ */
+ XXXXXXX, TO(_LAYER0),
+/* ├─────────┼─────────┼─────────┤ */
+ RGB_TOG, BL_TOGG, BL_STEP
+/* └─────────┴─────────┴─────────┘ */
+ ),
-const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
- /* Keymap 0
- * ,-----------.
- * | |Up |Fn0|
- * |---+---+---|
- * |Lef|Dow|Rig|
- * `-----------'
- */
- LAYOUT( KC_UP, TO(_LAYER1), KC_LEFT,KC_DOWN,KC_RIGHT ),
- /* Keymap 1
- * ,-----------.
- * | |PgU|Fn1|
- * |---+---+---|
- * |Hom|PgD|End|
- * `-----------'
- */
- LAYOUT( KC_PGUP,TO(_LAYER2), KC_HOME,KC_PGDN,KC_END ),
- /* Keymap 2
- * ,-----------.
- * | |Sel|Fn2|
- * |---+---+---|
- * |Pre|Pla|Nex|
- * `-----------'
- */
- LAYOUT( KC_MSEL,TO(_LAYER3), KC_MPRV,KC_MPLY,KC_MNXT ),
- /* Keymap 3
- * ,-----------.
- * | |MsU|Fn3|
- * |---+---+---|
- * |MsL|MsD|MsR|
- * `-----------'
- */
- LAYOUT( KC_MS_U,TO(_LAYER0), KC_MS_L,KC_MS_D,KC_MS_R ),
- // /* Keymap 4
- // * ,-----------.
- // * | |Fn6|Fn4|
- // * |---+---+---|
- // * |Fn7|Fn5|Fn8|
- // * `-----------'
- // */
- // LAYOUT( FN6, FN4, FN7, FN5, FN8 ),
};
-const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
- return MACRO_NONE ;
-}
+void eeconfig_init_user(void) {
+ // use the non noeeprom versions, to write these values to EEPROM too
+ rgblight_enable();
+ rgblight_mode(RGBLIGHT_MODE_BREATHING+1);
-void matrix_init_user(void) {
+ backlight_enable();
}
-void matrix_scan_user(void) {
+void keyboard_post_init_user(void) {
+ //layer_state_set_user is not called for inital state - set it here
+ rgblight_sethsv_noeeprom_white();
}
-void led_set_user(uint8_t usb_led) {
+uint32_t layer_state_set_user(uint32_t state) {
+ switch (biton32(state)) {
+ case _LAYER1:
+ rgblight_sethsv_noeeprom_cyan();
+ break;
+ case _LAYER2:
+ rgblight_sethsv_noeeprom_magenta();
+ break;
+ case _LAYER3:
+ rgblight_sethsv_noeeprom_red();
+ break;
+ case _LAYER4:
+ rgblight_sethsv_noeeprom_orange();
+ break;
+ case _LAYER0:
+ default: // for any other layers, or the default layer
+ rgblight_sethsv_noeeprom_white();
+ break;
+ }
+ return state;
}
diff --git a/keyboards/staryu/rules.mk b/keyboards/staryu/rules.mk
index 3e043bbcd5..ad4873a39a 100755
--- a/keyboards/staryu/rules.mk
+++ b/keyboards/staryu/rules.mk
@@ -1,10 +1,6 @@
# MCU name
MCU = atmega32u2
-BOOTLOADER = lufa-dfu
-
-SRC = backlight_staryu.c
-
# Processor frequency.
# This will define a symbol, F_CPU, in all source code files equal to the
# processor frequency in Hz. You can then use this symbol in your source code to
@@ -40,21 +36,43 @@ F_USB = $(F_CPU)
# Interrupt driven control endpoint task(+60)
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
+# Bootloader selection
+# Teensy halfkay
+# Pro Micro caterina
+# Atmel DFU atmel-dfu
+# LUFA DFU lufa-dfu
+# QMK DFU qmk-dfu
+# atmega32a bootloadHID
+BOOTLOADER = lufa-dfu
+
-# Boot Section Size in *bytes*
-OPT_DEFS += -DBOOTLOADER_SIZE=4096
+# If you don't know the bootloader type, then you can specify the
+# Boot Section Size in *bytes* by uncommenting out the OPT_DEFS line
+# Teensy halfKay 512
+# Teensy++ halfKay 1024
+# Atmel DFU loader 4096
+# LUFA bootloader 4096
+# USBaspLoader 2048
+# OPT_DEFS += -DBOOTLOADER_SIZE=4096
# Build Options
# comment out to disable the options.
#
-BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
-MOUSEKEY_ENABLE = no # Mouse keys(+4700)
-EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
-CONSOLE_ENABLE = yes # Console for debug(+400)
-COMMAND_ENABLE = no # Commands for debug and configuration
-SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
-NKRO_ENABLE = no # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
-BACKLIGHT_ENABLE = yes # In-switch LEDs
-AUDIO_ENABLE = no # There is no available timer or pin for audio on the NovelPad
-RGBLIGHT_ENABLE = yes # RGB LEDs for underglow, installed and enabled by default for the NovelPad
+BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE = no # Mouse keys(+4700)
+EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
+CONSOLE_ENABLE = no # Console for debug(+400)
+COMMAND_ENABLE = no # Commands for debug and configuration
+# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
+SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
+# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+NKRO_ENABLE = no # USB Nkey Rollover
+BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality on B7 by default
+RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
+MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config)
+UNICODE_ENABLE = no # Unicode
+BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
+AUDIO_ENABLE = no # Audio output on port C6
+FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
+HD44780_ENABLE = no # Enable support for HD44780 based LCDs (+400)
diff --git a/keyboards/staryu/staryu.c b/keyboards/staryu/staryu.c
index 6dcaaea0e8..20334c0b78 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
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "staryu.h"
-#include "backlight_staryu.h"
-
-// for keyboard subdirectory level init functions
-// @Override
-void matrix_init_kb(void) {
- // call user level keymaps, if any
- init_backlight_led();
- matrix_init_user();
+
+#ifdef BACKLIGHT_ENABLE
+
+#ifdef BACKLIGHT_PIN
+ #pragma error "BACKLIGHT_PIN must stay undefined otherwise software pwm is incorrectly used"
+#endif
+
+#define BACKLIGHT_PIN_COUNT 5
+static const pin_t backlight_pins[BACKLIGHT_PIN_COUNT] = { C2, C7, D5, D6, B0 };
+
+void backlight_init_ports(void) {
+ for (uint8_t index = 0; index < BACKLIGHT_PIN_COUNT; index++) {
+ setPinOutput(backlight_pins[index]);
+ }
}
+
+void backlight_set_value(uint8_t index, uint8_t level) {
+ writePin(backlight_pins[index], !!level);
+}
+
+void backlight_set(uint8_t level) {
+ for (uint8_t index = 0; index < BACKLIGHT_PIN_COUNT; index++) {
+ backlight_set_value(index, level);
+ }
+}
+
+#endif //BACKLIGHT_ENABLE
diff --git a/keyboards/staryu/staryu.h b/keyboards/staryu/staryu.h
index 12b8be92e7..f404dff284 100755
--- a/keyboards/staryu/staryu.h
+++ b/keyboards/staryu/staryu.h
@@ -14,15 +14,19 @@ 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/>.
*/
-#ifndef KB_H
-#define KB_H
+#pragma once
#include "quantum.h"
#define LAYOUT( \
- K00, K01, \
- K10, K11, K12 \
+ K00, K01, \
+ K10, K11, K12 \
) { \
{ K00, K01, K12, K11, K10 }, \
}
+
+#ifdef BACKLIGHT_ENABLE
+
+void backlight_set_value(uint8_t index, uint8_t level);
+
#endif