mirror of
https://github.com/openstenoproject/qmk
synced 2024-11-09 18:19:08 +00:00
rgb light through midi
This commit is contained in:
parent
530dd3377e
commit
3774a7fcda
26 changed files with 126 additions and 31 deletions
|
@ -67,7 +67,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/
|
||||
|
||||
#define RGB_DI_PIN E2
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 8 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 10
|
||||
#define RGBLIGHT_SAT_STEP 17
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
/* Underlight configuration
|
||||
*/
|
||||
#define RGB_DI_PIN B2
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 14 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 10
|
||||
#define RGBLIGHT_SAT_STEP 17
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
/* Underlight configuration
|
||||
*/
|
||||
#define RGB_DI_PIN D7
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 14 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 10
|
||||
#define RGBLIGHT_SAT_STEP 17
|
||||
|
|
|
@ -140,7 +140,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
/* Underlight configuration
|
||||
*/
|
||||
#define RGB_DI_PIN E6
|
||||
//#define RGBLIGHT_TIMER
|
||||
//#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 4 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 10
|
||||
#define RGBLIGHT_SAT_STEP 17
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "../../config.h"
|
||||
|
||||
// place overrides here
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLIGHT_EFFECT_SNAKE_LENGTH 3
|
||||
#define RGBLIGHT_EFFECT_KNIGHT_LENGTH 2
|
||||
#define RGBLIGHT_EFFECT_KNIGHT_OFFSET 2
|
||||
|
|
|
@ -70,7 +70,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
/* Underlight configuration
|
||||
*/
|
||||
#define RGB_DI_PIN F6
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 4 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 10
|
||||
#define RGBLIGHT_SAT_STEP 17
|
||||
|
|
|
@ -5,12 +5,13 @@
|
|||
|
||||
/* ws2812 RGB LED */
|
||||
#define RGB_DI_PIN D7
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 15 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 12
|
||||
#define RGBLIGHT_SAT_STEP 255
|
||||
#define RGBLIGHT_VAL_STEP 12
|
||||
|
||||
#define RGB_MIDI
|
||||
#define RGBW_BB_TWI
|
||||
|
||||
#endif
|
|
@ -182,7 +182,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#define ws2812_pin PF4
|
||||
*/
|
||||
#define RGB_DI_PIN F4
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 8 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 8
|
||||
#define RGBLIGHT_SAT_STEP 8
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
/* ws2812 RGB LED */
|
||||
#define RGB_DI_PIN D5
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 13 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 10
|
||||
#define RGBLIGHT_SAT_STEP 17
|
||||
|
|
|
@ -70,7 +70,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
)
|
||||
|
||||
#define RGB_DI_PIN D3
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 12 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 8
|
||||
#define RGBLIGHT_SAT_STEP 8
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/* WS2812B RGB Underglow LED */
|
||||
#define RGB_DI_PIN F5 // Based on wiring depicted in ws2812_wiring.jpg
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 16 // Number of LEDs. Change this to match your use case.
|
||||
#define RGBLIGHT_HUE_STEP 8
|
||||
#define RGBLIGHT_SAT_STEP 8
|
||||
|
|
|
@ -75,7 +75,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
/* ws2812 RGB LED */
|
||||
#define RGB_DI_PIN D4
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 8 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 10
|
||||
#define RGBLIGHT_SAT_STEP 17
|
||||
|
|
|
@ -75,7 +75,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
/* ws2812 RGB LED */
|
||||
#define RGB_DI_PIN D4
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 8 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 10
|
||||
#define RGBLIGHT_SAT_STEP 17
|
||||
|
|
|
@ -75,7 +75,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
/* ws2812 RGB LED */
|
||||
#define RGB_DI_PIN D4
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 8 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 10
|
||||
#define RGBLIGHT_SAT_STEP 17
|
||||
|
|
|
@ -63,7 +63,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
/* Underlight configuration
|
||||
*/
|
||||
#define RGB_DI_PIN E2
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 20 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 10
|
||||
#define RGBLIGHT_SAT_STEP 17
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
/* ws2812 RGB LED */
|
||||
#define RGB_DI_PIN B1
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 8 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 10
|
||||
#define RGBLIGHT_SAT_STEP 17
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
/* ws2812 RGB LED */
|
||||
#define RGB_DI_PIN D1
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 28 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 10
|
||||
#define RGBLIGHT_SAT_STEP 17
|
||||
|
|
|
@ -63,7 +63,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
/* ws2812 RGB LED */
|
||||
#define RGB_DI_PIN D1
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 28 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 10
|
||||
#define RGBLIGHT_SAT_STEP 17
|
||||
|
|
|
@ -63,7 +63,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
/* ws2812 RGB LED */
|
||||
#define RGB_DI_PIN D1
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 28 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 10
|
||||
#define RGBLIGHT_SAT_STEP 17
|
||||
|
|
|
@ -67,7 +67,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/
|
||||
|
||||
#define RGB_DI_PIN E2
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 8 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 10
|
||||
#define RGBLIGHT_SAT_STEP 17
|
||||
|
|
|
@ -67,7 +67,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/
|
||||
|
||||
/*#define RGB_DI_PIN E2
|
||||
#define RGBLIGHT_TIMER
|
||||
#define RGBLIGHT_ANIMATIONS
|
||||
#define RGBLED_NUM 2 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 10
|
||||
#define RGBLIGHT_SAT_STEP 17
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
#include <util/delay.h>
|
||||
#include "debug.h"
|
||||
|
||||
#define RGBW_BB_TWI 1
|
||||
|
||||
#ifdef RGBW_BB_TWI
|
||||
|
||||
// Port for the I2C
|
||||
|
|
|
@ -174,7 +174,7 @@ void rgblight_init(void) {
|
|||
}
|
||||
eeconfig_debug_rgblight(); // display current eeprom values
|
||||
|
||||
#if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
|
||||
#ifdef RGBLIGHT_ANIMATIONS
|
||||
rgblight_timer_init(); // setup the timer
|
||||
#endif
|
||||
|
||||
|
@ -221,7 +221,7 @@ void rgblight_mode(uint8_t mode) {
|
|||
eeconfig_update_rgblight(rgblight_config.raw);
|
||||
xprintf("rgblight mode: %u\n", rgblight_config.mode);
|
||||
if (rgblight_config.mode == 1) {
|
||||
#if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
|
||||
#ifdef RGBLIGHT_ANIMATIONS
|
||||
rgblight_timer_disable();
|
||||
#endif
|
||||
} else if (rgblight_config.mode >= 2 && rgblight_config.mode <= 23) {
|
||||
|
@ -231,7 +231,7 @@ void rgblight_mode(uint8_t mode) {
|
|||
// MODE 15-20, snake
|
||||
// MODE 21-23, knight
|
||||
|
||||
#if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
|
||||
#ifdef RGBLIGHT_ANIMATIONS
|
||||
rgblight_timer_enable();
|
||||
#endif
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ void rgblight_toggle(void) {
|
|||
if (rgblight_config.enable) {
|
||||
rgblight_mode(rgblight_config.mode);
|
||||
} else {
|
||||
#if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
|
||||
#ifdef RGBLIGHT_ANIMATIONS
|
||||
rgblight_timer_disable();
|
||||
#endif
|
||||
_delay_ms(50);
|
||||
|
@ -371,7 +371,7 @@ void rgblight_set(void) {
|
|||
}
|
||||
}
|
||||
|
||||
#if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
|
||||
#ifdef RGBLIGHT_ANIMATIONS
|
||||
|
||||
// Animation timer -- AVR Timer3
|
||||
void rgblight_timer_init(void) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef RGBLIGHT_H
|
||||
#define RGBLIGHT_H
|
||||
|
||||
#if !defined(AUDIO_ENABLE) && defined(RGBLIGHT_TIMER)
|
||||
#ifdef RGBLIGHT_ANIMATIONS
|
||||
#define RGBLIGHT_MODES 23
|
||||
#else
|
||||
#define RGBLIGHT_MODES 1
|
||||
|
|
|
@ -1135,12 +1135,12 @@ For this mod, you need an unused pin wiring to DI of WS2812 strip. After wiring
|
|||
|
||||
RGBLIGHT_ENABLE = yes
|
||||
|
||||
In order to use the underglow timer functions, you need to have `#define RGBLIGHT_TIMER` in your `config.h`, and have audio disabled (`AUDIO_ENABLE = no` in your Makefile).
|
||||
In order to use the underglow animation functions, you need to have `#define RGBLIGHT_ANIMATIONS` in your `config.h`.
|
||||
|
||||
Please add the following options into your config.h, and set them up according your hardware configuration. These settings are for the `F4` pin by default:
|
||||
|
||||
#define RGB_DI_PIN F4 // The pin your RGB strip is wired to
|
||||
#define RGBLIGHT_TIMER // Require for fancier stuff (not compatible with audio)
|
||||
#define RGBLIGHT_ANIMATIONS // Require for fancier stuff (not compatible with audio)
|
||||
#define RGBLED_NUM 14 // Number of LEDs
|
||||
#define RGBLIGHT_HUE_STEP 10
|
||||
#define RGBLIGHT_SAT_STEP 17
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
|
||||
#include "descriptor.h"
|
||||
#include "lufa.h"
|
||||
#include "quantum.h"
|
||||
|
||||
#ifdef NKRO_ENABLE
|
||||
#include "keycode_config.h"
|
||||
|
@ -1111,9 +1112,104 @@ void cc_callback(MidiDevice * device,
|
|||
#endif
|
||||
}
|
||||
|
||||
void send_dword(uint32_t number) {
|
||||
uint16_t word = (number >> 16);
|
||||
send_word(word);
|
||||
send_word(number & 0xFFFFUL);
|
||||
}
|
||||
|
||||
void send_word(uint16_t number) {
|
||||
uint8_t byte = number >> 8;
|
||||
send_byte(byte);
|
||||
send_byte(number & 0xFF);
|
||||
}
|
||||
|
||||
void send_byte(uint8_t number) {
|
||||
uint8_t nibble = number >> 4;
|
||||
send_nibble(nibble);
|
||||
send_nibble(number & 0xF);
|
||||
}
|
||||
|
||||
void send_nibble(uint8_t number) {
|
||||
switch (number) {
|
||||
case 0:
|
||||
register_code(KC_0);
|
||||
unregister_code(KC_0);
|
||||
break;
|
||||
case 1 ... 9:
|
||||
register_code(KC_1 + (number - 1));
|
||||
unregister_code(KC_1 + (number - 1));
|
||||
break;
|
||||
case 0xA ... 0xF:
|
||||
register_code(KC_A + (number - 0xA));
|
||||
unregister_code(KC_A + (number - 0xA));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t midi_buffer[16] = {0};
|
||||
|
||||
void sysex_callback(MidiDevice * device,
|
||||
uint16_t start, uint8_t length, uint8_t * data) {
|
||||
// for (int i = 0; i < length; i++)
|
||||
// midi_send_cc(device, 15, 0x7F & data[i], 0x7F & (start + i));
|
||||
// if (start == 0x27) {
|
||||
// SEND_STRING("\n");
|
||||
// send_word(start);
|
||||
// SEND_STRING(": ");
|
||||
for (uint8_t place = 0; place < length; place++) {
|
||||
// send_byte(*data);
|
||||
midi_buffer[start + place] = *data;
|
||||
if (*data == 0xF7)
|
||||
sysex_buffer_callback(start + place, &midi_buffer);
|
||||
// SEND_STRING(" ");
|
||||
data++;
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
void sysex_buffer_callback(uint8_t length, uint8_t * data) {
|
||||
uint8_t * pointer_copy = data;
|
||||
|
||||
if (*data++ != 0xF0)
|
||||
return
|
||||
data++;
|
||||
data++;
|
||||
data++;
|
||||
data++;
|
||||
|
||||
switch (*data++) {
|
||||
case 0x27: ; // RGB LED functions
|
||||
switch (*data++)
|
||||
case 0x00: ; // Update HSV
|
||||
uint32_t part1 = *data++;
|
||||
uint32_t part2 = *data++;
|
||||
uint32_t part3 = *data++;
|
||||
uint32_t part4 = *data++;
|
||||
uint32_t part5 = *data++;
|
||||
uint32_t chunk = ((part1 & 0x1FUL) << 28) | (part2 << 21) | (part3 << 14) | (part4 << 7) | part5;
|
||||
// SEND_STRING("\nCHUNK: ");
|
||||
// send_dword(chunk);
|
||||
rgblight_sethsv(((chunk >> 16) & 0xFFFF) % 360, (chunk >> 8) & 0xFF, chunk & 0xFF);
|
||||
// SEND_STRING("\nHUE: ");
|
||||
// send_word(((chunk >> 16) & 0xFFFF) % 360);
|
||||
// SEND_STRING("\nSAT: ");
|
||||
// send_word((chunk >> 8) & 0xFF);
|
||||
// SEND_STRING("\nVAL: ");
|
||||
// send_word(chunk & 0xFF);
|
||||
break;
|
||||
case 0x01: ; // Update RGB
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
// SEND_STRING("\nDATA:\n");
|
||||
// while (*pointer_copy != 0xF7) {
|
||||
// send_byte(*pointer_copy++);
|
||||
// SEND_STRING(" ");
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue