qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

wt_rgb_backlight.h (3898B)


      1 /* Copyright 2017 Jason Williams (Wilba)
      2  *
      3  * This program is free software: you can redistribute it and/or modify
      4  * it under the terms of the GNU General Public License as published by
      5  * the Free Software Foundation, either version 2 of the License, or
      6  * (at your option) any later version.
      7  *
      8  * This program is distributed in the hope that it will be useful,
      9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11  * GNU General Public License for more details.
     12  *
     13  * You should have received a copy of the GNU General Public License
     14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15  */
     16 #pragma once
     17 
     18 #if RGB_BACKLIGHT_ENABLED
     19 #else
     20 #error rgb_backlight.h included when RGB_BACKLIGHT_ENABLED == 0
     21 #endif // RGB_BACKLIGHT_ENABLED
     22 
     23 #include <stdint.h>
     24 #include <stdbool.h>
     25 
     26 #include "action.h"
     27 #include "quantum/color.h"
     28 
     29 typedef struct PACKED
     30 {
     31 	uint8_t h;
     32 	uint8_t s;
     33 } HS;
     34 
     35 typedef struct
     36 {
     37 	HS color;
     38 	uint8_t index;
     39 } backlight_config_indicator;
     40 
     41 #if defined(RGB_BACKLIGHT_M6_B)
     42 #define RGB_BACKLIGHT_CUSTOM_COLORS_COUNT 6
     43 #elif defined(RGB_BACKLIGHT_M10_C)
     44 #define RGB_BACKLIGHT_CUSTOM_COLORS_COUNT 10
     45 #endif
     46 
     47 typedef struct
     48 {
     49 	bool use_split_backspace:1;         // |
     50 	bool use_split_left_shift:1;        // |
     51 	bool use_split_right_shift:1;       // |
     52 	bool use_7u_spacebar:1;             // |
     53 	bool use_iso_enter:1;               // |
     54 	bool disable_when_usb_suspended:1;  // |
     55 	bool disable_hhkb_blocker_leds:1;   // |
     56 	bool __pad7:1;                      // 1 byte
     57 	uint8_t disable_after_timeout;      // 1 byte
     58 	uint8_t brightness;                 // 1 byte
     59 	uint8_t effect;                     // 1 byte
     60 	uint8_t effect_speed;				// 1 byte
     61 	HS color_1;                         // 2 bytes
     62 	HS color_2;                         // 2 bytes
     63 	backlight_config_indicator caps_lock_indicator;	// 3 bytes
     64 	backlight_config_indicator layer_1_indicator;	// 3 bytes
     65 	backlight_config_indicator layer_2_indicator;	// 3 bytes
     66 	backlight_config_indicator layer_3_indicator;	// 3 bytes
     67 	uint16_t alphas_mods[5];            // 10 bytes
     68 #if defined(RGB_BACKLIGHT_M6_B) || defined(RGB_BACKLIGHT_M10_C)
     69 	HS custom_color[RGB_BACKLIGHT_CUSTOM_COLORS_COUNT];                 // 12 or 20 bytes
     70 #endif
     71 } backlight_config;                // = 31 bytes (M6-B = 43 bytes, M10-C 51 bytes)
     72 
     73 void backlight_config_load(void);
     74 void backlight_config_save(void);
     75 void backlight_config_set_value( uint8_t *data );
     76 void backlight_config_get_value( uint8_t *data );
     77 
     78 void backlight_init_drivers(void);
     79 
     80 void backlight_timer_init(void);
     81 void backlight_timer_enable(void);
     82 void backlight_timer_disable(void);
     83 
     84 void backlight_set_suspend_state(bool state);
     85 
     86 // This should not be called from an interrupt
     87 // (eg. from a timer interrupt).
     88 // Call this while idle (in between matrix scans).
     89 // If the buffer is dirty, it will update the driver with the buffer.
     90 void backlight_update_pwm_buffers(void);
     91 
     92 // Handle backlight specific keycodes
     93 bool process_record_backlight(uint16_t keycode, keyrecord_t *record);
     94 
     95 void backlight_set_key_hit(uint8_t row, uint8_t col);
     96 
     97 void backlight_effect_increase(void);
     98 void backlight_effect_decrease(void);
     99 void backlight_effect_speed_increase(void);
    100 void backlight_effect_speed_decrease(void);
    101 
    102 void backlight_brightness_increase(void);
    103 void backlight_brightness_decrease(void);
    104 
    105 void backlight_color_1_hue_increase(void);
    106 void backlight_color_1_hue_decrease(void);
    107 void backlight_color_1_sat_increase(void);
    108 void backlight_color_1_sat_decrease(void);
    109 void backlight_color_2_hue_increase(void);
    110 void backlight_color_2_hue_decrease(void);
    111 void backlight_color_2_sat_increase(void);
    112 void backlight_color_2_sat_decrease(void);
    113 
    114 void backlight_test_led( uint8_t index, bool red, bool green, bool blue );
    115 void backlight_debug_led(bool state);
    116 void backlight_device_indication(uint8_t value);