- #include <Arduino.h>
- #include "tasks.hpp"
- TaskHandle_t video;
- TaskHandle_t led;
- void setup() {
- Serial.begin(115200);
- vTaskDelay(1000 / portTICK_PERIOD_MS);
- Serial.println();
- Serial.println("---SICABS Indoor---");
- Serial.println();
- xTaskCreatePinnedToCore(videoProjection, "Video projection", 200000, NULL, 1, &video, 1);
- xTaskCreatePinnedToCore(blinkLED, "blink LED", 200000, NULL, 1, &led, 0);
- }
- void loop() {
- vTaskDelete(NULL);
- }
- void videoProjection(void* parameter) {
- gfx.init();
- gfx.setRotation(0);
- gfx.setColorDepth(16);
- gfx.setBrightness(127);
- gfx.fillScreen(TFT_BLACK);
- gfx.setSwapBytes(true);
- gfx.setFont(&fonts::lgfxJapanGothic_16);
- gfx.drawString("SICABS Indoor", 0, 0);
- // JPEG decoder
- TJpgDec.setJpgScale(1);
- TJpgDec.setCallback(tft_output);
- // WiFi
- WiFi.softAP(wifi_ssid, wifi_password);
- IPAddress IP = WiFi.softAPIP();
- // WebSockets
- server.listen(SERVER_PORT);
- Serial.print("Video task running on core ");
- Serial.println(xPortGetCoreID());
- for (;;) {
- if (server.poll()) {
- // if (!client.available()) { // Always overwrite the client to the new one
- client = server.accept();
- client.onMessage(onMessageCallback);
- client.onEvent(onEventsCallback);
- client.send("Hello Client!");
- // }
- }
- if (client.available()) {
- client.poll();
- }
- }
- }
- void blinkLED(void *parameter) {
- int time = 1000;
- pinMode(led_pin, OUTPUT);
- Serial.print("Blinking LED task running on core ");
- Serial.println(xPortGetCoreID());
- for (;;) {
- digitalWrite(led_pin, HIGH);
- vTaskDelay(time / portTICK_PERIOD_MS);
- digitalWrite(led_pin, LOW);
- vTaskDelay(time / portTICK_PERIOD_MS);
- }
- }
I've already tried by changing their running core, stack size and even running them both on the same core and deleting the setup() and loop() functions.
Any idea why this happens? Thanks in advance