qmk_firmware

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

backlight.h (2493B)


      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 #include "compiler_support.h"
     24 
     25 #ifndef BACKLIGHT_LEVELS
     26 #    define BACKLIGHT_LEVELS 3
     27 #elif BACKLIGHT_LEVELS > 31
     28 #    error "Maximum value of BACKLIGHT_LEVELS is 31"
     29 #endif
     30 
     31 #ifndef BACKLIGHT_ON_STATE
     32 #    define BACKLIGHT_ON_STATE 1
     33 #endif
     34 
     35 #ifndef BREATHING_PERIOD
     36 #    define BREATHING_PERIOD 6
     37 #endif
     38 
     39 typedef union backlight_config_t {
     40     uint8_t raw;
     41     struct {
     42         bool    enable : 1;
     43         bool    breathing : 1;
     44         bool    valid : 1;
     45         uint8_t level : 5;
     46     };
     47 } backlight_config_t;
     48 
     49 STATIC_ASSERT(sizeof(backlight_config_t) == sizeof(uint8_t), "Backlight EECONFIG out of spec.");
     50 
     51 void    backlight_init(void);
     52 void    backlight_toggle(void);
     53 void    backlight_enable(void);
     54 void    backlight_disable(void);
     55 bool    is_backlight_enabled(void);
     56 void    backlight_step(void);
     57 void    backlight_increase(void);
     58 void    backlight_decrease(void);
     59 void    backlight_level_noeeprom(uint8_t level);
     60 void    backlight_level(uint8_t level);
     61 uint8_t get_backlight_level(void);
     62 
     63 void eeconfig_update_backlight_current(void);
     64 void eeconfig_update_backlight_default(void);
     65 
     66 // implementation specific
     67 void backlight_init_ports(void);
     68 void backlight_set(uint8_t level);
     69 void backlight_task(void);
     70 
     71 #ifdef BACKLIGHT_BREATHING
     72 
     73 void backlight_toggle_breathing(void);
     74 void backlight_enable_breathing(void);
     75 void backlight_disable_breathing(void);
     76 bool is_backlight_breathing(void);
     77 
     78 void    breathing_period_set(uint8_t value);
     79 uint8_t get_breathing_period(void);
     80 void    breathing_period_default(void);
     81 void    breathing_period_inc(void);
     82 void    breathing_period_dec(void);
     83 
     84 void breathing_toggle(void);
     85 
     86 // implementation specific
     87 void breathing_enable(void);
     88 void breathing_disable(void);
     89 bool is_breathing(void);
     90 void breathing_pulse(void);
     91 #endif