]> git.scottworley.com Git - tattlekey/commitdiff
client: create_press() → add_press()
authorScott Worley <scottworley@scottworley.com>
Tue, 10 Oct 2023 06:04:17 +0000 (23:04 -0700)
committerScott Worley <scottworley@scottworley.com>
Wed, 11 Oct 2023 01:49:32 +0000 (18:49 -0700)
client/press.c
client/press.h
client/tattlekey.c

index 7a7f99678ad6b64d48f6767620bce97fc9065bbc..56d95eaaabc32b4fe69a8d725246c0905d9f17e4 100644 (file)
@@ -25,16 +25,14 @@ press_pile_t *create_press_pile() {
   return pp;
 }
 
   return pp;
 }
 
-void create_press(press_pile_t *pp, uint32_t timestamp, u16_t seq) {
+void add_press(press_pile_t *pp, press_t *press) {
   pheap_node_id_t i = ph_new_node(pp->sleeps_heap);
   if (i == 0) {
     /* TODO: Don't drop new presses just because sleeps_heap is full of old
      * presses. */
     return;
   }
   pheap_node_id_t i = ph_new_node(pp->sleeps_heap);
   if (i == 0) {
     /* TODO: Don't drop new presses just because sleeps_heap is full of old
      * presses. */
     return;
   }
-  pp->presses[i].timestamp = timestamp;
-  pp->presses[i].seq = seq;
-  pp->presses[i].send_count = 0;
+  pp->presses[i] = *press;
   ph_insert_node(pp->sleeps_heap, i);
 }
 
   ph_insert_node(pp->sleeps_heap, i);
 }
 
index cd34b3df0b48aeb4189e8b9a0b393347121281f6..898bb1a85a4334c3cbb1e83046813100da251aac 100644 (file)
@@ -17,7 +17,9 @@ typedef struct {
 
 press_pile_t *create_press_pile();
 
 
 press_pile_t *create_press_pile();
 
-void create_press(press_pile_t *pp, uint32_t timestamp, u16_t seq);
+/* Adds this press to the pile.
+ * Copies the contents of `press`. */
+void add_press(press_pile_t *pp, press_t *press);
 
 /* When do we next need to send something (in seconds since boot)?
  * Returns -1 if there's nothing pending. */
 
 /* When do we next need to send something (in seconds since boot)?
  * Returns -1 if there's nothing pending. */
index 2f643235b8fe893e611c19682f643729f0c7a5c6..88bdd9159f7c958649bef438920bb7dbe2ed6b80 100644 (file)
@@ -102,7 +102,7 @@ void service_queue() {
     queue_remove_blocking(&queue, &e);
     switch (e.type) {
     case NEW_BUTTON_PRESS: {
     queue_remove_blocking(&queue, &e);
     switch (e.type) {
     case NEW_BUTTON_PRESS: {
-      create_press(pp, e.buttonpress.timestamp, seq++);
+      add_press(pp, &(press_t){e.buttonpress.timestamp, seq++, 0});
     } break;
     case RESEND_TIME: {
       /* OK, we're awake. Cool. Thanks! (We actually do the sends in the
     } break;
     case RESEND_TIME: {
       /* OK, we're awake. Cool. Thanks! (We actually do the sends in the