AceSegment  0.3.0
An adjustable, configurable, and extensible framework for rendering seven segment LED displays.
Driver.cpp
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 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 SOFTWARE.
23 */
24 
25 #include <Arduino.h> // LOW and HIGH
26 #include "LedMatrix.h"
27 #include "Driver.h"
28 
29 namespace ace_segment {
30 
32  if (mOwnsLedMatrix && mLedMatrix) {
33  delete mLedMatrix;
34  }
35 }
36 
38  if (mLedMatrix) {
39  mLedMatrix->configure();
40  }
41 }
42 
44  if (mLedMatrix) {
45  mLedMatrix->finish();
46  }
47 }
48 
49 void Driver::setPattern(uint8_t digit, SegmentPatternType pattern,
50  uint8_t brightness) {
51  if (digit >= mNumDigits) return;
52  DimmablePattern& dimmablePattern = mDimmablePatterns[digit];
53  dimmablePattern.pattern = pattern;
54  dimmablePattern.brightness = brightness;
55 }
56 
57 void Driver::setBrightness(uint8_t digit, uint8_t brightness) {
58  if (digit >= mNumDigits) return;
59  mDimmablePatterns[digit].brightness = brightness;
60 }
61 
62 }
uint8_t SegmentPatternType
Integer type used to store the segment bit patterns of a single digit.
Definition: Driver.h:51
virtual void finish()
Turn off the pins by doing the opposite of configure().
Definition: LedMatrix.h:85
virtual void configure()
Configure the pins for the given LED wiring.
Definition: LedMatrix.h:82
virtual void configure()
Configure the driver.
Definition: Driver.cpp:37
virtual void finish()
Turn off the LEDs by doing the opposite of configure().
Definition: Driver.cpp:43
void setPattern(uint8_t digit, SegmentPatternType pattern, uint8_t brightness=DimmablePattern::kOn)
Set the pattern for a given digit.
Definition: Driver.cpp:49
virtual ~Driver()
Virtual destructor needed to clean up LedMatrix that was created on the heap by DriverBuilder.
Definition: Driver.cpp:31
void setBrightness(uint8_t digit, uint8_t brightness)
Set the brightness of the given digit.
Definition: Driver.cpp:57