AceSegment  0.3.0
An adjustable, configurable, and extensible framework for rendering seven segment LED displays.
LedMatrixDirect.h
1 /*
2 MIT License
3 
4 Copyright (c) 2018 Brian T. Park
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in all
14 copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 SOFTWARE.
22 */
23 
24 #ifndef ACE_SEGMENT_LED_MATRIX_DIRECT_H
25 #define ACE_SEGMENT_LED_MATRIX_DIRECT_H
26 
27 #include "Hardware.h"
28 #include "LedMatrix.h"
29 
30 namespace ace_segment {
31 
32 class LedMatrixDirect: public LedMatrix {
33  public:
34  LedMatrixDirect(Hardware* hardware, uint8_t numGroups, uint8_t numElements):
35  LedMatrix(hardware, numGroups, numElements)
36  {}
37 
38  void setGroupPins(const uint8_t* groupPins);
39 
40  void setElementPins(const uint8_t* elementPins);
41 
42  virtual void configure() override;
43 
44  virtual void finish() override;
45 
46  virtual void enableGroup(uint8_t group) override;
47 
48  virtual void disableGroup(uint8_t group) override;
49 
50  virtual void drawElements(uint8_t pattern) override;
51 
52  private:
54  void writeGroupPin(uint8_t group, uint8_t output) {
55  uint8_t groupPin = mGroupPins[group];
56  mHardware->digitalWrite(groupPin, output);
57  }
58 
60  void writeElementPin(uint8_t element, uint8_t output) {
61  uint8_t elementPin = mElementPins[element];
62  mHardware->digitalWrite(elementPin, output);
63  }
64 
65  const uint8_t* mGroupPins;
66  const uint8_t* mElementPins;
67 };
68 
69 }
70 
71 #endif
virtual void digitalWrite(uint8_t pin, uint8_t value)
Write value to pin.
Definition: Hardware.h:43
Class that represents the abstraction of a particular LED display wiring.
Definition: LedMatrix.h:49
virtual void configure() override
Configure the pins for the given LED wiring.
virtual void finish() override
Turn off the pins by doing the opposite of configure().