qmk

QMK Firmware
git clone git://git.z3bra.org/qmk.git
Log | Files | Refs | Submodules | LICENSE

backlight.h (1732B)


      1 /*
      2 Copyright 2013 Mathias Andersson <wraul@dbox.se>
      3 
      4 This program is free software: you can redistribute it and/or modify
      5 it under the terms of the GNU General Public License as published by
      6 the Free Software Foundation, either version 2 of the License, or
      7 (at your option) any later version.
      8 
      9 This program is distributed in the hope that it will be useful,
     10 but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12 GNU General Public License for more details.
     13 
     14 You should have received a copy of the GNU General Public License
     15 along with this program.  If not, see <http://www.gnu.org/licenses/>.
     16 */
     17 
     18 #pragma once
     19 
     20 #include <stdint.h>
     21 #include <stdbool.h>
     22 
     23 #ifndef BACKLIGHT_LEVELS
     24 #    define BACKLIGHT_LEVELS 3
     25 #elif BACKLIGHT_LEVELS > 31
     26 #    error "Maximum value of BACKLIGHT_LEVELS is 31"
     27 #endif
     28 
     29 typedef union {
     30     uint8_t raw;
     31     struct {
     32         bool    enable : 1;
     33         bool    breathing : 1;
     34         uint8_t reserved : 1;  // Reserved for possible future backlight modes
     35         uint8_t level : 5;
     36     };
     37 } backlight_config_t;
     38 
     39 void    backlight_init(void);
     40 void    backlight_increase(void);
     41 void    backlight_decrease(void);
     42 void    backlight_toggle(void);
     43 void    backlight_enable(void);
     44 void    backlight_disable(void);
     45 bool    is_backlight_enabled(void);
     46 void    backlight_step(void);
     47 void    backlight_set(uint8_t level);
     48 void    backlight_level(uint8_t level);
     49 uint8_t get_backlight_level(void);
     50 
     51 #ifdef BACKLIGHT_BREATHING
     52 void backlight_toggle_breathing(void);
     53 void backlight_enable_breathing(void);
     54 void backlight_disable_breathing(void);
     55 bool is_backlight_breathing(void);
     56 void breathing_enable(void);
     57 void breathing_disable(void);
     58 #endif