C
Qt Quick Ultralite multitask Example
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
#include "fan_thread.h"
#include "qul_thread.h"
#include "hardwarecontrol.h"
#include "platforminterface/log.h"
static QueueHandle_t fanControlQueue = NULL;
void initFanControlQueue()
{
fanControlQueue = xQueueCreate(10, sizeof(int));
}
QueueHandle_t getFanControlQueueHandle()
{
return fanControlQueue;
}
void FanControl_Thread(void *argument)
{
(void) argument;
int newSpeed;
HardwareEvent fanEvent;
while (true) {
if (xQueueReceive(fanControlQueue, &newSpeed, portMAX_DELAY) == pdTRUE) {
int rotationPeriod = newSpeed == 0 ? 0 : 5000 / (newSpeed * 3);
fanEvent.id = HardwareEventId::FanRotationPeriod;
fanEvent.data = rotationPeriod;
postEventsToUI(fanEvent);
}
}
}