Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
AH Namespace Reference

Detailed Description

PrintStream library

Namespaces

namespace  detail
 
namespace  ExtIO
 A namespace with alternatives to the standard Arduino IO functions that can be used with extended IO pin numbers.
 

Classes

class  AnalogMultiplex
 A class for reading multiplexed analog inputs. More...
 
struct  Array
 An array wrapper for easy copying, comparing, and iterating. More...
 
class  ArraySlice
 Class for a view on a slice of an array. More...
 
class  BitArray
 A class for arrays of bits. More...
 
class  Button
 A class for reading and debouncing buttons and switches. More...
 
class  ButtonMatrix
 A class that reads the states of a button matrix. More...
 
class  DotBarDisplayLEDs
 A class for LED bars. More...
 
class  EMA
 Exponential moving average filter. More...
 
class  EMA_f
 A class for single-pole infinite impulse response filters or exponential moving average filters. More...
 
struct  EulerAngles
 Struct for Euler angles of floating point numbers. More...
 
class  ExtendedIOElement
 An abstract base class for Extended Input/Output elements. More...
 
class  FilteredAnalog
 A class that reads and filters an analog input. More...
 
class  Frequency
 Type-safe class for frequency values. More...
 
struct  function_traits
 
struct  function_traits< Return(Args...)>
 
class  GenericFilteredAnalog
 FilteredAnalog base class with generic MappingFunction. More...
 
struct  HexDump
 
class  Hysteresis
 A class for applying hysteresis to a given input. More...
 
class  Hysteresis< 0, T_in, T_out >
 
class  IncrementButton
 A class for buttons that increment some counter or setting. More...
 
class  IncrementDecrementButtons
 A class for buttons that increment and decrement some counter or setting. More...
 
class  LEDs
 A class for collections of LEDs that can display ranges. More...
 
class  MAX7219
 A class for LED outputs using the MAX7219 LED display driver. More...
 
class  MAX7219_Base
 A base class for classes that control MAX7219 LED drivers. More...
 
class  MAX7219SevenSegmentDisplay
 A class for 8-digit 7-segment displays with a MAX7219 driver. More...
 
struct  MaximumFilteredAnalogIncRes
 Helper to determine how many of the remaining bits of the filter data types can be used to achieve higher precision. More...
 
class  MCP23017
 Class for MCP23017 I²C I/O expanders. More...
 
class  MCP23017Encoders
 Class for reading 8 rotary encoders using a MCP23017 I²C port expander. More...
 
class  MultiPurposeButton
 Class for detecting short/long button presses and double clicks. More...
 
struct  NormalUpdatable
 
struct  Quaternion
 Type for quaternions of floating point numbers. More...
 
class  RegisterEncoders
 Class for keeping track of the position of multiple rotary encoders. More...
 
struct  round_div_default
 Divide by N using the default division operator, without explicit rounding This should be used for floating point types. More...
 
struct  round_div_helper
 Select the right rounding division operator, depending on whether T is an integer or not. More...
 
struct  round_div_int
 Select the right rounding division operator, depending on whether T is a signed or unsigned integer. More...
 
struct  round_div_signed_int
 Divide a signed integer by N, rounding the result. More...
 
struct  round_div_unsigned_int
 Divide an unsigned integer by N, rounding the result. More...
 
struct  Setbase
 
struct  Setbytesep
 
struct  Setprecision
 
class  ShiftRegisterOut
 A class for serial-in/parallel-out shift registers, like the 74HC595. More...
 
class  ShiftRegisterOutBase
 A class for serial-in/parallel-out shift registers, like the 74HC595. More...
 
struct  ShiftRegisterOutRGB
 A struct for setting the RGB mode for RGB shift registers. More...
 
class  SPIShiftRegisterOut
 A class for serial-in/parallel-out shift registers, like the 74HC595 that are connected to the SPI bus. More...
 
class  StaticSizeExtendedIOElement
 A class for ExtendedIOElements with a fixed size. More...
 
class  Timer
 A class for easily managing timed events. More...
 
class  Updatable
 A super class for object that have to be updated regularly. More...
 
class  UpdatableCRTP
 A super class for object that have to be updated regularly. More...
 
