Update Fraja PR

This commit is contained in:
Wolf 2023-06-22 01:39:06 +02:00
parent 87a51eb9e7
commit f8b5260903
4 changed files with 5 additions and 195 deletions

View File

@ -8,8 +8,6 @@
#define WS2812_PIO_USE_PIO1
#define RGB_MATRIX_LED_COUNT 102
#define RGB_DI_PIN GP29
#define WS2812_DI_PIN GP29
#define RGB_DISABLE_WHEN_USB_SUSPENDED
#define RGB_MATRIX_KEYPRESSES

View File

@ -19,6 +19,9 @@
"rows": ["GP4", "GP3", "GP2", "GP1", "GP0"]
},
"processor": "RP2040",
"ws2812": {
"pin": "GP29"
},
"rgb_matrix": {
"driver": "WS2812",
"layout": [

View File

@ -35,188 +35,4 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_VOLD, KC_MNXT
)
};
// Single Indicator memory layout
typedef struct _indicator_config_t {
uint8_t h;
uint8_t s;
uint8_t v;
bool enabled;
} indicator_config;
// Led State Config
typedef enum {
LED_STATE_ALL,
LED_STATE_BACKLIGHT,
LED_STATE_UNDERGLOW,
LED_STATE_INDICATORS
} led_states;
// Board memory layout
typedef struct _customKB_config_t {
led_states leds;
indicator_config caps;
} customKB_config;
customKB_config customKB;
void eeconfig_init_user(void) {
customKB.leds = LED_STATE_ALL;
// Default values
customKB.caps.h = 128;
customKB.caps.s = 128;
customKB.caps.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS / 2;
customKB.caps.enabled = true;
// Write default value to EEPROM now
eeconfig_update_kb_datablock(&customKB);
}
enum via_customKB {
id_leds_state = 1,
id_caps_indicator_enabled = 2,
id_caps_indicator_brightness = 3,
id_caps_indicator_color = 4
};
//On Keyboard startup
void keyboard_post_init_user(void) {
//Read our custom menu variables from memory
eeconfig_read_kb_datablock(&customKB);
}
void set_caps_lock_led(void) {
if (customKB.caps.enabled) {
// The rgb_matrix_set_color function needs an RGB code to work, so first the indicator color is cast to an HSV value and then translated to RGB
HSV hsv_caps_indicator_color = {customKB.caps.h, customKB.caps.s, customKB.caps.v};
RGB rgb_caps_indicator_color = hsv_to_rgb(hsv_caps_indicator_color);
if (host_keyboard_led_state().caps_lock)
rgb_matrix_set_color(CAPS_INDICATOR_INDEX, rgb_caps_indicator_color.r, rgb_caps_indicator_color.g, rgb_caps_indicator_color.b);
}
}
bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
switch(customKB.leds){
case LED_STATE_ALL:
set_caps_lock_led();
return true;
case LED_STATE_BACKLIGHT:
for (uint8_t i = led_min; i < led_max; i++) {
if (!HAS_FLAGS(g_led_config.flags[i], LED_FLAG_KEYLIGHT)) {
rgb_matrix_set_color(i, 0, 0, 0);
}
}
set_caps_lock_led();
return true;
case LED_STATE_UNDERGLOW:
for (uint8_t i = led_min; i < led_max; i++) {
if (!HAS_FLAGS(g_led_config.flags[i], LED_FLAG_UNDERGLOW)) {
rgb_matrix_set_color(i, 0, 0, 0);
}
}
set_caps_lock_led();
return true;
case LED_STATE_INDICATORS:
for (uint8_t i = led_min; i < led_max; i++) {
rgb_matrix_set_color(i, 0, 0, 0);
}
set_caps_lock_led();
return true;
}
return true;
}
void customKB_config_set_value(uint8_t *data) {
// data = [ value_id, value_data ]
uint8_t *value_id = &(data[0]);
uint8_t *value_data = &(data[1]);
switch (*value_id) {
case id_caps_indicator_enabled: {
customKB.caps.enabled = value_data[0];
break;
}
case id_caps_indicator_brightness: {
customKB.caps.v = value_data[0];
break;
}
case id_caps_indicator_color: {
customKB.caps.h = value_data[0];
customKB.caps.s = value_data[1];
break;
}
case id_leds_state: {
customKB.leds = value_data[0];
break;
}
}
}
void customKB_config_get_value(uint8_t *data) {
// data = [ value_id, value_data ]
uint8_t *value_id = &(data[0]);
uint8_t *value_data = &(data[1]);
switch (*value_id) {
case id_caps_indicator_enabled: {
value_data[0] = customKB.caps.enabled;
break;
}
case id_caps_indicator_brightness: {
value_data[0] = customKB.caps.v;
break;
}
case id_caps_indicator_color: {
value_data[0] = customKB.caps.h;
value_data[1] = customKB.caps.s;
break;
}
case id_leds_state: {
value_data[0] = customKB.leds;
break;
}
}
}
void customKB_config_save(void) {
eeconfig_update_kb_datablock(&customKB);
}
void via_custom_value_command_kb(uint8_t *data, uint8_t length) {
// data = [ command_id, channel_id, value_id, value_data ]
uint8_t *command_id = &(data[0]);
uint8_t *channel_id = &(data[1]);
uint8_t *value_id_and_data = &(data[2]);
if (*channel_id == id_custom_channel) {
switch (*command_id) {
case id_custom_set_value: {
customKB_config_set_value(value_id_and_data);
break;
}
case id_custom_get_value: {
customKB_config_get_value(value_id_and_data);
break;
}
case id_custom_save: {
customKB_config_save();
break;
}
default: {
// Unhandled message.
*command_id = id_unhandled;
break;
}
}
return;
}
*command_id = id_unhandled;
}
};

View File

@ -1,6 +1,6 @@
# Freja 65
![Freja 65](https://cdn.shopify.com/s/files/1/0435/8311/1331/products/image_1024x1024@2x.heic?v=1677804197)
![Freja 65](https://i.imgur.com/SGV0j4A.jpeg)
The following is the QMK Firmware for the Freja 65 PCB.
@ -8,13 +8,6 @@ The following is the QMK Firmware for the Freja 65 PCB.
* Hardware Supported: Freja65 PCB
* Hardware Availability: https://www.helheim.design/collections/freja65-collection/products/65-soldered-pcb
The PCB features:
* QMK & VIA compatibility
* Underglow RGB Leds
* Per key RGB Leds
---
Make example for this keyboard (after setting up your build environment):
make wolf/freja65:default