DIY Auto-Correlator 1.0
Auto-Correlator Card implementation using Teensy 4.x microcontrollers.
Public Types | Public Member Functions | Public Attributes | Private Member Functions | List of all members
LEDSet< SET_SIZE > Class Template Reference

#include <ledset.hpp>

Public Types

enum  ledstate_t { OFF = 0 , ON = 1 , Analog = 2 }
 

Public Member Functions

 LEDSet (std::initializer_list< unsigned int > pins)
 Constructor for LEDSet class. More...
 
unsigned int size () __attribute__((always_inline))
 Returns the size of the led sets. More...
 
void init ()
 Sets up the pin mode of all LEDs. More...
 
void state_reload ()
 Sets the LEDs based on the value of the corresponding state variable. This function is useful when the state is altered seperately from the digitalWrite calls. The function also calls pinMode() which muxes the pins to gpio. For State == Analog: The state maintains the analog dim state. More...
 
void ON_todigital ()
 Sets all leds with states (ON == 1) and (Analog == 2) to (ON == 1). More...
 
void toggle_all ()
 Toggles the state of all the LEDs. This is a pure digital function and destroys all Analog dim states. More...
 
void toggle_twice (int pin, double time_ms)
 Toggles the state of a particular LED. This is a pure digital function and destroys all Analog dim states. More...
 
void toggle_all_routine (int delay_ms)
 
void dim (int pin, unsigned int analog_val)
 dims a particular valid led pin. More...
 
void dim_all (unsigned int analog_val)
 Dims the ON-LEDs with the provided analog voltage. Only affects LEDs that are ON or on Analog Mode. More...
 
void dim_all_routine (unsigned int end_analog_val, double time_s)
 
void max_bright_all ()
 Sets maximum brightness for all ON-LEDs. More...
 
void min_bright_all ()
 
void set_all () __attribute__((always_inline))
 Turn on all available LEDs. More...
 
void unset_all () __attribute__((always_inline))
 
void set (int led_pin) __attribute__((always_inline))
 Turn-ON a particular LED Pin. More...
 
void unset (int led_pin) __attribute__((always_inline))
 Turn-OFF a particular LED Pin. More...
 
void set (int led_pin1, int led_pin2) __attribute__((always_inline))
 Turn-ON two LED Pins simultaneously. The function only works if both the Pins are valid pins. More...
 
void unset (int led_pin1, int led_pin2) __attribute__((always_inline))
 Turn-OFF two LED Pins simultaneously. More...
 
void set (int led_pin1, int led_pin2, int led_pin3) __attribute__((always_inline))
 Turn-ON three LED Pins simultaneously. More...
 
void unset (int led_pin1, int led_pin2, int led_pin3) __attribute__((always_inline))
 Turn-FF three LED Pins simultaneously. More...
 
void error (int pin)
 Special function that sets a valid pin and sets the flag LedSet::Error_State to true. This function also clears all LED states prior to the Error State but does not modify states set after the error state. More...
 
void assert_errors ()
 Special function that initiates a special routine if the device is in the Error State. It also calls abort() , if that feature macro is enabled. More...
 
bool is_valid_pin (int pin)
 Returns whether the given pin is a "valid pin". A valid pin is a pin that is registered with the LEDSet. More...
 

Public Attributes

const int LEDs [SET_SIZE] = {SAFE_OUTPUT_DUMP_PIN}
 LED pins. More...
 
unsigned int State [SET_SIZE]
 ON-OFF/Analog states for all LEDs. More...
 
bool Error_State = false
 Whether the LED Panel is in an error state. More...
 

Private Member Functions

int fetch_index (int pin) __attribute__((always_inline))
 Retrive data structure index based on the pin number. Returns -1 if the pin was not found. More...
 

Detailed Description

template<unsigned int SET_SIZE>
class LEDSet< SET_SIZE >

@Provides an interface for accessing the LEDs on the dashboar. The object serves primarily as a bookeeping object, and hence, enables state conservation and switching, and automatically manages dimming, and complex routines.

Member Enumeration Documentation

◆ ledstate_t

template<unsigned int SET_SIZE>
enum LEDSet::ledstate_t
Enumerator
OFF 
ON 
Analog 

Constructor & Destructor Documentation

◆ LEDSet()

template<unsigned int SET_SIZE>
LEDSet< SET_SIZE >::LEDSet ( std::initializer_list< unsigned int >  pins)
inline

Constructor for LEDSet class.

Parameters
pins- list of LED pins.