struct  Vec2f
 Type for 2D vectors of floating point numbers. More...
 
struct  Vec3f
 Type for 3D vectors of floating point numbers. More...
 

Typedefs

template<class T , size_t NumRows, size_t NumCols>
using Array2D = Array<Array<T, NumCols>, NumRows>
 An easy alias for two-dimensional Arrays.
 
using CD74HC4067 = AnalogMultiplex<4>
 An alias for AnalogMultiplex<4> to use with CD74HC4067 analog multiplexers.
 
using CD74HC4051 = AnalogMultiplex<3>
 An alias for AnalogMultiplex<3> to use with CD74HC4051 analog multiplexers.
 
using analog_t = uint16_t
 The type returned from analogRead and similar functions.
 
using pin_int_t = uint_fast16_t
 Integer type used internally to store the index of (extended) GPIO pins.
 
template<size_t N>
using PinList = Array<pin_t, N>
 An easy alias for arrays of pins.
 
typedef Print & manipulator(Print &)
 
using ANALOG_FILTER_TYPE = uint16_t
 The unsigned integer type to use for analog inputs during filtering.
 
using timefunction = unsigned long (*)()
 A function type that returns a time value.
 

Enumerations

enum class  DotBarMode : bool { Bar = false , Dot = true }
 An enumeration type to set an LED display to either bar or dot mode. More...
 
enum  : char { LOWERCASE = 0x7F , UPPERCASE = 0x5F }
 

Functions

template<class T >
constexpr T abs_diff (const T &a, const T &b)
 
template<class T , size_t N, class G >
Array< T, N > generateArray (G generator)
 Generate an array using the given generator.
 
template<size_t N, class G >
auto generateArray (G generator) -> Array< decltype(generator()), N >
 Generate an array using the given generator.
 
template<class T , size_t N, class U >
Array< T, N > copyAs (const Array< U, N > &src)
 Copy an Array to an Array of a different type.
 
template<class F , class U , size_t N>
Array< decltype(F{}(U{})), N > apply (const Array< U, N > &src, F f)
 Apply a function to all elements of the array and return a copy.
 
template<class T , size_t N, class... Args>
Array< T, N > fillArray (Args... args)
 Fill the array with the same value for each element.
 
template<class T , size_t N, class U , class V = U>
Array< T, N > generateIncrementalArray (U start=0, V increment=V(1))
 Generate an array where the first value is given, and the subsequent values are calculated as the previous value incremented with a given value:
\( x[0] = \mathrm{start} \)
\( x[k+1] = x[k] + \mathrm{increment} \) .
 
template<class T , size_t M, size_t N>
Array< T, M+N > cat (const Array< T, M > &a, const Array< T, N > &b)
 Concatenate two arrays.
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Reverse2, bool Const1, bool Const2>
Array< decltype(T1() *T2()), N1+N2 - 1 > distribute (const ArraySlice< T1, N1, Reverse1, Const1 > &a, const ArraySlice< T2, N2, Reverse2, Const2 > &b)
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse1, bool Const1>
Array< decltype(T1() *T2()), N1+N2 - 1 > distribute (const ArraySlice< T1, N1, Reverse1, Const1 > &a, const Array< T2, N2 > &b)
 
template<class T1 , class T2 , size_t N1, size_t N2, bool Reverse2, bool Const2>
Array< decltype(T1() *T2()), N1+N2 - 1 > distribute (const Array< T1, N1 > &a, const ArraySlice< T2, N2, Reverse2, Const2 > &b)
 
template<class T1 , class T2 , size_t N1, size_t N2>
Array< decltype(T1() *T2()), N1+N2 - 1 > distribute (const Array< T1, N1 > &a, const Array< T2, N2 > &b)
 
template<class T , size_t N, bool Reverse, bool Const>
std::enable_if_t< std::is_arithmetic< T >::value, Print & > operator<< (Print &os, const AH::ArraySlice< T, N, Reverse, Const > &a)
 
template<class T , size_t N>
std::enable_if_t< std::is_arithmetic< T >::value, Print & > operator<< (Print &os, const AH::Array< T, N > &a)
 
