backlight.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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_enable_noeeprom(void);
  43. void backlight_disable(void);
  44. void backlight_disable_noeeprom(void);
  45. bool is_backlight_enabled(void);
  46. void backlight_step(void);
  47. void backlight_increase(void);
  48. void backlight_decrease(void);
  49. void backlight_level_noeeprom(uint8_t level);
  50. void backlight_level(uint8_t level);
  51. uint8_t get_backlight_level(void);
  52. void eeconfig_update_backlight_current(void);
  53. void eeconfig_update_backlight_default(void);
  54. // implementation specific
  55. void backlight_init_ports(void);
  56. void backlight_set(uint8_t level);
  57. void backlight_task(void);
  58. #ifdef BACKLIGHT_BREATHING
  59. void backlight_toggle_breathing(void);
  60. void backlight_enable_breathing(void);
  61. void backlight_disable_breathing(void);
  62. bool is_backlight_breathing(void);
  63. void breathing_period_set(uint8_t value);
  64. uint8_t get_breathing_period(void);
  65. void breathing_period_default(void);
  66. void breathing_period_inc(void);
  67. void breathing_period_dec(void);
  68. void breathing_toggle(void);
  69. // implementation specific
  70. void breathing_enable(void);
  71. void breathing_disable(void);
  72. bool is_breathing(void);
  73. void breathing_pulse(void);
  74. #endif