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.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. #ifdef LEDMAP_ENABLE
  17. static const uint8_t ledmaps[LED_COUNT] PROGMEM = {
  18. [0] = LEDMAP_BACKLIGHT,
  19. [1] = LEDMAP_BACKLIGHT,
  20. [2] = LEDMAP_BACKLIGHT,
  21. [3] = LEDMAP_BACKLIGHT
  22. };
  23. uint8_t ledmap_get_code(uint8_t index)
  24. {
  25. return pgm_read_byte(&ledmaps[index]);
  26. }
  27. void ledmap_led_init(void)
  28. {
  29. DDRD |= (1<<PD0);
  30. DDRB |= (1<<PB7);
  31. DDRC |= (1<<PD5 | 1<<PD6);
  32. }
  33. void ledmap_led_on(uint8_t index)
  34. {
  35. switch (index) {
  36. case 0:
  37. PORTD |= (1<<PD0);
  38. break;
  39. case 1:
  40. PORTB |= (1<<PB7);
  41. break;
  42. case 2:
  43. PORTC |= (1<<PC6);
  44. break;
  45. case 3:
  46. PORTC |= (1<<PC5);
  47. break;
  48. }
  49. }
  50. void ledmap_led_off(uint8_t index)
  51. {
  52. switch (index) {
  53. case 0:
  54. PORTD &= ~(1<<PD0);
  55. break;
  56. case 1:
  57. PORTB &= ~(1<<PB7);
  58. break;
  59. case 2:
  60. PORTC &= ~(1<<PC6);
  61. break;
  62. case 3:
  63. PORTC &= ~(1<<PC5);
  64. break;
  65. }
  66. }
  67. #endif