// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md #include "WorkerGUI.hpp" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "messages/RenderingFinished.hpp" namespace sgui { WorkerGUI::WorkerGUI(ServiceGUI *service) : Worker(service) {} bool WorkerGUI::handleMessage(uint32_t queueID) { QueueHandle_t queue = queues[queueID]; auto serviceGUI = static_cast(service); if (queueID == 0) { sys::WorkerCommand received; xQueueReceive(queue, &received, 0); std::list> uniqueCommands; if (xSemaphoreTake(serviceGUI->semCommands, pdMS_TO_TICKS(1000)) == pdTRUE) { uniqueCommands = std::move(serviceGUI->commands); xSemaphoreGive(serviceGUI->semCommands); } else { LOG_ERROR("Failed to acquire semaphore"); } serviceGUI->renderer.render(serviceGUI->renderContext, uniqueCommands); sys::Bus::SendUnicast(std::make_shared(), service->GetName(), service); } return true; } } /* namespace sgui */