Treehopper C++ API
Led.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include <ostream>
5 
6 namespace Treehopper {
7  namespace Libraries {
8  namespace Displays {
9 
10  using namespace std;
11 
12  class LedDriver;
13 
23  public:
30  Led(LedDriver &driver, int channel = 0, bool hasBrightnessControl = false);
31 
32  Led &operator=(const Led &rhs) {
33  Led &led = *new Led(rhs.driver, rhs.channel, rhs.hasBrightnessControl);
34  led._brightness = rhs._brightness;
35  led._state = rhs._state;
36  return led;
37  }
38 
42  const int channel;
43 
51  void brightness(double value);
52 
53  double brightness();
54 
59 
66  bool state();
67 
68  void state(bool value);
69 
74  friend std::ostream &operator<<(std::ostream &stream, const Led &led) {
75  stream << (led._state ? "true" : "false") << " (" << led._brightness << ")" << endl;
76  }
77 
78  private:
79 
83  LedDriver &driver;
84  double _brightness = 1.0;
85  bool _state = false;
86  };
87  }
88  }
89 }
const bool hasBrightnessControl
Gets whether the LED has _brightness control
Definition: Led.h:58
Represents a single LED that may or may not have _brightness control
Definition: Led.h:22
Led & operator=(const Led &rhs)
Definition: Led.h:32
Base class that all LED drivers inherit from.
Definition: LedDriver.h:18
const int channel
Gets or sets the channel this LED belongs to
Definition: Led.h:42
#define LIBRARIES_API
Definition: Treehopper.Libraries.h:17
Definition: AdcPin.h:3
friend std::ostream & operator<<(std::ostream &stream, const Led &led)
Gets a string representation of the LED&#39;s current _state
Definition: Led.h:74