Would be interesting to know it is there as an option.
So far TeensyThreads has gotten some attention. It would be cool to see how much size difference there is for similar samples code ... what is working now and as redone with RTOS just to know how much it brings in.
Here is the basic example. This one shown for freeRTOS, the one for TeensyThreads is basically the same.
Code:
#include <Arduino.h>
#include "arduino_freertos.h"
#include "avr/pgmspace.h"
volatile uint16_t a,b,c;
void task1(void*)
{
a=0;
while (true)
{
a++;
vTaskDelay(pdMS_TO_TICKS(1));
}
}
void task2(void*)
{
b=0;
while (true)
{
b++;
//digitalWriteFast(arduino::LED_BUILTIN, arduino::HIGH);
vTaskDelay(pdMS_TO_TICKS(25));
//digitalWriteFast(arduino::LED_BUILTIN, arduino::LOW);
vTaskDelay(pdMS_TO_TICKS(50));
}
}
void task3(void*)
{
c=0;
while (true)
{
c++;
Serial.printf("a[%06u] : b[%06u] : c[%06u]\r\n",a,b,c);
vTaskDelay(pdMS_TO_TICKS(10));
}
}
void setup()
{
Serial.begin(115200);
while (!Serial); // wait for Arduino Serial Monitor
xTaskCreate(task1, "task1", 2048, nullptr, 3, nullptr);
xTaskCreate(task2, "task2", 2048, nullptr, 2, nullptr);
xTaskCreate(task3, "task3", 2048, nullptr, 1, nullptr);
Serial.println("setup(): starting scheduler...");
Serial.flush();
vTaskStartScheduler();
}
void loop()
{
}
TeensyThreads compile output:
teensy_size: Memory Usage on Teensy 4.1:
teensy_size: FLASH: code:28056, data:5016, headers:8908 free for files:8084484
teensy_size: RAM1: variables:5760, code:25384, padding:7384 free for local variables:485760
teensy_size: RAM2: variables:12384 free for malloc/new:511904
freeRTOS compile output:
RAM 1: [= ] 8.7% (used 45600 bytes from 524288 bytes)
RAM 2: [ ] 2.5% (used 13164 bytes from 524288 bytes)
Flash: [ ] 0.8% (used 61440 bytes from 8126464 bytes)
Not sure why the two outputs look different.