aboutsummaryrefslogtreecommitdiffstats
path: root/src/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.h')
-rw-r--r--src/common.h103
1 files changed, 86 insertions, 17 deletions
diff --git a/src/common.h b/src/common.h
index ca9e439..4ac8b53 100644
--- a/src/common.h
+++ b/src/common.h
@@ -82,6 +82,11 @@
#if defined(__GNUC__)
+# pragma GCC diagnostic ignored "-Wunsuffixed-float-constants"
+#endif
+
+
+#if defined(__GNUC__)
# define GCC_ONLY(...) __VA_ARGS__
#else
# define GCC_ONLY(...)
@@ -89,13 +94,7 @@
/**
- * The colour temperature corresponding to no effect
- */
-#define NEUTRAL_TEMP 6500
-
-
-/**
- * Truncate a value into a bounded range
+ * Truncate a value into a closed range
*
* @param LO The lower bound
* @param X The value to truncated
@@ -104,6 +103,43 @@
*/
#define CLAMP(LO, X, UP) (((LO) > (X)) ? (LO) : (((X) < (UP)) ? (X) : (UP)))
+/**
+ * Check whether a value is within a closed range
+ *
+ * @param LO The lower bound
+ * @param X The value to check
+ * @param UP The upper bound
+ * @return :int 1 if `X` is within [`LO`, `UP`], 0 otherwise
+ */
+#define WITHIN(LO, X, UP) ((LO) <= (X) && (X) <= (UP))
+
+
+/**
+ * The colour temperature corresponding to no effect
+ */
+#define NEUTRAL_TEMP 6500U
+
+/**
+ * Initialiser for `struct color_setting`
+ *
+ * Sets all values to their neutral values (no effects applied)
+ */
+#define COLOR_SETTING_NEUTRAL ((struct color_setting){NEUTRAL_TEMP, 1.0, {1.0, 1.0, 1.0}})
+
+
+/**
+ * State of an adjustment method
+ *
+ * Each method has their own definition of this structure
+ */
+typedef struct gamma_state GAMMA_STATE;
+
+/**
+ * State of a location provider
+ *
+ * Each provider has their own definition of this structure
+ */
+typedef struct location_state LOCATION_STATE;
enum period {
@@ -121,16 +157,45 @@ enum program_mode {
PROGRAM_MODE_MANUAL
};
+
+/**
+ * Geographical location, using GPS coordinates
+ */
struct location {
- double lat, lon;
+ /**
+ * Degrees north of the equator
+ */
+ double lat;
+
+ /**
+ * Degrees east of the prime meridian
+ */
+ double lon;
};
+
+/**
+ * Colour setting to apply
+ */
struct color_setting {
- int temperature;
- double gamma[3];
+ /**
+ * Colour temperature, in Kelvin
+ */
+ unsigned long int temperature;
+
+ /**
+ * Whitepoint brightness level
+ */
double brightness;
+
+ /**
+ * Gamma correct, for the each RGB channel
+ * in the order: red, green, and blue
+ */
+ double gamma[3];
};
+
/* Time range.
Fields are offsets from midnight in seconds. */
struct time_range {
@@ -138,6 +203,7 @@ struct time_range {
int end;
};
+
/* Transition scheme.
The solar elevations at which the transition begins/ends,
and the association color settings. */
@@ -151,18 +217,21 @@ struct transition_scheme {
struct color_setting night;
};
+
struct config_ini_setting {
struct config_ini_setting *next;
char *name;
char *value;
};
+
struct config_ini_section {
struct config_ini_section *next;
char *name;
struct config_ini_setting *settings;
};
+
struct config_ini_state {
struct config_ini_section *sections;
};
@@ -177,7 +246,7 @@ struct options {
int verbose;
/* Temperature to set in manual mode. */
- int temp_set;
+ unsigned long int temp_set;
/* Whether to fade between large skips in color temperature. */
int use_fade;
/* Whether to preserve gamma ramps if supported by gamma method. */
@@ -195,9 +264,9 @@ struct options {
};
-/* Gamma adjustment method */
-typedef struct gamma_state GAMMA_STATE;
-
+/**
+ * Adjustment method information and interface
+ */
struct gamma_method {
const char *name;
@@ -223,9 +292,9 @@ struct gamma_method {
};
-/* Location provider */
-typedef struct location_state LOCATION_STATE;
-
+/**
+ * Location provider information and interface
+ */
struct location_provider {
const char *name;