src/LED_Array_4x5.cpp
/**
 * @brief Configures the pins on the Charlieplex array.
 *
 * You must call this function before performing any other actions on the
 * LED array.
 *
 * @param[in] pins Array of pin numbers. Must be 8 bytes long.
 * @return True if array configured. False on error.
 */
@brief Configures the pins on the Charlieplex array.
You must call this function before performing any other actions on the
LED array.

@param[in] pins Array of pin numbers. Must be 8 bytes long.
@return True if array configured. False on error.
@brief Configures the pins on the Charlieplex array . You must call this function before performing any other actions on the LED array . @param [ in ] pins Array of pin numbers . Must be 8 bytes long . @return True if array configured . False on error .
bool LED_Array_4x5::init(byte pins[NUM_CHAPLEX_PINS])
{
#if defined __AVR_ATtiny85__
	if ( scrolling_ )
	{
		stopScrolling();
	}
	scrolling_ = 0;
    shift_count_ = 0;
    shift_delay_ = DEFAULT_SHIFT_DELAY;
    scroll_index_ = 0;
    scroll_len_ = 0;
	if ( chaplex_ != NULL ) 
    {
        delete chaplex_;
    }
	chaplex_ = new Chaplex(pins, NUM_CHAPLEX_PINS);
    timer1_count_ = 256 - (2 * (F_CPU / 1000000));  
    noInterrupts();             			
    TCCR1 = 0; 								
    TCCR1 |= (1 << CS13) | (1 << CS11) | (1 << CS10);	
	TCNT1 = timer1_count_;      			
    TIMSK |= (1 << TOIE1);      			
    interrupts();               			
    clear();
    display();
    return true;
#else	
    return false;
#endif	
}
bool LED_Array_4x5 :: init ( byte pins [ NUM_CHAPLEX_PINS ] ) { #if defined __AVR_ATtiny85__ if ( scrolling_ ) { stopScrolling ( ) ; } scrolling_ = 0 ; shift_count_ = 0 ; shift_delay_ = DEFAULT_SHIFT_DELAY ; scroll_index_ = 0 ; scroll_len_ = 0 ; if ( chaplex_ != NULL ) { delete chaplex_ ; } chaplex_ = new Chaplex ( pins , NUM_CHAPLEX_PINS ) ; timer1_count_ = 256 - ( 2 * ( F_CPU / 1000000 ) ) ; noInterrupts ( ) ; TCCR1 = 0 ; TCCR1 |= ( 1 << CS13 ) | ( 1 << CS11 ) | ( 1 << CS10 ) ; TCNT1 = timer1_count_ ; TIMSK |= ( 1 << TOIE1 ) ; interrupts ( ) ; clear ( ) ; display ( ) ; return true ; #else return false ; #endif }
@brief Configures the pins on the Charlieplex array.
@brief Configures the pins on the Charlieplex array .
// Right now, we only compile for the ATtiny85-based Arduinos // If we are scrolling, stop and delete our string buffer // Initialize members (again) // If we already have a Chaplex object, delete it // Create a new Chaplex object so we can write stuff to the LEDs // Calculate the Timer 2 reset number. Aim for 2.048 ms refresh. // count = 256 - (2.048 ms * F_CPU) / 1024 */ // Aim for 2.048ms refresh // Initialize Timer 1 // Disable interrupts // Normal operation, clear prescaler // Prescaler = 1024 // Load counter // Enable timer overflow // Enable all interrupts // Clear and load frame buffer // if defined __AVR_ATtiny85__ // if defined __AVR_ATtiny85__