C

Qt Quick Ultralite instrument_cluster 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$ ** ******************************************************************************/
#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; };