~aleteoryx/muditaos

ref: 03e5f8d7148275d0db11ddd8248055e93d35da3a muditaos/module-apps/application-clock/windows/ClockMainWindow.hpp -rw-r--r-- 1.6 KiB
03e5f8d7 — Wojtek Rzepecki [EGD-5360] Add USB current selection 5 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

// module-gui
#include "AppWindow.hpp"
#include "gui/widgets/Item.hpp"
#include "gui/widgets/Image.hpp"
#include "gui/widgets/Label.hpp"
#include "gui/widgets/BoxLayout.hpp"
#include "gui/widgets/ProgressBar.hpp"

namespace gui
{

    class ClockMainWindow : public AppWindow
    {
        uint32_t seconds         = 0;
        uint32_t hour            = 0;
        uint32_t minute          = 0;
        Label *hourLabel         = nullptr;
        Label *minuteLabel       = nullptr;
        ProgressBar *progressBar = nullptr;

      public:
        ClockMainWindow(app::Application *app, const std::string &name);

        bool handleSwitchData(SwitchData *data) override;

        void setHour(uint32_t h)
        {
            hour = h % 24;
        };
        void setMinute(uint32_t m)
        {
            minute = m % 60;
        };

        /**
         * @brief Increments hours counter
         */
        bool incrementHour();
        /**
         * @brief Increments minutes counter
         */
        bool incrementMinute();
        /**
         * @brief Increments seconds counter
         */
        bool incrementSecond();
        /**
         * @brief Updates strings for hour and minutes
         */
        void updateLabels();

        void rebuild(){};
        void buildInterface()
        {
            AppWindow::buildInterface();
        };
        void destroyInterface()
        {
            AppWindow::destroyInterface();
        };
    };

} /* namespace gui */