void fatalErrorExit () __attribute__((noreturn))
 Function that executes and loops forever, blinking the built-in LED when a fatal error is encountered.
 
template<class T >
constexpr ArduinoPin_t arduino_pin_cast (T t)
 
constexpr ArduinoPin_t arduino_pin_cast (pin_t t)
 
template<class T >
constexpr std::enable_if< std::is_floating_point< T >::value, T >::type rad2deg (T r)
 Convert radians to degrees.
 
template<class T >
constexpr std::enable_if< std::is_floating_point< T >::value, T >::type deg2rad (T d)
 Convert degrees to radians.
 
template<size_t N, class T >
T round_div (T val)
 Divide a number by N and round the result.
 
template<size_t Bits_out, size_t Bits_in, class T_out , class T_in >
T_out increaseBitDepth (T_in in)
 Increase the bit depth of the given value from Bits_in bits wide to Bits_out bits wide, (approximately) evenly distributing the error across the entire range, such that the error for each element is between -1 and +1.
 
template<size_t Bits_out, size_t Bits_in, class T_out , class T_in >
T_out increaseBitDepthMiddle (T_in in)
 Increase the bit depth of the given value from Bits_in bits wide to Bits_out bits wide, while ensuring that the middle of the input range maps exactly to the middle of the output range, i.e.
 
template<class T , class U >
constexpr auto min (const T &a, const U &b) -> decltype(b< a ? b :a)
 Return the smaller of two numbers/objects.
 
template<class T , class U >
constexpr auto max (const T &a, const U &b) -> decltype(a< b ? b :a)
 Return the larger of two numbers/objects.
 
Print & operator<< (Print &os, Quaternion q)
 
Print & operator<< (Print &os, EulerAngles e)
 
template<class T >
Print & printIntegral (Print &printer, T i)
 
Print & endl (Print &printer)
 
Print & uppercase (Print &printer)
 
Print & nouppercase (Print &printer)
 
Print & showbase (Print &printer)
 
Print & noshowbase (Print &printer)
 
Print & flush (Print &printer)
 
Print & hex (Print &printer)
 
Print & bin (Print &printer)
 
Print & dec (Print &printer)
 
Print & boolalpha (Print &printer)
 
Print & noboolalpha (Print &printer)
 
Print & leadingzeros (Print &printer)
 
Print & noleadingzeros (Print &printer)
 
Print & operator<< (Print &printer, const __FlashStringHelper *s)
 
Print & operator<< (Print &printer, const String &s)
 
Print & operator<< (Print &printer, const char s[])
 
Print & operator<< (Print &printer, char c)
 
Print & operator<< (Print &printer, unsigned char i)
 
Print & operator<< (Print &printer, int i)
 
Print & operator<< (Print &printer, unsigned int i)
 
Print & operator<< (Print &printer, int8_t i)
 
Print & operator<< (Print &printer, long i)
 
Print & operator<< (Print &printer, unsigned long i)
 
Print & operator<< (Print &printer, double d)
 
Print & operator<< (Print &printer, float f)
 
Print & operator<< (Print &printer, const Printable &p)
 
Print & operator<< (Print &printer, bool b)
 
Print & operator<< (Print &printer, manipulator pf)
 
Setbase setbase (uint8_t base)
 
Print & operator<< (Print &printer, Setbase f)
 
Setbytesep setbytesep (char bytesep)
 
Print & operator<< (Print &printer, Setbytesep f)
 
Setprecision setprecision (int n)
 
Print & operator<< (Print &printer, Setprecision f)
 
static char nibble_to_hex (uint8_t nibble)
 
template<class T >
void printHex (Print &printer, T val)
 
template<class T >
void printBin (Print &printer, T val)
 
Print & operator<< (Print &p, HexDump h)
 

Variables

constexpr pin_int_t NO_PIN_INT
 
constexpr pin_t NO_PIN {}
 A special pin number that indicates an unused or invalid pin.
 
static constexpr uint8_t SevenSegmentCharacters [0x40]
 A lookup table for 7-segment characters, as specified by the Logic Control manual.
 
