Now we show off when your keyboard has numlock enabled.

pull/18/head
Jesse Vincent 10 years ago
parent 6e739f164e
commit 93deece2a3

@ -274,13 +274,13 @@ void setup()
Keyboard.begin(); Keyboard.begin();
Mouse.begin(); Mouse.begin();
setup_leds(); setup_leds();
update_leds(); update_leds(0);
setup_command_mode(); setup_command_mode();
setup_matrix(); setup_matrix();
setup_pins(); setup_pins();
rightsx1509.fetchPinStates(); rightsx1509.fetchPinStates();
primary_keymap = load_primary_keymap(); temporary_keymap = primary_keymap = load_primary_keymap();
} }
String myApp; String myApp;
@ -295,7 +295,7 @@ void loop()
TS("about to scan the matrix") TS("about to scan the matrix")
scan_matrix(); scan_matrix();
TS("updating LEDs"); TS("updating LEDs");
update_leds(); update_leds(temporary_keymap == NUMPAD_KEYMAP);
} }

@ -49,7 +49,7 @@
{Key_LGUI, Key_Backspace, Key_LShift, Key_LCtrl, Key_KeymapNext_Momentary, Key_skip, Key_skip, Key_skip, Key_skip, Key_KeymapNext_Momentary, Key_RCtrl, Key_RShift, Key_Space, Key_RAlt},\ {Key_LGUI, Key_Backspace, Key_LShift, Key_LCtrl, Key_KeymapNext_Momentary, Key_skip, Key_skip, Key_skip, Key_skip, Key_KeymapNext_Momentary, Key_RCtrl, Key_RShift, Key_Space, Key_RAlt},\
}, },
#define KEYMAPS 3 #define KEYMAPS 3
// This is a total waste. we should only ever include any given keymap once #define NUMPAD_KEYMAP 2
static const Key keymaps[KEYMAPS][ROWS][COLS] = { static const Key keymaps[KEYMAPS][ROWS][COLS] = {
KEYMAP_QWERTY KEYMAP_QWERTY
KEYMAP_GENERIC_FN2 KEYMAP_GENERIC_FN2

@ -1,5 +1,5 @@
#define KEYMAPS 3 #define KEYMAPS 3
// This is a total waste. we should only ever include any given keymap once #define NUMPAD_KEYMAP 2
static const Key keymaps[KEYMAPS][ROWS][COLS] = { static const Key keymaps[KEYMAPS][ROWS][COLS] = {
KEYMAP_QWERTY KEYMAP_QWERTY
KEYMAP_GENERIC_FN2 KEYMAP_GENERIC_FN2

@ -7,6 +7,7 @@ WS2812 LED(LED_COUNT);
int led_mode; int led_mode;
int last_led_mode; int last_led_mode;
int stored_led_mode;
int pos = 0; int pos = 0;
cRGB led_off; cRGB led_off;
@ -16,7 +17,7 @@ cRGB led_off;
cRGB led_steady; cRGB led_steady;
cRGB led_blue; cRGB led_blue;
cRGB led_dark_blue; cRGB led_dark_blue;
cRGB led_bright_red;
cRGB led_breathe; cRGB led_breathe;
@ -56,6 +57,10 @@ void setup_leds() {
led_dark_blue.g = 0; led_dark_blue.g = 0;
led_dark_blue.b = 127; led_dark_blue.b = 127;
led_bright_red.r=255;
led_bright_red.g=0;
led_bright_red.b=0;
@ -116,7 +121,20 @@ void set_led_mode(int mode) {
void update_leds() { void update_leds(int numlock_enabled) {
if (numlock_enabled) {
if (led_mode != LED_SPECIAL_MODE_NUMLOCK) {
stored_led_mode = led_mode;
}
led_mode = LED_SPECIAL_MODE_NUMLOCK;
}
if (!numlock_enabled &&
led_mode == LED_SPECIAL_MODE_NUMLOCK
) {
led_mode = stored_led_mode;
}
if (led_mode != last_led_mode) { if (led_mode != last_led_mode) {
initialize_led_mode(led_mode); initialize_led_mode(led_mode);
} }
@ -132,7 +150,8 @@ void update_leds() {
led_effect_chase_update(); led_effect_chase_update();
} else if (led_mode == LED_MODE_STEADY) { } else if (led_mode == LED_MODE_STEADY) {
led_effect_steady_update(); led_effect_steady_update();
} else if (led_mode == LED_SPECIAL_MODE_NUMLOCK) {
led_effect_numlock_update();
} }
@ -140,13 +159,23 @@ void update_leds() {
} }
void led_effect_numlock_update() {
for (int i = 0; i < 44; i++) {
LED.set_crgb_at(i, led_off);
}
for (int i = 44; i < LED_COUNT; i++) {
LED.set_crgb_at(i, led_bright_red);
}
led_compute_breath();
LED.set_crgb_at(60, led_breathe); // make numlock breathe
LED.sync();
}
void led_effect_steady_update() { void led_effect_steady_update() {
LED.sync(); LED.sync();
} }
void led_compute_breath() {
void led_effect_breathe_update() {
// algorithm from http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/ // algorithm from http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/
breathe_brightness = (exp(sin(millis()/2000.0*PI)) - 0.36787944)*108.0; breathe_brightness = (exp(sin(millis()/2000.0*PI)) - 0.36787944)*108.0;
// change the brightness for next time through the loop: // change the brightness for next time through the loop:
@ -159,6 +188,10 @@ void led_effect_breathe_update() {
led_breathe.SetHSV(200, 255, breathe_brightness); led_breathe.SetHSV(200, 255, breathe_brightness);
}
void led_effect_breathe_update() {
led_compute_breath();
set_all_leds_to(led_breathe); set_all_leds_to(led_breathe);
LED.sync(); LED.sync();
} }

@ -11,6 +11,7 @@
#define LED_MODE_HEATMAP 5 #define LED_MODE_HEATMAP 5
#define LED_MODE_CHASE 6 #define LED_MODE_CHASE 6
#define LED_SPECIAL_MODE_NUMLOCK 100
#define LED_DATA_PIN 4 #define LED_DATA_PIN 4
#define LED_COUNT 64 #define LED_COUNT 64
@ -26,7 +27,7 @@ static const int key_led_map[4][16] =
void setup_leds(); void setup_leds();
void update_leds(); void update_leds(int numlock_enabled);
void set_all_leds_to(cRGB color); void set_all_leds_to(cRGB color);
void set_led_mode(int mode); void set_led_mode(int mode);
@ -36,6 +37,7 @@ byte key_to_led(byte row, byte col);
void set_key_color(byte row, byte col); void set_key_color(byte row, byte col);
cRGB get_key_color(byte row, byte col); cRGB get_key_color(byte row, byte col);
void led_compute_breath();
void led_effect_breathe_init(); void led_effect_breathe_init();
void led_effect_rainbow_init(); void led_effect_rainbow_init();
void led_effect_chase_init(); void led_effect_chase_init();
@ -47,6 +49,8 @@ void led_effect_rainbow_update();
void led_effect_rainbow_wave_update(); void led_effect_rainbow_wave_update();
void led_effect_chase_update(); void led_effect_chase_update();
void led_effect_steady_update(); void led_effect_steady_update();
void led_Effect_heatmap_update(); void led_effect_heatmap_update();
void led_effect_numlock_update();
#endif #endif

Loading…
Cancel
Save