No Description
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.

led.c 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * led.c
  3. *
  4. * Copyright (c) 2024 Thomas Buck (thomas@xythobuz.de)
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * See <http://www.gnu.org/licenses/>.
  17. */
  18. #include <stdio.h>
  19. #include <inttypes.h>
  20. #include "pico/stdlib.h"
  21. #include "sequence.h"
  22. #include "led.h"
  23. #if 0
  24. static const uint led_gpio_num[LED_COUNT] = {
  25. 10, 11, 13, 15,
  26. };
  27. #else
  28. static const uint led_gpio_num[LED_COUNT] = {
  29. 6, 7, 8, 9, 10, 11, 12, 13,
  30. };
  31. #endif
  32. static const uint ch_gpio_num[NUM_CHANNELS] = {
  33. 22, 26, 27,
  34. };
  35. void led_init(void) {
  36. for (uint i = 0; i < LED_COUNT; i++) {
  37. gpio_init(led_gpio_num[i]);
  38. gpio_set_dir(led_gpio_num[i], GPIO_OUT);
  39. }
  40. for (uint i = 0; i < NUM_CHANNELS; i++) {
  41. gpio_init(ch_gpio_num[i]);
  42. gpio_set_dir(ch_gpio_num[i], GPIO_OUT);
  43. }
  44. }
  45. void led_set(uint32_t i, bool v) {
  46. i %= LED_COUNT;
  47. gpio_put(led_gpio_num[i], v);
  48. //printf("led %"PRIu32" now %d\n", i, v);
  49. }
  50. void ch_set(uint32_t i, bool v) {
  51. i %= NUM_CHANNELS;
  52. gpio_put(ch_gpio_num[i], v);
  53. //printf("ch %"PRIu32" now %d\n", i, v);
  54. }