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.

ledmap.c 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #include <avr/pgmspace.h>
  2. #include "ledmap.h"
  3. #include "debug.h"
  4. #ifdef LEDMAP_ENABLE
  5. static const uint16_t ledmaps[LED_COUNT] PROGMEM = {
  6. [0] = LEDMAP_NUM_LOCK | LEDMAP_BACKLIGHT, // LEDS1 - PB2
  7. [1] = LEDMAP_BACKLIGHT, // LEDS6 - PF7
  8. [2] = LEDMAP_BACKLIGHT, // LEDS11 - PF6
  9. [3] = LEDMAP_BACKLIGHT, // LEDS16 - PF5
  10. [4] = LEDMAP_BACKLIGHT, // PWM - PB5
  11. };
  12. ledmap_t ledmap_get_code(uint8_t index)
  13. {
  14. return (ledmap_t) { .code = pgm_read_word(&ledmaps[index]) };
  15. }
  16. void ledmap_led_init(void)
  17. {
  18. DDRB |= (1<<PB2);
  19. PORTB |= (1<<PB2);
  20. DDRF |= (1<<PF7 | 1<<PF6 | 1<<PF5);
  21. PORTF |= (1<<PF7 | 1<<PF6 | 1<<PF5);
  22. DDRB |= (1<<PB5);
  23. PORTB &= ~(1<<PB5);
  24. }
  25. void ledmap_led_on(uint8_t index)
  26. {
  27. switch (index) {
  28. case 0:
  29. PORTB &= ~(1<<PB2);
  30. break;
  31. case 1:
  32. PORTF &= ~(1<<PF7);
  33. break;
  34. case 2:
  35. PORTF &= ~(1<<PF6);
  36. break;
  37. case 3:
  38. PORTF &= ~(1<<PF5);
  39. break;
  40. case 4:
  41. PORTB |= (1<<PB5);
  42. break;
  43. }
  44. }
  45. void ledmap_led_off(uint8_t index)
  46. {
  47. switch (index) {
  48. case 0:
  49. PORTB |= (1<<PB2);
  50. break;
  51. case 1:
  52. PORTF |= (1<<PF7);
  53. break;
  54. case 2:
  55. PORTF |= (1<<PF6);
  56. break;
  57. case 3:
  58. PORTF |= (1<<PF5);
  59. break;
  60. case 4:
  61. PORTB &= ~(1<<PB5);
  62. break;
  63. }
  64. }
  65. #endif