You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.4 KiB

  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. #ifndef BACKLIGHT_ON_STATE
  23. # define BACKLIGHT_ON_STATE 1
  24. #endif
  25. #ifndef BREATHING_PERIOD
  26. # define BREATHING_PERIOD 6
  27. #endif
  28. typedef union {
  29. uint8_t raw;
  30. struct {
  31. bool enable : 1;
  32. bool breathing : 1;
  33. uint8_t reserved : 1; // Reserved for possible future backlight modes
  34. uint8_t level : 5;
  35. };
  36. } backlight_config_t;
  37. void backlight_init(void);
  38. void backlight_toggle(void);
  39. void backlight_enable(void);
  40. void backlight_disable(void);
  41. bool is_backlight_enabled(void);
  42. void backlight_step(void);
  43. void backlight_increase(void);
  44. void backlight_decrease(void);
  45. void backlight_level_noeeprom(uint8_t level);
  46. void backlight_level(uint8_t level);
  47. uint8_t get_backlight_level(void);
  48. uint8_t eeconfig_read_backlight(void);
  49. void eeconfig_update_backlight(uint8_t val);
  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