Kestrel Interface
Loading...
Searching...
No Matches
kest_representation.c
Go to the documentation of this file.
1#include "kest_int.h"
2
3#ifndef PRINTLINES_ALLOWED
4#define PRINTLINES_ALLOWED 0
5#endif
6
7static const char *FNAME = "kest_representation.c";
8
10
11#ifdef KEST_USE_FREERTOS
12QueueHandle_t kest_rep_update_queue;
13int rep_updated_initd = 0;
14#endif
15
16void kest_representation_pll_update_all(kest_representation_pll *reps)
17{
18 kest_representation_pll *current = reps;
19
20 while (current)
21 {
22 if (current->data && current->data->update)
23 {
24 current->data->update(current->data->representer, current->data->representee);
25 }
26
27 current = current->next;
28 }
29
30 return;
31}
32
33#ifdef KEST_ENABLE_REPRESENTATIONS
34void update_queued_representations_cb(lv_timer_t *timer)
35{
36 //FUNCTION_START();
37
38 kest_representation_pll *list;
39
40 while (xQueueReceive(kest_rep_update_queue, &list, 0) == pdTRUE)
41 {
43 }
44
45 //return;
46}
47
48int init_representation_updater()
49{
50 kest_rep_update_queue = xQueueCreate(16, sizeof(kest_representation_pll*));
51 lv_timer_t * timer = lv_timer_create(update_queued_representations_cb, 1, NULL);
52 rep_updated_initd = 1;
53 return NO_ERROR;
54}
55#endif
56
57int queue_representation_list_update(kest_representation_pll *reps)
58{
59 #ifdef KEST_ENABLE_REPRESENTATIONS
60 #ifdef KEST_USE_FREERTOS
61 if (!rep_updated_initd)
63
64 if (xQueueSend(kest_rep_update_queue, (void*)&reps, (TickType_t)10) != pdPASS)
65 {
67 }
68 #endif
69 return NO_ERROR;
70 #endif
72}
73
74kest_representation_pll *kest_representation_pll_remove(kest_representation_pll *reps, kest_representation *rep)
75{
76 if (!reps)
77 return NULL;
78
79 kest_representation_pll *current = reps;
80 kest_representation_pll *prev = NULL;
81 kest_representation_pll *head = reps;
82
83 while (current)
84 {
85 if (current->data == rep)
86 {
87 if (prev)
88 prev->next = current->next;
89 else
90 head = current->next;
91
92 kest_free(current);
93 return head;
94 }
95
96 prev = current;
97 current = current->next;
98 }
99
100 return head;
101}
void kest_free(void *ptr)
Definition kest_alloc.c:32
#define NO_ERROR
#define ERR_CURRENTLY_EXHAUSTED
#define ERR_FEATURE_DISABLED
#define ERR_QUEUE_SEND_FAILED
#define IMPLEMENT_LINKED_PTR_LIST(X)
void kest_representation_pll_update_all(kest_representation_pll *reps)
int queue_representation_list_update(kest_representation_pll *reps)
kest_representation_pll * kest_representation_pll_remove(kest_representation_pll *reps, kest_representation *rep)