Dilbert
Firmware for the Dilbert interactive badge.
 All Classes Files Functions Variables Enumerations Macros Pages
SystemConfigData.h
Go to the documentation of this file.
1 
3 #ifndef _SYSTEMCONFIGDATA_H_
4 #define _SYSTEMCONFIGDATA_H_
5 
6 #include <Arduino.h>
7 
12 enum Config
13 {
14  CONFIG_BACK_BUTTON_EXIT_DELAY,
15  CONFIG_BL_FULL_BRIGHT,
16  CONFIG_BL_DIM_BRIGHT,
17  CONFIG_BL_DIM_TIMEOUT,
18  CONFIG_BL_OFF_TIMEOUT
19 };
20 
27 {
28 public:
29  static const size_t NUM_CONFIGS = 5;
30 
31 public:
33  {
34  /* Set configuration options */
35  m_names[CONFIG_BACK_BUTTON_EXIT_DELAY] = "Exit delay";
36  m_delta[CONFIG_BACK_BUTTON_EXIT_DELAY] = 50;
37 
38  m_names[CONFIG_BL_FULL_BRIGHT] = "BL full";
39  m_delta[CONFIG_BL_FULL_BRIGHT] = 32;
40 
41  m_names[CONFIG_BL_DIM_BRIGHT] = "BL dimmed";
42  m_delta[CONFIG_BL_DIM_BRIGHT] = 32;
43 
44  m_names[CONFIG_BL_DIM_TIMEOUT] = "BL dim delay";
45  m_delta[CONFIG_BL_DIM_TIMEOUT] = 1000;
46 
47  m_names[CONFIG_BL_OFF_TIMEOUT] = "BL off delay";
48  m_delta[CONFIG_BL_OFF_TIMEOUT] = 5000;
49 
50  /* Set defaults */
52  }
53 
58  {
59  m_values[CONFIG_BACK_BUTTON_EXIT_DELAY] = 500;
60  m_values[CONFIG_BL_FULL_BRIGHT] = PWMRANGE;
61  m_values[CONFIG_BL_DIM_BRIGHT] = 256;
62  m_values[CONFIG_BL_DIM_TIMEOUT] = 10000;
63  m_values[CONFIG_BL_OFF_TIMEOUT] = 60000;
64  }
65 
71  inline uint16_t &value(Config config)
72  {
73  return m_values[config];
74  }
75 
81  inline uint16_t delta(Config config) const
82  {
83  if ((size_t)config >= NUM_CONFIGS)
84  return 0;
85 
86  return m_delta[config];
87  }
88 
94  inline char *name(Config config)
95  {
96  if ((size_t)config >= NUM_CONFIGS)
97  return NULL;
98 
99  return m_names[config];
100  }
101 
102 private:
103  uint16_t m_values[NUM_CONFIGS];
104  uint16_t m_delta[NUM_CONFIGS];
105  char *m_names[NUM_CONFIGS];
106 };
107 
108 #endif
Used to store system configuration data.
Definition: SystemConfigData.h:26
char * name(Config config)
Gets the name of a configuration option.
Definition: SystemConfigData.h:94
void setDefaultValues()
Sets default values of configuration options.
Definition: SystemConfigData.h:57
uint16_t & value(Config config)
Gets the value of a configuration option.
Definition: SystemConfigData.h:71
Config
Enumeration of config IDs.
Definition: SystemConfigData.h:12
uint16_t delta(Config config) const
Gets a suitable "step" in value for a given configuration option.
Definition: SystemConfigData.h:81