[Keyboard] Convert Staryu to use DIRECT_PINS and BACKLIGHT_PINS (#5848)

* Convert to use DIRECT_PINS and BACKLIGHT_PINS

* Convert to use DIRECT_PINS and BACKLIGHT_PINS - remove old comment
This commit is contained in:
zvecr 2019-05-12 06:57:51 +01:00 committed by Drashna Jaelre
parent 831d765b52
commit b32ad8b90c
4 changed files with 31 additions and 46 deletions

View File

@ -17,5 +17,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once #pragma once
// Add backwards compatibility for existing keymaps // Add backwards compatibility for existing keymaps
static inline void backlight_set_value(uint8_t index, uint8_t level) {
static const uint8_t backlight_pins[BACKLIGHT_LED_COUNT] = BACKLIGHT_PINS;
if (level) {
setPinOutput(backlight_pins[index]);
} else {
setPinInput(backlight_pins[index]);
}
}
#define backlight_led_off(i) backlight_set_value(i, 0) #define backlight_led_off(i) backlight_set_value(i, 0)
#define backlight_led_on(i) backlight_set_value(i, 1) #define backlight_led_on(i) backlight_set_value(i, 1)

View File

@ -27,20 +27,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DESCRIPTION 5-key macropad #define DESCRIPTION 5-key macropad
/* key matrix size */ /* key matrix size */
#define MATRIX_ROWS 1 #define MATRIX_ROWS 2
#define MATRIX_COLS 5 #define MATRIX_COLS 3
/* key matrix pins */ /* key matrix pins */
#define MATRIX_ROW_PINS { NO_PIN } #define DIRECT_PINS { \
#define MATRIX_COL_PINS { D0, D1, D2, D3, D4 } { NO_PIN, D0, D1 }, \
{ D4, D3, D2 }, \
}
#define UNUSED_PINS #define UNUSED_PINS
/* COL2ROW or ROW2COL */
#define DIODE_DIRECTION COL2ROW
#define RGB_DI_PIN C6 #define RGB_DI_PIN C6
#define RGBLED_NUM 1 // Number of LEDs #define RGBLED_NUM 1 // Number of LEDs
#define RGBLIGHT_ANIMATIONS #define RGBLIGHT_ANIMATIONS
#define RGBLIGHT_LIMIT_VAL 200
// #ifdef RGB_DI_PIN // #ifdef RGB_DI_PIN
// #define RGBLIGHT_HUE_STEP 8 // #define RGBLIGHT_HUE_STEP 8
// #define RGBLIGHT_SAT_STEP 8 // #define RGBLIGHT_SAT_STEP 8
@ -61,8 +61,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// #define RGBLIGHT_EFFECT_ALTERNATING // #define RGBLIGHT_EFFECT_ALTERNATING
// #endif // #endif
#define BACKLIGHT_LEVELS 1 // either on/off #undef BACKLIGHT_PIN
#define RGBLIGHT_LIMIT_VAL 200 #define BACKLIGHT_PINS { C2, C7, D5, D6, B0 }
#define BACKLIGHT_LED_COUNT 5
#define BACKLIGHT_LEVELS 10
#define BACKLIGHT_ON_STATE 1
/* Set 0 if debouncing isn't needed */ /* Set 0 if debouncing isn't needed */
#define DEBOUNCING_DELAY 5 #define DEBOUNCING_DELAY 5
/* Bootmagic Lite key configuration */
#define BOOTMAGIC_LITE_ROW 0
#define BOOTMAGIC_LITE_COLUMN 1

View File

@ -15,30 +15,3 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "staryu.h" #include "staryu.h"
#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

View File

@ -15,18 +15,14 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once #pragma once
#include "quantum.h" #include "quantum.h"
#define ___ KC_NO
#define LAYOUT( \ #define LAYOUT( \
K00, K01, \ K01, K02, \
K10, K11, K12 \ K10, K11, K12 \
) { \ ) { \
{ K00, K01, K12, K11, K10 }, \ { ___, K01, K02 }, \
{ K10, K11, K12 } \
} }
#ifdef BACKLIGHT_ENABLE
void backlight_set_value(uint8_t index, uint8_t level);
#endif