]> git.scottworley.com Git - tattlekey/blob - client/blink.c
9f1e419485c191e89291cff7f975bbbf52a8d8ff
[tattlekey] / client / blink.c
1 /* tattlekey: A one-key UDP keyboard
2 * Copyright (C) 2023 Scott Worley <scottworley@scottworley.com>
3 *
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 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18 #include "pico/cyw43_arch.h"
19 #include "pico/stdlib.h"
20
21 #include "blink.h"
22
23 void one_blink(int duration) {
24 cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 1);
25 sleep_ms(duration);
26 cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 0);
27 sleep_ms(duration);
28 }
29
30 void signal(int count, int duration) {
31 for (int i = 0; i < count; i++)
32 one_blink(duration);
33 sleep_ms(1000);
34 }
35
36 void blink_forever(int duration) {
37 while (true) {
38 one_blink(duration);
39 }
40 }
41
42 void signal_error_by_blinking() { blink_forever(100); }
43 void signal_success_by_blinking() { blink_forever(400); }