static constexpr const uint8_tAlphaChars = &SevenSegmentCharacters[0x01]
 
static constexpr const uint8_tNumericChars = &SevenSegmentCharacters[0x30]
 
static constexpr int8_t RegisterEncodersLUT [16]
 Lookup table that maps rotary encoder (2-bit gray code) state changes to position deltas.
 
uint8_t formatPrintStream = DEC
 
bool boolalphaPrintStream = false
 
bool leadingZerosPrintStream = false
 
uint8_t precisionPrintStream = 2
 
char byteSeparatorPrintStream = '\0'
 
enum AH:: { ... }  casePrintStream = LOWERCASE
 
bool showbasePrintStream = false
 
constexpr unsigned long defaultBaudRate = 115200
 The default baud rate for debug output.
 
constexpr uint8_t ADC_BITS = 10
 The bit depth to use for the ADC (Analog to Digital Converter).
 
constexpr uint8_t ANALOG_FILTER_SHIFT_FACTOR = 2
 The factor for the analog filter:
Difference equation: \( y[n] = \alpha\cdot x[n] + (1-\alpha)\cdot y[n-1] \) where \( \alpha = \left(\frac{1}{2}\right)^{ANALOG\_FILTER\_SHIFT\_FACTOR} \).
 
constexpr unsigned long BUTTON_DEBOUNCE_TIME = 25
 The debounce time for momentary push buttons in milliseconds.
 
constexpr unsigned long SELECT_LINE_DELAY = 10
 The time in microseconds to wait for lines of multiplexers and scanning matrices to settle before reading the value.
 
constexpr unsigned long LONG_PRESS_DELAY = 450
 The time in milliseconds before a press is registered as a long press.
 
constexpr unsigned long LONG_PRESS_REPEAT_DELAY = 200
 The time between increments/decremnets during a long press.
 
constexpr unsigned long FILTERED_INPUT_UPDATE_INTERVAL = 1000
 The interval between updating filtered analog inputs, in microseconds.
 
static constexpr Frequency SPI_MAX_SPEED = 8_MHz
 

Typedef Documentation

◆ analog_t

The type returned from analogRead and similar functions.

Definition at line 14 of file Hardware-Types.hpp.

◆ pin_int_t

Integer type used internally to store the index of (extended) GPIO pins.

This type is also used to represent offsets of pin numbers (e.g. the index of a pin within an extended IO element). In contrast, ExtIO::pin_t represents an absolute pin number.

Definition at line 19 of file Hardware-Types.hpp.

◆ PinList

template<size_t N>
using PinList = Array<pin_t, N>

An easy alias for arrays of pins.

Definition at line 100 of file Hardware-Types.hpp.

◆ ANALOG_FILTER_TYPE

The unsigned integer type to use for analog inputs during filtering.

See also
FilteredAnalog

Definition at line 73 of file AH/Settings/Settings.hpp.

Enumeration Type Documentation

◆ DotBarMode

An enumeration type to set an LED display to either bar or dot mode.

Enumerator
Bar 

Turn on a range of LEDs up to the active LED.

Dot 

Turn on only the active LED.

Definition at line 12 of file DotBarDisplayLEDs.hpp.

◆ anonymous enum

Enumerator
LOWERCASE 
UPPERCASE 

Definition at line 22 of file PrintStream.cpp.

Function Documentation

◆ abs_diff()

template<class T >
constexpr T abs_diff ( const T & a,
const T & b )
constexpr

Definition at line 13 of file Array.hpp.

◆ operator<<() [1/4]

template<class T , size_t N, bool Reverse, bool Const>
std::enable_if_t< std::is_arithmetic< T >::value, Print & > operator<< ( Print & os,
const AH::ArraySlice< T, N, Reverse, Const > & a )

Definition at line 40 of file ArrayHelpers.hpp.

◆ operator<<() [2/4]

template<class T , size_t N>
std::enable_if_t< std::is_arithmetic< T >::value, Print & > operator<< ( Print & os,
const AH::Array< T, N > & a )

Definition at line 40 of file ArrayHelpers.hpp.

◆ fatalErrorExit()

void fatalErrorExit ( )
extern

