Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

ledmap.c 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. Copyright 2014 Kai Ryu <[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/pgmspace.h>
  15. #include "ledmap.h"
  16. #include "debug.h"
  17. #ifdef LEDMAP_ENABLE
  18. static const uint8_t ledmaps[LED_COUNT] PROGMEM = {
  19. [0] = LEDMAP_CAPS_LOCK, // CapsLock - PB2
  20. [1] = LEDMAP_BACKLIGHT, // PWM - PF7
  21. };
  22. uint8_t ledmap_get_code(uint8_t index)
  23. {
  24. return pgm_read_byte(&ledmaps[index]);
  25. }
  26. void ledmap_led_init(void)
  27. {
  28. DDRB |= (1<<PB2);
  29. PORTB |= (1<<PB2);
  30. DDRF |= (1<<PF7);
  31. PORTF &= ~(1<<PF7);
  32. }
  33. void ledmap_led_on(uint8_t index)
  34. {
  35. switch (index) {
  36. case 0:
  37. PORTB &= ~(1<<PB2);
  38. break;
  39. case 1:
  40. PORTF |= (1<<PF7);
  41. break;
  42. }
  43. }
  44. void ledmap_led_off(uint8_t index)
  45. {
  46. switch (index) {
  47. case 0:
  48. PORTB |= (1<<PB2);
  49. break;
  50. case 1:
  51. PORTF &= ~(1<<PF7);
  52. break;
  53. }
  54. }
  55. #endif