2 * Copyright © 2016 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.
17 static uint16_t blink_delay, blink_running;
19 static void blink(void) {
22 ao_led_on(AO_LED_GREEN);
23 ao_delay(blink_delay);
24 ao_led_off(AO_LED_GREEN);
25 ao_delay(blink_delay);
28 ao_wakeup(&blink_running);
32 struct ao_task blink_task;
34 static void blink_cmd() {
36 blink_delay = ao_cmd_lex_i;
37 if (blink_delay && !blink_running)
38 ao_add_task(&blink_task, blink, "blink");
41 ao_sleep(&blink_running);
44 static const struct ao_cmds blink_cmds[] = {
45 { blink_cmd, "b <delay, 0 off>\0Blink the green LED" },
51 ao_led_init(LEDS_AVAILABLE);
59 ao_cmd_register(blink_cmds);