2 * Copyright © 2018 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 [0] { LED_0_PORT, LED_0_PIN },
29 [1] { LED_1_PORT, LED_1_PIN },
32 [2] { LED_2_PORT, LED_2_PIN },
35 [3] { LED_3_PORT, LED_3_PIN },
38 [4] { LED_4_PORT, LED_4_PIN },
41 [5] { LED_5_PORT, LED_5_PIN },
44 [6] { LED_6_PORT, LED_6_PIN },
47 [7] { LED_7_PORT, LED_7_PIN },
50 [8] { LED_8_PORT, LED_8_PIN },
53 [9] { LED_9_PORT, LED_9_PIN },
56 [10] { LED_10_PORT, LED_10_PIN },
59 [11] { LED_11_PORT, LED_11_PIN },
62 [12] { LED_12_PORT, LED_12_PIN },
65 [13] { LED_13_PORT, LED_13_PIN },
68 [14] { LED_14_PORT, LED_14_PIN },
71 [15] { LED_15_PORT, LED_15_PIN },
74 [16] { LED_16_PORT, LED_16_PIN },
77 [17] { LED_17_PORT, LED_17_PIN },
80 [18] { LED_18_PORT, LED_18_PIN },
83 [19] { LED_19_PORT, LED_19_PIN },
86 [20] { LED_20_PORT, LED_20_PIN },
89 [21] { LED_21_PORT, LED_21_PIN },
92 [22] { LED_22_PORT, LED_22_PIN },
95 [23] { LED_23_PORT, LED_23_PIN },
98 [24] { LED_24_PORT, LED_24_PIN },
101 [25] { LED_25_PORT, LED_25_PIN },
104 [26] { LED_26_PORT, LED_26_PIN },
107 [27] { LED_27_PORT, LED_27_PIN },
110 [28] { LED_28_PORT, LED_28_PIN },
113 [29] { LED_29_PORT, LED_29_PIN },
116 [30] { LED_30_PORT, LED_30_PIN },
119 [31] { LED_31_PORT, LED_31_PIN },
122 #define N_LED (sizeof (ao_leds)/sizeof(ao_leds[0]))
125 ao_led_on(AO_LED_TYPE colors)
128 for (i = 0; i < N_LED; i++)
129 if (colors & (1 << i))
130 ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, 1);
134 ao_led_off(AO_LED_TYPE colors)
137 for (i = 0; i < N_LED; i++)
138 if (colors & (1 << i))
139 ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, 0);
143 ao_led_set(AO_LED_TYPE colors)
146 for (i = 0; i < N_LED; i++)
147 ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, (colors >> i) & 1);
151 ao_led_for(AO_LED_TYPE colors, AO_TICK_TYPE ticks)
163 for (bit = 0; bit < N_LED; bit++)
164 ao_enable_output(ao_leds[bit].port, ao_leds[bit].pin, 0);