Control Surface  1.1.0
MIDI Control Surface library for Arduino
AH/Settings/Settings.hpp
Go to the documentation of this file.
1 #ifndef AH_SETTINGSWRAPPER_HPP
2 #error "Do not include this file directly, use the wrapper!"
3 #endif
4 
5 /**
6  * @file
7  * @brief All user settings and debugging options can be changed here.
8  * @ingroup AH_Settings
9  */
10 
11 #include <AH/Types/Frequency.hpp>
13 #include <limits.h> // CHAR_BIT
14 #include <stddef.h>
15 #include <stdint.h>
16 
18 
19 // ----------------------------- Debug Settings ----------------------------- //
20 // ========================================================================== //
21 
22 /// The debug output.
23 /// Use `#define DEBUG_OUT Serial` to print debugging information to the serial
24 /// monitor.
25 /// @note Printing debug information can slow down the program dramatically.
26 #define DEBUG_OUT
27 // #define DEBUG_OUT Serial
28 
29 /// Exit when encountering an error, instead of trying to recover (recommended).
30 #define FATAL_ERRORS
31 
32 // ----------------------------- User Settings ------------------------------ //
33 // ========================================================================== //
34 
35 /// The default baud rate for debug output.
36 constexpr unsigned long defaultBaudRate = 115200;
37 
38 /**
39  * The bit depth to use for the ADC (Analog to Digital Converter).
40  *
41  * By default, the maximum supported resolution is used, but if you need it for
42  * compatibility with other code that expects the default 10-bit resolution, you
43  * can use
44  *
45  * ```cpp
46  * constexpr uint8_t ADC_BITS = 10;
47  * ```
48  *
49  * If the library doesn't know your specific hardware, it defaults to 10 bits.
50  * This might not be the optimal resolution, so it's best to add the actual
51  * resolution to @ref Hardware/ADCConfig.hpp.
52  */
53 constexpr uint8_t ADC_BITS = ADC_RESOLUTION;
54 
55 /**
56  * The factor for the analog filter:
57  * Difference equation:
58  * @f$ y[n] = \alpha\cdot x[n] + (1-\alpha)\cdot y[n-1] @f$
59  * where
60  * @f$ \alpha = \left(\frac{1}{2}\right)^{ANALOG\_FILTER\_SHIFT\_FACTOR} @f$
61  *
62  * @see FilteredAnalog
63  */
64 constexpr uint8_t ANALOG_FILTER_SHIFT_FACTOR = 2;
65 
66 /**
67  * The unsigned integer type to use for analog inputs during filtering.
68  *
69  * @see FilteredAnalog
70  */
71 using ANALOG_FILTER_TYPE = uint16_t;
72 
73 /// The debounce time for momentary push buttons in milliseconds.
74 constexpr unsigned long BUTTON_DEBOUNCE_TIME = 25; // milliseconds
75 
76 /// The time in milliseconds before a press is registered as a long press.
77 constexpr unsigned long LONG_PRESS_DELAY = 450; // milliseconds
78 
79 /// The time between increments/decremnets during a long press.
80 constexpr unsigned long LONG_PRESS_REPEAT_DELAY = 200; // milliseconds
81 
82 /// The interval between updating filtered analog inputs, in microseconds.
83 constexpr unsigned long FILTERED_INPUT_UPDATE_INTERVAL = 1000; // microseconds
84 
85 constexpr static Frequency SPI_MAX_SPEED = 8_MHz;
86 
87 /// Make it possible to invert individual push buttons.
88 /// Enabling this will increase memory usage.
89 #define AH_INDIVIDUAL_BUTTON_INVERT
90 
91 // ========================================================================== //
92 
ADC_RESOLUTION
#define ADC_RESOLUTION
The actual maximum resolution of the built-in ADC.
Definition: ADCConfig.hpp:69
AH::LONG_PRESS_DELAY
constexpr unsigned long LONG_PRESS_DELAY
The time in milliseconds before a press is registered as a long press.
Definition: AH/Settings/Settings.hpp:77
AH::FILTERED_INPUT_UPDATE_INTERVAL
constexpr unsigned long FILTERED_INPUT_UPDATE_INTERVAL
The interval between updating filtered analog inputs, in microseconds.
Definition: AH/Settings/Settings.hpp:83
Frequency.hpp
AH::ADC_BITS
constexpr uint8_t ADC_BITS
The bit depth to use for the ADC (Analog to Digital Converter).
Definition: AH/Settings/Settings.hpp:53
AH::LONG_PRESS_REPEAT_DELAY
constexpr unsigned long LONG_PRESS_REPEAT_DELAY
The time between increments/decremnets during a long press.
Definition: AH/Settings/Settings.hpp:80
AH::Frequency
Type-safe class for frequency values.
Definition: Frequency.hpp:11
BEGIN_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
Definition: AH/Settings/NamespaceSettings.hpp:9
AH::ANALOG_FILTER_TYPE
uint16_t ANALOG_FILTER_TYPE
The unsigned integer type to use for analog inputs during filtering.
Definition: AH/Settings/Settings.hpp:71
END_AH_NAMESPACE
#define END_AH_NAMESPACE
Definition: AH/Settings/NamespaceSettings.hpp:10
AH::BUTTON_DEBOUNCE_TIME
constexpr unsigned long BUTTON_DEBOUNCE_TIME
The debounce time for momentary push buttons in milliseconds.
Definition: AH/Settings/Settings.hpp:74
ADCConfig.hpp
This file contains the platform-specific ADC resolutions. By default, the library automatically selec...
AH::SPI_MAX_SPEED
constexpr static Frequency SPI_MAX_SPEED
Definition: AH/Settings/Settings.hpp:85
AH::defaultBaudRate
constexpr unsigned long defaultBaudRate
The default baud rate for debug output.
Definition: AH/Settings/Settings.hpp:36
AH::ANALOG_FILTER_SHIFT_FACTOR
constexpr uint8_t ANALOG_FILTER_SHIFT_FACTOR
The factor for the analog filter: Difference equation: where .
Definition: AH/Settings/Settings.hpp:64