logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

backlight.h (2493B)


  1. /*
  2. Copyright 2013 Mathias Andersson <wraul@dbox.se>
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #pragma once
  15. #include <stdint.h>
  16. #include <stdbool.h>
  17. #include "compiler_support.h"
  18. #ifndef BACKLIGHT_LEVELS
  19. # define BACKLIGHT_LEVELS 3
  20. #elif BACKLIGHT_LEVELS > 31
  21. # error "Maximum value of BACKLIGHT_LEVELS is 31"
  22. #endif
  23. #ifndef BACKLIGHT_ON_STATE
  24. # define BACKLIGHT_ON_STATE 1
  25. #endif
  26. #ifndef BREATHING_PERIOD
  27. # define BREATHING_PERIOD 6
  28. #endif
  29. typedef union backlight_config_t {
  30. uint8_t raw;
  31. struct {
  32. bool enable : 1;
  33. bool breathing : 1;
  34. bool valid : 1;
  35. uint8_t level : 5;
  36. };
  37. } backlight_config_t;
  38. STATIC_ASSERT(sizeof(backlight_config_t) == sizeof(uint8_t), "Backlight EECONFIG out of spec.");
  39. void backlight_init(void);
  40. void backlight_toggle(void);
  41. void backlight_enable(void);
  42. void backlight_disable(void);
  43. bool is_backlight_enabled(void);
  44. void backlight_step(void);
  45. void backlight_increase(void);
  46. void backlight_decrease(void);
  47. void backlight_level_noeeprom(uint8_t level);
  48. void backlight_level(uint8_t level);
  49. uint8_t get_backlight_level(void);
  50. void eeconfig_update_backlight_current(void);
  51. void eeconfig_update_backlight_default(void);
  52. // implementation specific
  53. void backlight_init_ports(void);
  54. void backlight_set(uint8_t level);
  55. void backlight_task(void);
  56. #ifdef BACKLIGHT_BREATHING
  57. void backlight_toggle_breathing(void);
  58. void backlight_enable_breathing(void);
  59. void backlight_disable_breathing(void);
  60. bool is_backlight_breathing(void);
  61. void breathing_period_set(uint8_t value);
  62. uint8_t get_breathing_period(void);
  63. void breathing_period_default(void);
  64. void breathing_period_inc(void);
  65. void breathing_period_dec(void);
  66. void breathing_toggle(void);
  67. // implementation specific
  68. void breathing_enable(void);
  69. void breathing_disable(void);
  70. bool is_breathing(void);
  71. void breathing_pulse(void);
  72. #endif