Add RGB code (from ps2avrgb and luizribeiro/qmk_firmware)
This commit is contained in:
parent
a8a02455f5
commit
c7ebb0f950
1 changed files with 49 additions and 53 deletions
|
@ -15,7 +15,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "mechmini.h"
|
#include "mechmini.h"
|
||||||
#include "rgblight.h"
|
#include "rgblight.h"
|
||||||
#include "action_layer.h"
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
|
|
||||||
#define MAX_BRIGHTNESS 15
|
#define MAX_BRIGHTNESS 15
|
||||||
|
@ -35,7 +34,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
KC_LCTL, KC_LGUI, KC_LALT, _____, KC_SPC, _____, MO(_FN1), MO(_FN3)
|
KC_LCTL, KC_LGUI, KC_LALT, _____, KC_SPC, _____, MO(_FN1), MO(_FN3)
|
||||||
),
|
),
|
||||||
[_FN1] = KEYMAP(
|
[_FN1] = KEYMAP(
|
||||||
_____, _____, KC_UP, KC_MUTE, KC_VOLD, KC_VOLU, KC_MRWD, KC_MPLY, KC_MFFD, KC_SLCK, KC_PAUS, KC_DEL,
|
KC_GRAVE, _____, KC_UP, KC_MUTE, KC_VOLD, KC_VOLU, KC_MRWD, KC_MPLY, KC_MFFD, KC_SLCK, KC_PAUS, KC_DEL,
|
||||||
KC_CAPS, KC_LEFT, KC_DOWN, KC_RIGHT, _____, _____, _____, KC_INS, KC_HOME, KC_PGUP, KC_PSCR,
|
KC_CAPS, KC_LEFT, KC_DOWN, KC_RIGHT, _____, _____, _____, KC_INS, KC_HOME, KC_PGUP, KC_PSCR,
|
||||||
_____, _____, M(0), M(1), M(2), _____, _____, KC_END, KC_PGDN, _____, _____,
|
_____, _____, M(0), M(1), M(2), _____, _____, KC_END, KC_PGDN, _____, _____,
|
||||||
_____, _____, _____, _____, _____, _____, _____, _____
|
_____, _____, _____, _____, _____, _____, _____, _____
|
||||||
|
@ -74,65 +73,62 @@ uint8_t b = 0xFF;
|
||||||
uint8_t max_brightness = MAX_BRIGHTNESS_IOS;
|
uint8_t max_brightness = MAX_BRIGHTNESS_IOS;
|
||||||
|
|
||||||
enum macro_id {
|
enum macro_id {
|
||||||
TOGGLE_RGB,
|
TOGGLE_RGB,
|
||||||
RGB_LEVEL_DOWN,
|
BRIGHTNESS_DOWN,
|
||||||
RGB_LEVEL_UP,
|
BRIGHTNESS_UP,
|
||||||
RGB_PURPLE,
|
COLOR_1,
|
||||||
RGB_CYAN,
|
COLOR_2,
|
||||||
RGB_WHITE,
|
COLOR_3,
|
||||||
ENABLE_MAX_BRIGHTNESS
|
ENABLE_MAX_BRIGHTNESS
|
||||||
};
|
};
|
||||||
|
|
||||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
|
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
|
||||||
keyevent_t event = record->event;
|
keyevent_t event = record->event;
|
||||||
|
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case TOGGLE_RGB:
|
case TOGGLE_RGB:
|
||||||
if (event.pressed) {
|
if (event.pressed) {
|
||||||
if (!is_on) {
|
if (!is_on) {
|
||||||
current_level = 2;
|
current_level = 4;
|
||||||
is_on = 1;
|
is_on = 1;
|
||||||
} else {
|
} else {
|
||||||
is_on = 0;
|
is_on = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case RGB_LEVEL_DOWN:
|
case BRIGHTNESS_DOWN:
|
||||||
if (event.pressed && current_level > 0) {
|
if (event.pressed && current_level > 0) {
|
||||||
current_level--;
|
current_level--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RGB_LEVEL_UP:
|
case BRIGHTNESS_UP:
|
||||||
if (event.pressed && current_level < max_brightness) {
|
if (event.pressed && current_level < max_brightness) {
|
||||||
current_level++;
|
current_level++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RGB_PURPLE:
|
case COLOR_1: // set to pink
|
||||||
r = 0xFF;
|
r = 0xFF;
|
||||||
g = 0x81;
|
g = 0x81;
|
||||||
b = 0xC2;
|
b = 0xC2;
|
||||||
break;
|
break;
|
||||||
case RGB_CYAN:
|
case COLOR_2: // set to cyan
|
||||||
r = 0x00;
|
r = 0x00;
|
||||||
g = 0xE0;
|
g = 0xE0;
|
||||||
b = 0xFF;
|
b = 0xFF;
|
||||||
break;
|
break;
|
||||||
case RGB_WHITE:
|
case COLOR_3: // set to white
|
||||||
r = 0xFF;
|
r = 0xFF;
|
||||||
g = 0xFF;
|
g = 0xFF;
|
||||||
b = 0xFF;
|
b = 0xFF;
|
||||||
break;
|
break;
|
||||||
case ENABLE_MAX_BRIGHTNESS:
|
case ENABLE_MAX_BRIGHTNESS: // enable all 16 brightness steps
|
||||||
max_brightness = MAX_BRIGHTNESS;
|
max_brightness = MAX_BRIGHTNESS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return MACRO_NONE;
|
return MACRO_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint16_t fn_actions[] PROGMEM = {
|
const uint16_t fn_actions[] PROGMEM = {
|
||||||
[0] = ACTION_MACRO(TOGGLE_RGB),
|
|
||||||
[1] = ACTION_MACRO(RGB_LEVEL_DOWN),
|
|
||||||
[2] = ACTION_MACRO(RGB_LEVEL_UP)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b);
|
void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b);
|
||||||
|
|
Loading…
Reference in a new issue