]>
git.scottworley.com Git - tattlekey/blob - client/press.h
1 /* tattlekey: A one-key UDP keyboard
2 * Copyright (C) 2023 Scott Worley <scottworley@scottworley.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 3 of the License, or
7 * (at your option) any later version.
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.
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/>.
21 #include "pico/cyw43_arch.h"
22 #include "pico/util/pheap.h"
23 #include "pico/util/queue.h"
32 /* Queues of various sizes that hold presses. There is one queue for each
36 /* Tracks when each queue will be next ready-to-send. Empty queues are not in
40 /* The companion-array for the heap. */
45 press_pile_t
*create_press_pile();
47 /* Adds this press to the pile.
48 * Copies the contents of `press`. */
49 void add_press(press_pile_t
*pp
, press_t
*press
);
51 /* When do we next need to send something (in seconds since boot)?
52 * Returns -1 if there's nothing pending. */
53 int32_t next_scheduled_send(press_pile_t
*pp
);
55 /* Find a press ready for resend at or before `now`.
56 * Move it out of the press-pile `pp` and into into `press`.
57 * Or return false if there is no press due for re-send. */
58 bool get_press_due_for_resend(press_pile_t
*pp
, uint32_t now
, press_t
*press
);