backlight.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #ifndef BACKLIGHT_LEVELS
  18. #define BACKLIGHT_LEVELS 3
  19. #elif BACKLIGHT_LEVELS > 31
  20. #error "Maximum value of BACKLIGHT_LEVELS is 31"
  21. #endif
  22. typedef union {
  23. uint8_t raw;
  24. struct {
  25. bool enable :1;
  26. bool breathing :1;
  27. uint8_t reserved :1; // Reserved for possible future backlight modes
  28. uint8_t level :5;
  29. };
  30. } backlight_config_t;
  31. void backlight_init(void);
  32. void backlight_increase(void);
  33. void backlight_decrease(void);
  34. void backlight_toggle(void);
  35. void backlight_enable(void);
  36. void backlight_disable(void);
  37. bool is_backlight_enabled(void);
  38. void backlight_step(void);
  39. void backlight_set(uint8_t level);
  40. void backlight_level(uint8_t level);
  41. uint8_t get_backlight_level(void);
  42. #ifdef BACKLIGHT_BREATHING
  43. void backlight_toggle_breathing(void);
  44. void backlight_enable_breathing(void);
  45. void backlight_disable_breathing(void);
  46. bool is_backlight_breathing(void);
  47. void breathing_enable(void);
  48. void breathing_disable(void);
  49. #endif