ClearCore Library
Loading...
Searching...
No Matches
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
38namespace ClearCore {
39
46class LedDriver : public Connector {
47 friend class SysManager;
48
49public:
50#ifndef HIDE_FROM_DOXYGEN
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
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
143private:
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__
Base class for all connector classes.
LED shift register access class.
ClearCorePins
ClearCore PIN definitions.
Definition SysConnectors.h:54
Base class for interacting with all ClearCore connector objects.
Definition Connector.h:62
virtual bool IsInHwFault()=0
Get whether the connector is in a hardware fault state.
virtual ConnectorModes Mode()
Get the connector's operational mode.
Definition Connector.h:309
ConnectorModes
All possible operational modes for a connector.
Definition Connector.h:74
@ OUTPUT_DIGITAL
Definition Connector.h:98
ConnectorTypes
The different types of ClearCore connectors.
Definition Connector.h:172
@ SHIFT_REG_TYPE
Definition Connector.h:203
ClearCore LED control class.
Definition LedDriver.h:46
int16_t State() override
Get LED's last sampled state.
Connector::ConnectorTypes Type() override
Get connector type.
Definition LedDriver.h:93
bool State(int16_t newState) override
Set the state of the LED.
bool IsWritable() override
Get R/W status of the connector.
Definition LedDriver.h:108
ClearCore Board Supervisory System Manager.
Definition SysManager.h:58
Namespace to encompass the ClearCore board API.
Definition AdcManager.h:36