Skip to content

Commit

Permalink
Merge pull request qmk#9 from tusing/zeal60
Browse files Browse the repository at this point in the history
Keymap speed effect; keymap improvements/fixes
  • Loading branch information
Wilba6582 authored Sep 9, 2018
2 parents 524212d + a096e97 commit 6ed9a44
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 26 deletions.
27 changes: 18 additions & 9 deletions keyboards/zeal60/keymaps/tusing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

<img src="https://i.imgur.com/UuUdOCb.jpg" width="800">

## Requirements

- WS2812B RGB strip, preferably 60 LEDs/meter
- Wire, solder
- Tape, hot glue, or some sort of adhesive

## A. Connecting the strip
You might find the [**full PCB image**](https://cdn.shopify.com/s/files/1/0490/7329/files/zeal60jumpers.png) helpful. Ignore the red boxes!

Expand All @@ -12,43 +18,46 @@ You might find the [**full PCB image**](https://cdn.shopify.com/s/files/1/0490/7
2. Connect DI to PB0.

<img src="https://i.imgur.com/BiMyMLv.jpg" width="300">

3. Should look something like this when finished:

<img src="https://i.imgur.com/ngxYMuA.jpg" width="600">

*Optional:* To allow considerably more light to escape, consider angling the strip outwards by using some sort of fulcrum under the strip. (I used a thick wire.)

## B. Enabling the strip
1. If it is not present already, add the following to your ***keymap's*** ```Makefile```:

```Makefile
RGBLIGHT_ENABLE = yes
AUDIO_ENABLE = no #Underglow animations cannot be used with audio.
```
2. If it is not present already, add the following to your *keymap's* ```config.h```:
2. If it is not present already, add the following to your *keymap's* ```config.h```, and edit the values as necessary:
```c
#define RGBLIGHT_ANIMATIONS // Underglow animations.
// Set up RGB underglow.
#define RGB_DI_PIN B0 // The pin your RGB strip is wired to
#define RGBLIGHT_ANIMATIONS // Require for fancier stuff (not compatible with audio)
#define RGBLED_NUM 35 // Number of LEDs
#define RGBLIGHT_HUE_STEP 5 // How much each press of rgb_hue changes hue
#define RGBLIGHT_SAT_STEP 10 // How much each press of rgb_sat changes sat
#define RGBLIGHT_VAL_STEP 10 // How much each press of rgb_val changes val
```
3. If they are not present already, add the following keycodes to your keymap to control the RGB strip: ```RGB_TOG``` (on/off), ```RGB_MOD``` (step through modes), ```RGB_HUI```, ```RGB_HUD```, ```RGB_SAI```, ```RGB_SAD```, ```RGB_VAI```, ```RGB_VAD``` (HSV increase/decrease). Add these to your keymap.
3. If they are not present already, add the following keycodes to your keymap to control the RGB strip: ```RGB_TOG``` (on/off), ```RGB_MOD``` (step through modes), ```RGB_HUI```, ```RGB_HUD```, ```RGB_SAI```, ```RGB_SAD```, ```RGB_VAI```, ```RGB_VAD``` (HSV increase/decrease). Add these to your keymap.
## C. Dealing with current limits
USB 2.0 ports on laptops provide up to 500mA max, but USB 3.0 ports can provide up to 900mA; USB 3.1 up to 1.5A; and powered USB hubs even more. We can run our keyboard at a higher brightness if we draw more power. **The Zeal60 uses 500mA at max brightness.** This means that **you have about 400mA remaining for the strip to use on a USB 3.0 port**; 1000mA free on a USB 3.1 port, so on and so forth.
***Warning:*** **This means you will need to turn *off* your RGB strip before connecting to a USB 2.0 port**, as USB 2.0 cannot sustain the current necessary!
1. If not present already, add the following to your keymap's ```config.h```. Change variable definitions based on your needs.
1. If not present already, add the following to your keymap's ```config.h```. Change the numbers based on your needs. The ones below are safe underestimates.
```c
// Current limiting.
#define USB_MAX_POWER_CONSUMPTION 900 // Limit device max power consumption.
#define RGBSTRIP_CURRENT_LIMIT 400 // Strip current limit in mA.
#define RGBSTRIP_MAX_CURRENT_PER_LIGHT 60 // mA per light when at max brightness.
// Enable current limiting for RGB underglow.
#define RGBSTRIP_CURRENT_LIMIT 400 // Strip current limit in mA. (USB amperage - 500mA for keyboard)
#define RGBSTRIP_MAX_CURRENT_PER_LIGHT 50 // mA per light when at max brightness.
```
*Example:* I use a USB port capable of providing 1800 mA. The keyboard uses 500mA, so my personal value (in the `tusing` keymap) for `RGBSTRIP_CURRENT_LIMIT` is 1300. The particular WS2812B RGB strip I have uses a maximum of 60 mA per LED, so that is my personal value for `RGBSTRIP_MAX_CURRENT_PER_LIGHT`.
2. Toggle on the LED strip (```RGB_TOG```) and step through animations (```RGB_MOD```) to test it out!

## D. Sources and resources
Expand Down
7 changes: 4 additions & 3 deletions keyboards/zeal60/keymaps/tusing/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#define RGB_BACKLIGHT_DISABLE_HHKB_BLOCKER_LEDS 0

// Set up RGB underglow.
#define RGBLIGHT_ANIMATIONS
#define RGB_DI_PIN B0 // The pin your RGB strip is wired to
#define RGBLIGHT_ANIMATIONS // Require for fancier stuff (not compatible with audio)
#define RGBLED_NUM 35 // Number of LEDs
Expand All @@ -32,12 +31,14 @@
#define RGBLIGHT_VAL_STEP 10 // How much each press of rgb_val changes val

// Enable current limiting for RGB underglow.
//#define USB_MAX_POWER_CONSUMPTION 900
#define RGBSTRIP_CURRENT_LIMIT 800 // Strip current limit in mA.
#define RGBSTRIP_CURRENT_LIMIT 1300 // Strip current limit in mA. (USB amperage - 500mA for keyboard)
#define RGBSTRIP_MAX_CURRENT_PER_LIGHT 40 // mA per light when at max brightness.

// Scale brightnes according to BRIGHTNESS_CORRECTION_TABLE in quantum/rgblight.c.
// This allows to mitigate uneven brightness from LED underglow strips.
// #define LED_BRIGHTNESS_CORRECTION

// Prevent modifiers on layer 1 from persisting after we let go
#define PREVENT_STUCK_MODIFIERS

#endif
27 changes: 13 additions & 14 deletions keyboards/zeal60/keymaps/tusing/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
// For readability.
#define _______ KC_TRNS
#define _x_ KC_NO

#define AUD_PRV LCTL(KC_MPRV) // Previous music track
#define AUD_PLY LCTL(KC_MPLY) // Pause music
#define AUD_NXT LCTL(KC_MNXT) // Next music track

// Zeal60-specific keys:
// EF_INC, EF_DEC, // next/previous backlight effect
Expand All @@ -16,9 +18,8 @@
// BR_INC, BR_DEC, // backlight brightness increase/decrease

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

// Default layer: Pressing caps-lock momentarily switches to Layer 1.
// This is the default layer. Pressing an invalid keycode on another layer will take you here.
// This is the default layer. Pressing an empty keycode on another layer will take you here.
[0] = {
{KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC},
{KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS},
Expand All @@ -27,25 +28,23 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
{KC_LCTL, KC_LGUI, KC_LALT, _x_ , _x_ , _x_ , _x_ , KC_SPC, _x_ , _x_ , KC_LEFT, KC_UP, KC_DOWN, KC_RGHT}
},

// Layer 1: Pressing Ctrl switches to layer 2.
// Layer 1: Pressing enter switches to layer 2, where backlight controls live.
// This is a momentary layer: once you let go of caps, you'll be back in layer 1.
[1] = {
{KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL },
{_______, KC_VOLD, KC_MUTE, KC_VOLU, _______, _______, _______, _______, KC_PSCR, KC_SLCK, KC_PAUS, KC_INS, KC_DEL, _______},
{_______, KC_MPRV, KC_MPLY, KC_MNXT, _______, _______, _______, _______, _______, _______, _______, _______, _______, _x_ },
{_______, AUD_PRV, AUD_PLY, AUD_NXT, _______, _______, _______, _______, _______, _______, _______, _______, TO(2) , _x_ },
{KC_CAPS, _x_ , _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _x_ },
{TO(2), _______, _______, _x_ , _x_ , _x_ , _x_ , _______, _x_ , _x_ , KC_HOME, KC_PGUP, KC_PGDN, KC_END}
{KC_RCTL, KC_RGUI, KC_RALT, _x_ , _x_ , _x_ , _x_ , _______, _x_ , _x_ , KC_HOME, KC_PGUP, KC_PGDN, KC_END}
},


// Layer 2: Zeal60 and backlight configuration. (Get here quickly by pressing Caps+Control from Layer 1.)
// This is a persistent layer. Get back to Layer 1 by pressing left control or an unused key.
// Layer 2: Zeal60 and backlight configuration. (Get here quickly by pressing Caps+Enter from Layer 1.)
// This is a persistent layer. Get back to the default layer by pressing enter.
[2] = {
{RESET, EF_DEC, EF_INC, BR_DEC, BR_INC, _______, _______, _______, _______, _______, _______, _______, _______, _______},
{RESET, EF_DEC, EF_INC, BR_DEC, BR_INC, ES_DEC, ES_INC, _______, _______, _______, _______, _______, _______, _______},
{_______, H1_DEC, H1_INC, S1_DEC, S1_INC, _______, _______, _______, _______, _______, _______, _______, _______, _______},
{RGB_TOG, H2_DEC, H2_INC, S2_DEC, S2_INC, _______, _______, _______, _______, _______, _______, _______, _______, _x_ },
{_______, H2_DEC, H2_INC, S2_DEC, S2_INC, _______, _______, _______, _______, _______, _______, _______, TO(0) , _x_ },
{RGB_MOD, _x_ , RGB_HUD, RGB_HUI, RGB_SAD, RGB_SAI, _______, _______, _______, _______, _______, _______, _______, _x_ },
{TO(0), RGB_VAD, RGB_VAI, _x_ , _x_ , _x_ , _x_ , _______, _x_ , _x_ , _______, _______, _______, _______}
{RGB_TOG, RGB_VAD, RGB_VAI, _x_ , _x_ , _x_ , _x_ , _______, _x_ , _x_ , _______, _______, _______, _______}
}

};
};

0 comments on commit 6ed9a44

Please sign in to comment.