Member Function Documentation

◆ assert_errors()

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::assert_errors ( )
inline

Special function that initiates a special routine if the device is in the Error State. It also calls abort() , if that feature macro is enabled.

◆ dim()

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::dim ( int  pin,
unsigned int  analog_val 
)
inline

dims a particular valid led pin.

◆ dim_all()

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::dim_all ( unsigned int  analog_val)
inline

Dims the ON-LEDs with the provided analog voltage. Only affects LEDs that are ON or on Analog Mode.

◆ dim_all_routine()

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::dim_all_routine ( unsigned int  end_analog_val,
double  time_s 
)
inline

◆ error()

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::error ( int  pin)
inline

Special function that sets a valid pin and sets the flag LedSet::Error_State to true. This function also clears all LED states prior to the Error State but does not modify states set after the error state.

◆ fetch_index()

template<unsigned int SET_SIZE>
int LEDSet< SET_SIZE >::fetch_index ( int  pin)
inlineprivate

Retrive data structure index based on the pin number. Returns -1 if the pin was not found.

Returns
Local array index of pin in the LEDs array (bookeeping object). -1 if the search fails.

◆ init()

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::init ( )
inline

Sets up the pin mode of all LEDs.

◆ is_valid_pin()

template<unsigned int SET_SIZE>
bool LEDSet< SET_SIZE >::is_valid_pin ( int  pin)
inline

Returns whether the given pin is a "valid pin". A valid pin is a pin that is registered with the LEDSet.

◆ max_bright_all()

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::max_bright_all ( )
inline

Sets maximum brightness for all ON-LEDs.

◆ min_bright_all()

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::min_bright_all ( )
inline

Sets the minimum brighness for all ON-LEDs.

◆ ON_todigital()

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::ON_todigital ( )
inline

Sets all leds with states (ON == 1) and (Analog == 2) to (ON == 1).

◆ set() [1/3]

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::set ( int  led_pin)
inline

Turn-ON a particular LED Pin.

◆ set() [2/3]

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::set ( int  led_pin1,
int  led_pin2 
)
inline

Turn-ON two LED Pins simultaneously. The function only works if both the Pins are valid pins.

◆ set() [3/3]

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::set ( int  led_pin1,
int  led_pin2,
int  led_pin3 
)
inline

Turn-ON three LED Pins simultaneously.

◆ set_all()

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::set_all ( )
inline

Turn on all available LEDs.

◆ size()

template<unsigned int SET_SIZE>
unsigned int LEDSet< SET_SIZE >::size ( )
inline

Returns the size of the led sets.

◆ state_reload()

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::state_reload ( )
inline

Sets the LEDs based on the value of the corresponding state variable. This function is useful when the state is altered seperately from the digitalWrite calls. The function also calls pinMode() which muxes the pins to gpio. For State == Analog: The state maintains the analog dim state.

◆ toggle_all()

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::toggle_all ( )
inline

Toggles the state of all the LEDs. This is a pure digital function and destroys all Analog dim states.

◆ toggle_all_routine()

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::toggle_all_routine ( int  delay_ms)
inline

◆ toggle_twice()

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::toggle_twice ( int  pin,
double  time_ms 
)
inline

Toggles the state of a particular LED. This is a pure digital function and destroys all Analog dim states.

◆ unset() [1/3]

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::unset ( int  led_pin)
inline

Turn-OFF a particular LED Pin.

◆ unset() [2/3]

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::unset ( int  led_pin1,
int  led_pin2 
)
inline

Turn-OFF two LED Pins simultaneously.

◆ unset() [3/3]

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::unset ( int  led_pin1,
int  led_pin2,
int  led_pin3 
)
inline

Turn-FF three LED Pins simultaneously.

◆ unset_all()

template<unsigned int SET_SIZE>
void LEDSet< SET_SIZE >::unset_all ( )
inline

Turn off all available LEDs.

Member Data Documentation

◆ Error_State

template<unsigned int SET_SIZE>
bool LEDSet< SET_SIZE >::Error_State = false

Whether the LED Panel is in an error state.

◆ LEDs

template<unsigned int SET_SIZE>
const int LEDSet< SET_SIZE >::LEDs[SET_SIZE] = {SAFE_OUTPUT_DUMP_PIN}

LED pins.

◆ State

template<unsigned int SET_SIZE>
unsigned int LEDSet< SET_SIZE >::State[SET_SIZE]

ON-OFF/Analog states for all LEDs.


The documentation for this class was generated from the following file: