C
Qt Quick Ultralite instrument_cluster Example
// Copyright (C) 2024 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial #pragma once #include <stdint.h> struct SimulationStep { int duration; int targetSpeed; bool leftBlinkerOn; bool rightBlinkerOn; }; class Simulator { public: Simulator() : steps() , timestamp(0) , previousValueUpdate(0) , previousStepUpdate(0) , currentStep(0) , currentSpeed(0) , stepIndex(0) , updatePeriod(500) , stepCount(sizeof(steps) / sizeof(steps[0])) , leftBlinkerState(false) , rightBlinkerState(false) , tripMeter(0.0) { steps[0].duration = 4000; steps[0].targetSpeed = 80; steps[0].leftBlinkerOn = true; steps[0].rightBlinkerOn = false; steps[1].duration = 2000; steps[1].targetSpeed = 80; steps[1].leftBlinkerOn = false; steps[1].rightBlinkerOn = false; steps[2].duration = 7000; steps[2].targetSpeed = 60; steps[2].leftBlinkerOn = false; steps[2].rightBlinkerOn = false; steps[3].duration = 4000; steps[3].targetSpeed = 70; steps[3].leftBlinkerOn = false; steps[3].rightBlinkerOn = true; steps[4].duration = 6000; steps[4].targetSpeed = 95; steps[4].leftBlinkerOn = false; steps[4].rightBlinkerOn = false; } void tick(int delta); private: SimulationStep steps[5]; uint64_t timestamp; uint64_t previousValueUpdate; uint64_t previousStepUpdate; uint64_t currentStep; int currentSpeed; int stepIndex; const int updatePeriod; const int stepCount; bool leftBlinkerState; bool rightBlinkerState; double tripMeter; };