rtos multicore implementation

This commit is contained in:
Siwat Sirichai 2023-09-11 12:03:59 +07:00
parent f1299071c1
commit 1c09bb2bf4
1 changed files with 28 additions and 5 deletions

View File

@ -110,6 +110,14 @@ void publish_input_states();
void publish_input_state(int id); void publish_input_state(int id);
void publish_input_state(int id, int state); 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_begin();
void lcd_loop(); void lcd_loop();
void lcd_refresh(); void lcd_refresh();
@ -175,7 +183,8 @@ void setup()
Serial.println("Initialization Completed."); Serial.println("Initialization Completed.");
Serial.println("Jumping to User Code."); Serial.println("Jumping to User Code.");
// Begin User Code // Begin User Code
xTaskCreatePinnedToCore(StartLCDTask, "LCDT", 4096, NULL, 2, &LCDTask, 1);
xTaskCreatePinnedToCore(StartVirtualInterruptTask, "VIT", 4096, NULL, 0, &VirturalInterruptTask, 1);
/* /*
Pre-NTP Implementation Pre-NTP Implementation
*/ */
@ -184,12 +193,10 @@ void setup()
void loop() void loop()
{ {
virtual_interrupt_loop();
mqtt_client.loop(); mqtt_client.loop();
ESPMega_loop(); ESPMega_loop();
ir_loop(); ir_loop();
thread_controller.run(); thread_controller.run();
lcd_loop();
} }
void io_begin() void io_begin()
@ -332,7 +339,6 @@ void virtual_interrupt_loop()
{ {
virtual_interupt_timer[i] = millis(); virtual_interupt_timer[i] = millis();
} }
yield();
} }
} }
@ -688,7 +694,7 @@ void lcd_refresh()
} }
void lcd_top_bar_update() 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.writeStr("time.txt", time_str);
panel.writeNum("server.pic", standalone ? 4 : 5); panel.writeNum("server.pic", standalone ? 4 : 5);
panel.writeNum("lan.pic", ETH.linkUp() ? 3 : 2); panel.writeNum("lan.pic", ETH.linkUp() ? 3 : 2);
@ -789,4 +795,21 @@ void trigger12()
void trigger13() 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();
} }