You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

71 lines
2.2 KiB

/* Copyright 2021 Mikael Manukyan <arm.localhost@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "rgb_matrix_ledmaps.h"
__attribute__((weak)) bool rgb_matrix_indicators_keymap(void) { return true; }
__attribute__((weak)) bool rgb_matrix_indicators_advanced_keymap(uint8_t led_min, uint8_t led_max) {
return true;
}
#ifdef RGB_MATRIX_LEDMAPS_ENABLED
static bool enabled = true;
#endif // RGB_MATRIX_LEDMAPS_ENABLED
bool rgb_matrix_indicators_user(void) { return rgb_matrix_indicators_keymap(); }
bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
#ifdef RGB_MATRIX_LEDMAPS_ENABLED
if (rgb_matrix_is_enabled() && enabled) {
set_layer_rgb(led_min, led_max, get_highest_layer(layer_state | default_layer_state));
}
#endif // RGB_MATRIX_LEDMAPS_ENABLED
return rgb_matrix_indicators_advanced_keymap(led_min, led_max);
}
#ifdef RGB_MATRIX_LEDMAPS_ENABLED
void set_layer_rgb(uint8_t led_min, uint8_t led_max, int layer) {
const ledmap *l = &(ledmaps[layer]);
uint8_t val = rgb_matrix_get_val();
for (int i = 0; i < RGB_MATRIX_LED_COUNT; i++) {
HSV hsv = {
.h = (*l)[i][0],
.s = (*l)[i][1],
.v = val,
};
if (hsv.h || hsv.s) {
RGB rgb = hsv_to_rgb(hsv);
RGB_MATRIX_INDICATOR_SET_COLOR(i, rgb.r, rgb.g, rgb.b);
}
}
}
void rgb_matrix_layers_enable(void) {
dprintf("ledmaps are enabled\n");
enabled = true;
}
void rgb_matrix_layers_disable(void) {
dprintf("ledmaps are disabled\n");
enabled = false;
}
#endif // RGB_MATRIX_LEDMAPS_ENABLED