22// Copyright (C) 2017 Michael Kamprath
33//
44// This file is part of Shift Register LED Matrix Project.
5- //
5+ //
66// Shift Register LED Matrix Project is free software: you can redistribute it and/or modify
77// it under the terms of the GNU General Public License as published by
88// the Free Software Foundation, either version 3 of the License, or
99// (at your option) any later version.
10- //
10+ //
1111// Shift Register LED Matrix Project is distributed in the hope that it will be useful,
1212// but WITHOUT ANY WARRANTY; without even the implied warranty of
1313// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414// GNU General Public License for more details.
15- //
15+ //
1616// You should have received a copy of the GNU General Public License
1717// along with Shift Register LED Matrix Project. If not, see <http://www.gnu.org/licenses/>.
1818
@@ -35,13 +35,13 @@ class BaseLEDMatrix : public TimerAction {
3535 typedef enum {
3636 // the left most column in the hardware and MSB in the shift register chain is column 0
3737 LED_BIG_ENDIAN,
38-
39- // The columns are laid out in 8 column "bytes" with column 0 being the left most
40- // bit in the right most byte. Column 8 would be the left most bit in the second
38+
39+ // The columns are laid out in 8 column "bytes" with column 0 being the left most
40+ // bit in the right most byte. Column 8 would be the left most bit in the second
4141 // to the right byte.
4242 LED_LITTLE_ENDIAN_8
4343 } DeviceBitEndian;
44-
44+
4545private:
4646 unsigned int _rows;
4747 unsigned int _columns;
@@ -54,37 +54,37 @@ class BaseLEDMatrix : public TimerAction {
5454 unsigned int _interFrameOffTimeInterval;
5555 unsigned int _blankLevel;
5656 DeviceBitEndian _bitEndian;
57-
57+
5858 bool _columnControlBitOn;
5959 bool _rowControlBitOn;
60-
60+
6161 LEDMatrixBits **_curScreenBitFrames;
6262 LEDMatrixBits **_screenBitFrames;
6363 LEDMatrixBits *_allOffBits;
64-
64+
6565 bool _screenBitFrameToggle;
6666 bool _interFrameTransmitOffToggle;
67-
67+
6868 unsigned int _scanPass;
6969 unsigned int _scanRow;
7070 int _isDrawingCount;
7171
7272 SPIConnection _spi;
7373 int _blankPin;
74-
74+
7575 void shiftOutControlRow ( int row, int scanPass );
76-
76+
7777protected:
7878 unsigned int controlRows () const { return _controlRows; }
7979 unsigned int controlColumns () const { return _controlColumns; }
8080 unsigned int rowGroups () const { return _rowGroups; }
8181 unsigned int columnBitWidth () const { return _columnBitWidth; }
8282 virtual void action ();
83-
83+
8484 virtual void generateFrameBits (LEDMatrixBits& frameBits, size_t frame ) const = 0;
8585 virtual bool matrixNeedsUpdate (void ) const = 0;
8686 virtual void matrixHasBeenUpdated (void ) = 0;
87-
87+
8888 virtual unsigned int baseIntervalMultiplier ( size_t frame ) const ;
8989public:
9090
@@ -93,26 +93,26 @@ class BaseLEDMatrix : public TimerAction {
9393 *
9494 * @param rows the number of rows in the LED matrix.
9595 * @param columns the number of columns in the LED matrix.
96- * @param controlRows the number of powered rows in the LED matrix. Control rows are
96+ * @param controlRows the number of powered rows in the LED matrix. Control rows are
9797 * expected to have shared power to the LEDs.
9898 * @param controlColumns the number of control columns in the LED matrix.
99- * @param columnBitWidth the number of bits needed to represent one physical LED in
99+ * @param columnBitWidth the number of bits needed to represent one physical LED in
100100 * a column. E.g., and RGB LED needs 3 bits.
101101 * @param pwmCycleScanCount the number of row scans needed for the PWM cycle of the matrix.
102102 * @param columnControlBitOn what value a column bit should be set to to the column on.
103- * @param rowControlBitOn what value a row bit should be set to to turn the row on.
104- * E.g. of the row is common anode and a PNP transistor is being use
103+ * @param rowControlBitOn what value a row bit should be set to to turn the row on.
104+ * E.g. of the row is common anode and a PNP transistor is being use
105105 * to switch power to the row, the row bit likely needs to be LOW to
106106 * cause the transistor to power the row.
107107 * @param interFrameOffTimeMicros Controls whether an all-off signal is sent to the
108- * shift registers in between row updates in order to mitigate LED
109- * ghosting. A value of 0 indicates that no all-off signal should be
108+ * shift registers in between row updates in order to mitigate LED
109+ * ghosting. A value of 0 indicates that no all-off signal should be
110110 * sent. A value greater than 0 indicates how many microseconds should
111- * be waited until the next row update gets shifted out. Usually a value
111+ * be waited until the next row update gets shifted out. Usually a value
112112 * less than 3 microseconds is sufficient for most slow row power
113113 * switching.
114114 * @param slavePin which pin is used for the latch signal.
115- * @param maxSPISpeed The requested max SPI speed. The board typically picks the
115+ * @param maxSPISpeed The requested max SPI speed. The board typically picks the
116116 * smaller of this and it's own max.
117117 */
118118 BaseLEDMatrix (
@@ -126,48 +126,48 @@ class BaseLEDMatrix : public TimerAction {
126126 bool rowControlBitOn = LOW,
127127 unsigned int interFrameOffTimeMicros = 0 ,
128128#if defined( ESP8266 )
129- int slavePin = D8
129+ int slavePin = D8
130130#elif defined( ESP32 )
131- int slavePin = 5
131+ int slavePin = 5
132132#else
133- int slavePin = 10
133+ int slavePin = 10
134134#endif
135135 ,
136136 DeviceBitEndian bitEndian = LED_BIG_ENDIAN,
137137 unsigned long maxSPISpeed = 18000000
138138 );
139139 virtual ~BaseLEDMatrix ();
140-
140+
141141 /* *
142142 * Should be called before any operations against this object is performed. Child
143- * classes implementing matrix-type specific implementation should call this parent
143+ * classes implementing matrix-type specific implementation should call this parent
144144 * class implementation of setup() before doing their own setup work.
145145 */
146- virtual void setup ();
146+ virtual void setup ();
147147
148148 void enableBlanking (int blankPin = 9 );
149149 void disableBlanking ( void );
150150 void blank (void );
151151 void unblank (void );
152152
153153 /* *
154- * Increments the draw lock. While a matrix has a non-zero draw lock, any changes to
154+ * Increments the draw lock. While a matrix has a non-zero draw lock, any changes to
155155 * the image() buffer will not be pass through to the matrix scan buffer.
156156 */
157157 void startDrawing (void ) { _isDrawingCount++; }
158-
158+
159159 /* *
160- * Decrements the draw lock. All calls to startDrawing() should be balanced with a
160+ * Decrements the draw lock. All calls to startDrawing() should be balanced with a
161161 * call to stopDrawing().
162162 */
163163 void stopDrawing (void ) { _isDrawingCount--; if (_isDrawingCount < 0 ) { _isDrawingCount = 0 ; }}
164-
165-
164+
165+
166166 /* *
167167 * Returns true is a draw lock is active.
168168 */
169169 bool isDrawing (void ) const { return (_isDrawingCount > 0 ); }
170-
170+
171171 /* *
172172 * Returns the number of rows in this matrix.
173173 *
@@ -183,7 +183,7 @@ class BaseLEDMatrix : public TimerAction {
183183 unsigned int columns () const { return _columns; }
184184
185185 /* *
186- * Begins the row scan timer interrupt, which in turn starts sending data through the
186+ * Begins the row scan timer interrupt, which in turn starts sending data through the
187187 * SPI interface to the LED matrix.
188188 */
189189 void startScanning (void );
@@ -196,7 +196,7 @@ class BaseLEDMatrix : public TimerAction {
196196 DeviceBitEndian bitEndian (void ) const { return _bitEndian; }
197197
198198 /* *
199- * This methods are "private" to this class but have to be declared public so
199+ * This methods are "private" to this class but have to be declared public so
200200 * the timer interrupt can access them.
201201 */
202202 bool doInterFrameTransmitOff ( void ) const ;
0 commit comments