-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ino
57 lines (50 loc) · 1.06 KB
/
main.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <common.h>
#include <LedController.h>
#include <TelegramHandler.h>
#include <WifiServerHandler.h>
QueueHandle_t g_xQueue;
TaskHandle_t g_LedTask;
TaskHandle_t g_TelegramTask;
void command_task(void *p)
{
Serial.print("command_task running on core: ");
Serial.println(xPortGetCoreID());
handle_new_messages(g_xQueue);
vTaskDelete(NULL);
}
void led_task(void *p)
{
Serial.print("led_task running on core: ");
Serial.println(xPortGetCoreID());
handle_queue_commands(g_xQueue);
vTaskDelete(NULL);
}
void setup()
{
Serial.begin(115200);
wifi_handler();
// Launch tasks
g_xQueue = xQueueCreate(5, sizeof(struct LedState));
if (g_xQueue == NULL)
Serial.println("Failed to create queue");
// FastLED.addLeds<NEOPIXEL, LED_PIN_EXT>(g_ext_leds, LED_NUM_TOTAL);
xTaskCreate(
command_task,
"command_task",
5000,
NULL,
2,
&g_TelegramTask);
xTaskCreate(
led_task,
"led_task",
50000,
NULL,
3,
&g_LedTask);
Serial.println("Setup done");
}
void loop()
{
// we got tasks, no need loop
}