Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / examples / all-clusters-app / esp32 / main / BluetoothWidget.cpp
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *    All rights reserved.
5  *
6  *    Licensed under the Apache License, Version 2.0 (the "License");
7  *    you may not use this file except in compliance with the License.
8  *    You may obtain a copy of the License at
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *    Unless required by applicable law or agreed to in writing, software
13  *    distributed under the License is distributed on an "AS IS" BASIS,
14  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *    See the License for the specific language governing permissions and
16  *    limitations under the License.
17  */
18
19 /**
20  * @file BluetoothWidget.cpp
21  *
22  * Implements a Bluetooth Widget controller that display the state of bluetooth
23  * connection on display.
24  */
25
26 #include "ScreenManager.h"
27
28 #include "BluetoothWidget.h"
29
30 #include "esp_log.h"
31 #include "esp_system.h"
32
33 extern const char * TAG;
34
35 void BluetoothWidget::Init()
36 {
37 #if CONFIG_HAVE_DISPLAY
38     mVLED = -1;
39 #endif // CONFIG_HAVE_DISPLAY
40
41     mState = false;
42 }
43
44 void BluetoothWidget::Set(bool state)
45 {
46     bool stateChange = (mState != state);
47     mState           = state;
48     if (stateChange)
49     {
50 #if CONFIG_HAVE_DISPLAY
51         if (mVLED != -1)
52         {
53             ScreenManager::SetVLED(mVLED, mState);
54         }
55 #endif // CONFIG_HAVE_DISPLAY
56     }
57 }
58
59 #if CONFIG_HAVE_DISPLAY
60 void BluetoothWidget::SetVLED(int id)
61 {
62     mVLED = id;
63     if (mVLED != -1)
64     {
65         ScreenManager::SetVLED(mVLED, mState);
66     }
67 }
68 #endif // CONFIG_HAVE_DISPLAY