1
0
Fork 0

[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
// 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_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
/* key matrix size */
#define MATRIX_ROWS 1
#define MATRIX_COLS 5
#define MATRIX_ROWS 2
#define MATRIX_COLS 3
/* key matrix pins */
#define MATRIX_ROW_PINS { NO_PIN }
#define MATRIX_COL_PINS { D0, D1, D2, D3, D4 }
#define DIRECT_PINS { \
{ NO_PIN, D0, D1 }, \
{ D4, D3, D2 }, \
}
#define UNUSED_PINS
/* COL2ROW or ROW2COL */
#define DIODE_DIRECTION COL2ROW
#define RGB_DI_PIN C6
#define RGBLED_NUM 1 // Number of LEDs
#define RGBLIGHT_ANIMATIONS
#define RGBLIGHT_LIMIT_VAL 200
// #ifdef RGB_DI_PIN
// #define RGBLIGHT_HUE_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
// #endif
#define BACKLIGHT_LEVELS 1 // either on/off
#define RGBLIGHT_LIMIT_VAL 200
#undef BACKLIGHT_PIN
#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 */
#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/>.
*/
#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/>.
*/
#pragma once
#include "quantum.h"
#define ___ KC_NO
#define LAYOUT( \
K00, K01, \
K01, K02, \
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