Function that executes and loops forever, blinking the built-in LED when a fatal error is encountered.

Definition at line 7 of file Exit.cpp.

◆ arduino_pin_cast() [1/2]

template<class T >
constexpr ArduinoPin_t arduino_pin_cast ( T t)
constexpr

Definition at line 68 of file Arduino-Hardware-Types.hpp.

◆ arduino_pin_cast() [2/2]

constexpr ArduinoPin_t arduino_pin_cast ( pin_t t)
constexpr

Definition at line 71 of file Arduino-Hardware-Types.hpp.

◆ round_div()

template<size_t N, class T >
T round_div ( T val)

Divide a number by N and round the result.

Uses different specializations for integers to implement efficient rounding.

Definition at line 54 of file Divide.hpp.

◆ operator<<() [3/4]

Print & operator<< ( Print & os,
Quaternion q )
related

Definition at line 26 of file Quaternion.cpp.

◆ operator<<() [4/4]

Print & operator<< ( Print & os,
EulerAngles e )
related

Definition at line 30 of file Quaternion.cpp.

◆ printIntegral()

template<class T >
Print & printIntegral ( Print & printer,
T i )

Definition at line 227 of file PrintStream.cpp.

◆ nibble_to_hex()

static char nibble_to_hex ( uint8_t nibble)
static

Definition at line 171 of file PrintStream.cpp.

◆ printHex()

template<class T >
void printHex ( Print & printer,
T val )

Definition at line 182 of file PrintStream.cpp.

◆ printBin()

template<class T >
void printBin ( Print & printer,
T val )

Definition at line 200 of file PrintStream.cpp.

Variable Documentation

◆ NO_PIN_INT

constexpr pin_int_t NO_PIN_INT
constexpr
Initial value:
=
(std::numeric_limits<pin_int_t>::max() >> 1) + 1

Definition at line 20 of file Hardware-Types.hpp.

◆ NO_PIN

constexpr pin_t NO_PIN {}
constexpr

A special pin number that indicates an unused or invalid pin.

Definition at line 96 of file Hardware-Types.hpp.

◆ SevenSegmentCharacters

constexpr uint8_t SevenSegmentCharacters[0x40]
staticconstexpr
Initial value:
= {
0b00000000, 0b01110111, 0b00011111, 0b01001110,
0b00111101, 0b01001111, 0b01000111, 0b01011110,
0b00010111, 0b00110000, 0b00111100, 0b00000111,
0b00001110, 0b01110110, 0b00010101, 0b00011101,
0b01100111, 0b01110011, 0b00000101, 0b01011011,
0b00001111, 0b00011100, 0b00100111, 0b00111110,
0b00110111, 0b00111011, 0b01101101, 0b01001110,
0b00010011, 0b01111000, 0b01100010, 0b00001000,
0b00000000, 0b00000000, 0b00100010, 0b01100011,
0b01011011, 0b01100111, 0b01111101, 0b00000010,
0b01001110, 0b01111000, 0b01100011, 0b00110001,
0b00000100, 0b00000001, 0b00001000, 0b00100101,
0b01111110, 0b00110000, 0b01101101, 0b01111001,
0b00110011, 0b01011011, 0b01011111, 0b01110000,
0b01111111, 0b01111011, 0b00000000, 0b01000100,
0b00110001, 0b00001001, 0b00000111, 0b01100101,
}

A lookup table for 7-segment characters, as specified by the Logic Control manual.

A | | F | | B |__G__| | | E | | C |__D__| o DP

Definition at line 20 of file MAX7219SevenSegmentDisplay.hpp.

◆ AlphaChars

constexpr const uint8_t* AlphaChars = &SevenSegmentCharacters[0x01]
staticconstexpr

Definition at line 39 of file MAX7219SevenSegmentDisplay.hpp.

◆ NumericChars

constexpr const uint8_t* NumericChars = &SevenSegmentCharacters[0x30]
staticconstexpr

Definition at line 40 of file MAX7219SevenSegmentDisplay.hpp.

◆ RegisterEncodersLUT

