暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. static const uint led_gpio_num[LED_COUNT] = {
  24. 10, 11, 13, 15,
  25. };
  26. static const uint ch_gpio_num[NUM_CHANNELS] = {
  27. 22, 26, 27,
  28. };
  29. void led_init(void) {
  30. for (uint i = 0; i < LED_COUNT; i++) {
  31. gpio_init(led_gpio_num[i]);
  32. gpio_set_dir(led_gpio_num[i], GPIO_OUT);
  33. }
  34. for (uint i = 0; i < NUM_CHANNELS; i++) {
  35. gpio_init(ch_gpio_num[i]);
  36. gpio_set_dir(ch_gpio_num[i], GPIO_OUT);
  37. }
  38. }
  39. void led_set(uint32_t i, bool v) {
  40. i %= LED_COUNT;
  41. gpio_put(led_gpio_num[i], v);
  42. //printf("led %"PRIu32" now %d\n", i, v);
  43. }
  44. void ch_set(uint32_t i, bool v) {
  45. i %= NUM_CHANNELS;
  46. gpio_put(ch_gpio_num[i], v);
  47. //printf("ch %"PRIu32" now %d\n", i, v);
  48. }