NASA Astrobee Robot Software  0.19.1
Flight software for the Astrobee robots operating inside the International Space Station.
flashlight.h
Go to the documentation of this file.
1 /* Copyright (c) 2017, United States Government, as represented by the
2  * Administrator of the National Aeronautics and Space Administration.
3  *
4  * All rights reserved.
5  *
6  * The Astrobee platform is licensed under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with the
8  * License. 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, WITHOUT
14  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15  * License for the specific language governing permissions and limitations
16  * under the License.
17  */
18 
19 #ifndef FLASHLIGHT_FLASHLIGHT_H_
20 #define FLASHLIGHT_FLASHLIGHT_H_
21 
22 #include <i2c/i2c_new.h>
23 
24 namespace flashlight {
25 
26 enum class Mode : std::uint8_t {
27  GROUP = 1,
28  INDIVIDUAL = 2
29 };
30 
31 class Flashlight {
32  public:
33  explicit Flashlight(i2c::Device const &dev);
34 
35  bool Init(i2c::Error* ec);
36 
37  bool SetBrightness(int brightness, i2c::Error* ec);
38  bool SetEnabled(bool enabled, i2c::Error* ec);
39  bool SetMode(Mode mode, i2c::Error* ec);
40 
41  int brightness() { return brightness_; }
42  bool enabled() { return enabled_; }
43  Mode mode() { return mode_; }
44 
45  private:
46  i2c::Device dev_;
47 
48  int brightness_;
49  bool enabled_;
50  Mode mode_;
51 };
52 
53 } // namespace flashlight
54 
55 #endif // FLASHLIGHT_FLASHLIGHT_H_
flashlight::Flashlight
Definition: flashlight.h:31
flashlight::Mode::GROUP
@ GROUP
flashlight::Flashlight::SetBrightness
bool SetBrightness(int brightness, i2c::Error *ec)
Definition: flashlight.cc:99
flashlight::Flashlight::mode
Mode mode()
Definition: flashlight.h:43
flashlight
Definition: flashlight.h:24
flashlight::Flashlight::Flashlight
Flashlight(i2c::Device const &dev)
Definition: flashlight.cc:69
flashlight::Flashlight::Init
bool Init(i2c::Error *ec)
Definition: flashlight.cc:73
flashlight::Flashlight::SetEnabled
bool SetEnabled(bool enabled, i2c::Error *ec)
Definition: flashlight.cc:143
flashlight::Flashlight::brightness
int brightness()
Definition: flashlight.h:41
flashlight::Flashlight::enabled
bool enabled()
Definition: flashlight.h:42
flashlight::Flashlight::SetMode
bool SetMode(Mode mode, i2c::Error *ec)
Definition: flashlight.cc:118
i2c_new.h
flashlight::Mode
Mode
Definition: flashlight.h:26
flashlight::Mode::INDIVIDUAL
@ INDIVIDUAL
i2c::Error
int Error
Definition: i2c_new.h:30
i2c::Device
Definition: i2c_new.h:82