From 1c09bb2bf49ab0dc3e918a2ef786f9a171e7dc8c Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Mon, 11 Sep 2023 12:03:59 +0700 Subject: [PATCH] rtos multicore implementation --- src/main.cpp | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 5c486a1..6190142 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -110,6 +110,14 @@ void publish_input_states(); void publish_input_state(int id); void publish_input_state(int id, int state); +TaskHandle_t ConnectivityTask = NULL; +TaskHandle_t VirturalInterruptTask = NULL; +TaskHandle_t LCDTask = NULL; + +void StartConnectivityTask(void *pvParameters); +void StartVirtualInterruptTask(void *pvParameters); +void StartLCDTask(void *pvParameters); + void lcd_begin(); void lcd_loop(); void lcd_refresh(); @@ -175,7 +183,8 @@ void setup() Serial.println("Initialization Completed."); Serial.println("Jumping to User Code."); // Begin User Code - + xTaskCreatePinnedToCore(StartLCDTask, "LCDT", 4096, NULL, 2, &LCDTask, 1); + xTaskCreatePinnedToCore(StartVirtualInterruptTask, "VIT", 4096, NULL, 0, &VirturalInterruptTask, 1); /* Pre-NTP Implementation */ @@ -184,12 +193,10 @@ void setup() void loop() { - virtual_interrupt_loop(); mqtt_client.loop(); ESPMega_loop(); ir_loop(); thread_controller.run(); - lcd_loop(); } void io_begin() @@ -332,7 +339,6 @@ void virtual_interrupt_loop() { virtual_interupt_timer[i] = millis(); } - yield(); } } @@ -688,7 +694,7 @@ void lcd_refresh() } void lcd_top_bar_update() { - String time_str = String(rtc.getHour())+":"+String(rtc.getMinute()); + String time_str = String(rtc.getHour()) + ":" + String(rtc.getMinute()); panel.writeStr("time.txt", time_str); panel.writeNum("server.pic", standalone ? 4 : 5); panel.writeNum("lan.pic", ETH.linkUp() ? 3 : 2); @@ -789,4 +795,21 @@ void trigger12() void trigger13() { +} + +void StartConnectivityTask(void *pvParameters) +{ + while (true) + { + } +} +void StartVirtualInterruptTask(void *pvParameters) +{ + while (true) + virtual_interrupt_loop(); +} +void StartLCDTask(void *pvParameters) +{ + while (true) + lcd_loop(); } \ No newline at end of file