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.

59 lines
1.2 KiB

  1. #include "prototype.h"
  2. #include <avr/io.h>
  3. #include "backlight.h"
  4. #include "print.h"
  5. void matrix_init_kb(void) {
  6. // put your keyboard start-up code here
  7. // runs once when the firmware starts up
  8. matrix_init_user();
  9. led_init_ports();
  10. }
  11. void matrix_scan_kb(void) {
  12. matrix_scan_user();
  13. }
  14. void backlight_init_ports(void) {
  15. print("init_backlight_pin()\n");
  16. // Set our LED pins as output
  17. DDRD |= (1<<0); // Esc
  18. DDRD |= (1<<4); // Page Up
  19. DDRD |= (1<<1); // Arrows
  20. // Set our LED pins low
  21. PORTD &= ~(1<<0); // Esc
  22. PORTD &= ~(1<<4); // Page Up
  23. PORTD &= ~(1<<1); // Arrows
  24. }
  25. void backlight_set(uint8_t level) {
  26. if ( level == 0 ) {
  27. // Turn off light
  28. PORTD |= (1<<0); // Esc
  29. PORTD |= (1<<4); // Page Up
  30. PORTD |= (1<<1); // Arrows
  31. } else {
  32. // Turn on light
  33. PORTD &= ~(1<<0); // Esc
  34. PORTD &= ~(1<<4); // Page Up
  35. PORTD &= ~(1<<1); // Arrows
  36. }
  37. }
  38. void led_init_ports() {
  39. // * Set our LED pins as output
  40. DDRB |= (1<<4);
  41. }
  42. void led_set_kb(uint8_t usb_led) {
  43. DDRB |= (1<<4);
  44. if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
  45. // Turn capslock on
  46. PORTB |= (1<<4);
  47. } else {
  48. // Turn capslock off
  49. PORTB &= ~(1<<4);
  50. }
  51. }