From 9ef21d2e1c26b4153368fb3fe887ea7117c5b49b Mon Sep 17 00:00:00 2001 From: zvecr Date: Wed, 27 Mar 2019 01:39:09 +0000 Subject: Refactor staryu to current standards and enable support for backlight keycodes (#5487) --- keyboards/staryu/backlight_staryu.c | 52 ------------- keyboards/staryu/backlight_staryu.h | 25 +++++-- keyboards/staryu/config.h | 60 +++++++-------- keyboards/staryu/keymaps/default/keymap.c | 119 ++++++++++++++++++------------ keyboards/staryu/rules.mk | 50 +++++++++---- keyboards/staryu/staryu.c | 34 +++++++-- keyboards/staryu/staryu.h | 12 ++- 7 files changed, 183 insertions(+), 169 deletions(-) delete mode 100644 keyboards/staryu/backlight_staryu.c 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 @@ -#include "backlight.h" -#include - -/* backlighting */ -void init_backlight_led(void) -{ - DDRC |= (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. -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 . +*/ +#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 268fe991a..7f8b39ba7 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 . */ -#ifndef CONFIG_H -#define CONFIG_H +#pragma once #include "config_common.h" @@ -32,43 +31,38 @@ along with this program. If not, see . #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<. */ #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 12b8be92e..f404dff28 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 . */ -#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 -- cgit v1.2.3-24-g4f1b