constexpr int8_t RegisterEncodersLUT[16]
staticconstexpr
Initial value:
= {
0,
+1,
-1,
+2,
-1,
0,
-2,
+1,
+1,
-2,
0,
-1,
+2,
-1,
+1,
0,
}

Lookup table that maps rotary encoder (2-bit gray code) state changes to position deltas.

Definition at line 14 of file RegisterEncoders.hpp.

◆ formatPrintStream

uint8_t formatPrintStream = DEC

Definition at line 17 of file PrintStream.cpp.

◆ boolalphaPrintStream

bool boolalphaPrintStream = false

Definition at line 18 of file PrintStream.cpp.

◆ leadingZerosPrintStream

bool leadingZerosPrintStream = false

Definition at line 19 of file PrintStream.cpp.

◆ precisionPrintStream

uint8_t precisionPrintStream = 2

Definition at line 20 of file PrintStream.cpp.

◆ byteSeparatorPrintStream

char byteSeparatorPrintStream = '\0'

Definition at line 21 of file PrintStream.cpp.

◆ []

enum { ... } casePrintStream

◆ showbasePrintStream

bool showbasePrintStream = false

Definition at line 23 of file PrintStream.cpp.

◆ defaultBaudRate

constexpr unsigned long defaultBaudRate = 115200
constexpr

The default baud rate for debug output.

Definition at line 38 of file AH/Settings/Settings.hpp.

◆ ADC_BITS

constexpr uint8_t ADC_BITS = 10
constexpr

The bit depth to use for the ADC (Analog to Digital Converter).

By default, the maximum supported resolution is used, but if you need it for compatibility with other code that expects the default 10-bit resolution, you can use

constexpr uint8_t ADC_BITS = 10;
A class for serial-in/parallel-out shift registers, like the 74HC595 that are connected to the SPI bu...
constexpr uint8_t ADC_BITS
The bit depth to use for the ADC (Analog to Digital Converter).

If the library doesn't know your specific hardware, it defaults to 10 bits. This might not be the optimal resolution, so it's best to add the actual resolution to Hardware/ADCConfig.hpp.

Definition at line 55 of file AH/Settings/Settings.hpp.

◆ ANALOG_FILTER_SHIFT_FACTOR

constexpr uint8_t ANALOG_FILTER_SHIFT_FACTOR = 2
constexpr

The factor for the analog filter:
Difference equation: \( y[n] = \alpha\cdot x[n] + (1-\alpha)\cdot y[n-1] \) where \( \alpha = \left(\frac{1}{2}\right)^{ANALOG\_FILTER\_SHIFT\_FACTOR} \).

See also
FilteredAnalog

Definition at line 66 of file AH/Settings/Settings.hpp.

◆ BUTTON_DEBOUNCE_TIME

constexpr unsigned long BUTTON_DEBOUNCE_TIME = 25
constexpr

The debounce time for momentary push buttons in milliseconds.

Definition at line 76 of file AH/Settings/Settings.hpp.

◆ SELECT_LINE_DELAY

constexpr unsigned long SELECT_LINE_DELAY = 10
constexpr

The time in microseconds to wait for lines of multiplexers and scanning matrices to settle before reading the value.


Has no effect on AVR.

Definition at line 81 of file AH/Settings/Settings.hpp.

◆ LONG_PRESS_DELAY

constexpr unsigned long LONG_PRESS_DELAY = 450
constexpr

The time in milliseconds before a press is registered as a long press.

Definition at line 84 of file AH/Settings/Settings.hpp.

◆ LONG_PRESS_REPEAT_DELAY

constexpr unsigned long LONG_PRESS_REPEAT_DELAY = 200
constexpr

The time between increments/decremnets during a long press.

Definition at line 87 of file AH/Settings/Settings.hpp.

◆ FILTERED_INPUT_UPDATE_INTERVAL

constexpr unsigned long FILTERED_INPUT_UPDATE_INTERVAL = 1000
constexpr

The interval between updating filtered analog inputs, in microseconds.

Definition at line 90 of file AH/Settings/Settings.hpp.

◆ SPI_MAX_SPEED

constexpr Frequency SPI_MAX_SPEED = 8_MHz
staticconstexpr

Definition at line 92 of file AH/Settings/Settings.hpp.