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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

backlight.c 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. Copyright 2014 Ralf Schmitt <[email protected]>
  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. #include <avr/io.h>
  15. #include "backlight.h"
  16. /* Backlight pin configuration
  17. *
  18. * Alphas PB1 (high)
  19. * Numeric PB2 (high)
  20. * Mod+Num PB3 (high)
  21. * Backside PD6 (high)
  22. * TopRight PD7 (low)
  23. * F-Row PE6 (high)
  24. */
  25. void backlight_set(uint8_t level)
  26. {
  27. // Set as output.
  28. DDRB |= (1<<1) | (1<<2) | (1<<3);
  29. DDRD |= (1<<6) | (1<<7);
  30. DDRE |= (1<<6);
  31. if (level & BACKLIGHT_ALPHA)
  32. {
  33. PORTB |= (1<<1);
  34. }
  35. else
  36. {
  37. PORTB &= ~(1<<1);
  38. }
  39. if (level & BACKLIGHT_NUMERIC)
  40. {
  41. PORTB |= (1<<2);
  42. }
  43. else
  44. {
  45. PORTB &= ~(1<<2);
  46. }
  47. if (level & BACKLIGHT_MODNUM)
  48. {
  49. PORTB |= (1<<3);
  50. }
  51. else
  52. {
  53. PORTB &= ~(1<<3);
  54. }
  55. if (level & BACKLIGHT_BACKSIDE)
  56. {
  57. PORTD |= (1<<6);
  58. }
  59. else
  60. {
  61. PORTD &= ~(1<<6);
  62. }
  63. if (level & BACKLIGHT_TOPRIGHT)
  64. {
  65. PORTD &= ~(1<<7);
  66. }
  67. else
  68. {
  69. PORTD |= (1<<7);
  70. }
  71. if (level & BACKLIGHT_FROW)
  72. {
  73. PORTE |= (1<<6);
  74. }
  75. else
  76. {
  77. PORTE &= ~(1<<6);
  78. }
  79. }