ClearCore Library
LedDriver.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Teknic, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  */
22 
31 #ifndef __LEDDRIVER_H__
32 #define __LEDDRIVER_H__
33 
34 #include <stdint.h>
35 #include "Connector.h"
36 #include "ShiftRegister.h"
37 
38 namespace ClearCore {
39 
46 class LedDriver : public Connector {
47  friend class SysManager;
48 
49 public:
50 #ifndef HIDE_FROM_DOXYGEN
51 
57  LedDriver() {};
58 
66  virtual ConnectorModes Mode() override {
67  return Connector::Mode();
68  }
69 
77  bool Mode(ConnectorModes newMode) override {
78  return newMode == ConnectorModes::OUTPUT_DIGITAL;
79  }
80 #endif
81 
95  }
96 
108  bool IsWritable() override {
109  return true;
110  }
111 
123  int16_t State() override;
124 
135  bool State(int16_t newState) override;
136 
137 #ifndef HIDE_FROM_DOXYGEN
138  bool IsInHwFault() override {
139  return false;
140  }
141 #endif
142 
143 private:
144  ShiftRegister::Masks m_ledMask;
153  void Refresh() override {}
154 
161  void Initialize(ClearCorePins clearCorePin) override {
162  m_clearCorePin = clearCorePin;
163  m_mode = OUTPUT_DIGITAL;
164  }
165 
169  explicit LedDriver(ShiftRegister::Masks ledMask);
170 }; // LedDriver
171 
172 } // ClearCore namespace
173 
174 #endif // __LEDDRIVER_H__
virtual bool IsInHwFault()=0
Get whether the connector is in a hardware fault state.
Definition: Connector.h:203
Base class for interacting with all ClearCore connector objects.
Definition: Connector.h:62
Connector::ConnectorTypes Type() override
Get connector type.
Definition: LedDriver.h:93
Definition: Connector.h:98
Namespace to encompass the ClearCore board API.
Definition: AdcManager.h:36
bool IsWritable() override
Get R/W status of the connector.
Definition: LedDriver.h:108
LED shift register access class.
Base class for all connector classes.
ConnectorModes
All possible operational modes for a connector.
Definition: Connector.h:74
ClearCore LED control class.
Definition: LedDriver.h:46
ClearCore Board Supervisory System Manager.
Definition: SysManager.h:58
int16_t State() override
Get LED&#39;s last sampled state.
ClearCorePins
ClearCore PIN definitions.
Definition: SysConnectors.h:54
virtual ConnectorModes Mode()
Get the connector&#39;s operational mode.
Definition: Connector.h:309
ConnectorTypes
The different types of ClearCore connectors.
Definition: Connector.h:172