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.

41 lines
971 B

  1. #include <avr/io.h>
  2. #include "backlight.h"
  3. #include "print.h"
  4. /* Clueboard 2.0 LED locations:
  5. *
  6. * Capslock: B4, pull high to turn on
  7. * LCtrl: Shared with Capslock, DO NOT INSTALL LED'S IN BOTH
  8. * Page Up: B7, pull high to turn on
  9. * Escape: D6, pull high to turn on
  10. * Arrows: D4, pull high to turn on
  11. */
  12. void init_backlight_pin(void) {
  13. print("init_backlight_pin()\n");
  14. // Set our LED pins as output
  15. DDRD |= (1<<6); // Esc
  16. DDRB |= (1<<7); // Page Up
  17. DDRD |= (1<<4); // Arrows
  18. // Set our LED pins low
  19. PORTD &= ~(1<<6); // Esc
  20. PORTB &= ~(1<<7); // Page Up
  21. PORTD &= ~(1<<4); // Arrows
  22. }
  23. void backlight_set(uint8_t level) {
  24. if ( level == 0 ) {
  25. // Turn off light
  26. PORTD |= (1<<6); // Esc
  27. PORTB |= (1<<7); // Page Up
  28. PORTD |= (1<<4); // Arrows
  29. } else {
  30. // Turn on light
  31. PORTD &= ~(1<<6); // Esc
  32. PORTB &= ~(1<<7); // Page Up
  33. PORTD &= ~(1<<4); // Arrows
  34. }
  35. }