]> git.scottworley.com Git - tattlekey/blame - client/blink.c
README: Fix image path for display in gitweb
[tattlekey] / client / blink.c
CommitLineData
a4a617fd
SW
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
dae35db7
SW
18#include "pico/cyw43_arch.h"
19#include "pico/stdlib.h"
20
21#include "blink.h"
22
23void 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
30void signal(int count, int duration) {
31 for (int i = 0; i < count; i++)
32 one_blink(duration);
33 sleep_ms(1000);
34}
35
36void blink_forever(int duration) {
37 while (true) {
38 one_blink(duration);
39 }
40}
41
42void signal_error_by_blinking() { blink_forever(100); }
43void signal_success_by_blinking() { blink_forever(400); }