~aleteoryx/muditaos

ref: 22819c5f6749fcce7d0df95bc63172a13a0e8f61 muditaos/module-bsp/board/linux/torch/torch.cpp -rw-r--r-- 1.7 KiB
22819c5f — Mateusz Piesta [BH-1558] Temperature layouts conf 3 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
69
70
71
72
73
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "bsp/torch/torch.hpp"
#include <log/log.hpp>

static xQueueHandle qHandleIrq = NULL;

namespace bsp
{

    namespace torch
    {
        State state_simulated               = State::off;
        ColourTemperature currentColourTemp = ColourTemperature::warmest;

        int32_t init(xQueueHandle qHandle)
        {

            qHandleIrq      = qHandle;
            state_simulated = State::off;
            return 1;
        }

        void deinit()
        {
            qHandleIrq = nullptr;
        }

        bool isPresent(void)
        {
            return true;
        }

        bool turn(State state, ColourTemperature colourTemp)
        {
            state_simulated = state;
            if (colourTemp != ColourTemperature::noChange) {
                currentColourTemp = colourTemp;
            }

            if (state == State::on) {
                LOG_INFO("Torch is ON \U0001f526 (%s)",
                         currentColourTemp == ColourTemperature::warmest ? "warm \U0001f987" : "cold \U0001f535");
            }
            else {
                LOG_INFO("Torch is OFF");
            }
            return true;
        }

        State getState()
        {
            return state_simulated;
        }

        ColourTemperature getColorTemp()
        {
            return currentColourTemp;
        }

        bool toggle()
        {
            return turn(getState() == State::off ? State::on : State::off);
        };

        bool setCurrent(const unsigned short mA)
        {
            return true;
        }

    } // namespace torch
} // namespace bsp