]> git.scottworley.com Git - tattlekey/blame - client/tattlekey.c
client: Fancier blinking
[tattlekey] / client / tattlekey.c
CommitLineData
e2173399 1#include "pico/cyw43_arch.h"
5ec2b60a
SW
2#include "pico/stdlib.h"
3
75649fe3
SW
4void one_blink(int duration) {
5 cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 1);
6 sleep_ms(duration);
7 cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 0);
8 sleep_ms(duration);
9}
10
11void signal(int count, int duration) {
12 for (int i = 0; i < count; i++)
13 one_blink(duration);
14 sleep_ms(1000);
15}
16
17void blink_forever(int duration) {
5ec2b60a 18 while (true) {
75649fe3 19 one_blink(duration);
5ec2b60a 20 }
5ec2b60a 21}
75649fe3
SW
22
23void signal_error_by_blinking() { blink_forever(100); }
24void signal_success_by_blinking() { blink_forever(400); }
25
26int main() {
27 stdio_init_all();
28 if (cyw43_arch_init())
29 signal_error_by_blinking();
30 signal(1, 200);
31 signal(2, 200);
32 signal(3, 200);
33 signal_success_by_blinking();
34}