C
Qt Quick Ultralite freertos_multitask Example
/****************************************************************************** ** ** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Quick Ultralite module. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ******************************************************************************/#include "led_thread.h" #include "qul_thread.h" #include <FreeRTOS.h> #include <task.h> #include <queue.h> #include <board_utils/led.h> void Led_Thread(void *argument) { (void) argument; uint32_t speed = 1; uint32_t newSpeed = 0; int ledCycleCount = 0; bool ledOn = false; HardwareEvent ledEvent; while (true) { const TickType_t ticks = speed > 0 ? (350 / (portTICK_PERIOD_MS * speed)) : portMAX_DELAY; if (xTaskNotifyWait(0, ULONG_MAX, &newSpeed, ticks) == pdTRUE) { speed = newSpeed; } BoardUtils::toggleLED(); if (ledOn) { ledCycleCount++; ledCycleCount = ledCycleCount < 0 ? 0 : ledCycleCount; } ledOn = !ledOn; ledEvent.id = HardwareEventId::LedCycleCount; ledEvent.data = ledCycleCount; postEventsToUI(ledEvent); taskYIELD(); } }