@@ -129,7 +129,7 @@ ICACHE_RAM_ATTR void BaseLEDMatrix::incrementScanRow( void ) {
129129}
130130
131131// Number of 5 microsecond units
132- ICACHE_RAM_ATTR unsigned int BaseLEDMatrix::multiplier5microseconds ( size_t frame ) const {
132+ ICACHE_RAM_ATTR unsigned int BaseLEDMatrix::baseIntervalMultiplier ( size_t frame ) const {
133133 // base case does nothing interesting
134134 return 1 ;
135135}
@@ -182,7 +182,7 @@ void BaseLEDMatrix::stopScanning(void) {
182182
183183unsigned int BaseLEDMatrix::nextTimerInterval (void ) const {
184184 // Calculates the microseconds for each scan
185- return 5 *this ->multiplier5microseconds ( _scanPass );
185+ return 5 *this ->baseIntervalMultiplier ( _scanPass );
186186}
187187
188188#pragma mark ESP8266 Handlers
@@ -227,7 +227,7 @@ void BaseLEDMatrix::stopScanning(void) {
227227
228228ICACHE_RAM_ATTR unsigned int BaseLEDMatrix::nextTimerInterval (void ) const {
229229 // Calculates the microseconds for each scan
230- return 5 *this ->multiplier5microseconds ( _scanPass );
230+ return 5 *this ->baseIntervalMultiplier ( _scanPass );
231231}
232232
233233#pragma mark Arduino Due Handlers
@@ -259,7 +259,7 @@ unsigned int BaseLEDMatrix::nextTimerInterval(void) const {
259259 // Calculates the microseconds for each scan
260260 // The base interval is set to 55, which for the
261261 // 10.5MHz CLOCK2 yields a ~5 micro second interval.
262- return 55 *this ->multiplier5microseconds ( _scanPass );
262+ return 55 *this ->baseIntervalMultiplier ( _scanPass );
263263}
264264
265265void BaseLEDMatrix::stopScanning (void ) {
@@ -325,7 +325,7 @@ unsigned int BaseLEDMatrix::nextTimerInterval(void) const {
325325 // Calculates the microseconds for each scan
326326 // The base interval is set to 59, which with a /4
327327 // prescaler should yield a 5 ms interval.
328- return 59 *this ->multiplier5microseconds ( _scanPass );
328+ return 59 *this ->baseIntervalMultiplier ( _scanPass );
329329}
330330
331331void BaseLEDMatrix::stopScanning (void ) {
@@ -372,20 +372,19 @@ void BaseLEDMatrix::startScanning(void) {
372372 this ->setup ();
373373
374374 noInterrupts (); // disable all interrupts
375-
376- TIMSK2 &= ~(1 <<TOIE2); // disable timer overflow interupt
375+
376+ TIMSK2 &= ~(1 <<TOIE2); // disable timer overflow interupt
377377
378378 // SET timer2 to count up mode
379379 TCCR2A &= ~((1 <<WGM21) | (1 <<WGM20));
380380 TCCR2B &= ~(1 <<WGM22);
381-
382381 // set clock to I/O clock
383- ASSR &= ~(1 <<AS2);
384-
385- // overflow only mode
386- TIMSK2 &= ~(1 <<OCIE2A);
387-
388- // configure to fire about every 5 micro-second
382+ ASSR &= ~(1 <<AS2);
383+
384+ // overflow only mode
385+ TIMSK2 &= ~(1 <<OCIE2A);
386+
387+ // configure to fire about every 5 micro-second
389388 TCCR2B |= (1 <<CS22) ;
390389 TCCR2B &= ~(1 <<CS20);
391390 TCCR2B &= ~(1 <<CS21);
@@ -402,19 +401,21 @@ void BaseLEDMatrix::stopScanning(void) {
402401}
403402
404403unsigned int BaseLEDMatrix::nextTimerInterval (void ) const {
405- return max (257 - this ->multiplier5microseconds ( _scanPass )*BASE_SCAN_TIMER_INTERVALS, 0 );
404+ return max (257 - this ->baseIntervalMultiplier ( _scanPass )*BASE_SCAN_TIMER_INTERVALS, 0 );
406405}
407406
408-
409407ISR (TIMER2_OVF_vect) {
410- noInterrupts ();
408+ noInterrupts (); // disable all interrupts
409+
411410 // shift out next row
412411 gSingleton ->shiftOutCurrentRow ();
412+
413413 // reload the timer
414- TCNT2 = gSingleton ->nextTimerInterval ();
415- interrupts ();
416- // update scan row. Done outside of interrupt stoppage since execution time can
417- // be inconsistent, which would lead to vary brightness in rows.
418- gSingleton ->incrementScanRow ();
414+ TCNT2 = gSingleton ->nextTimerInterval ();
415+ interrupts (); // enable all interrupts
416+
417+ // update scan row. Done outside of interrupt stoppage since execution time can
418+ // be inconsistent, which would lead to vary brightness in rows.
419+ gSingleton ->incrementScanRow ();
419420}
420421#endif
0 commit comments