Telescope Control Library

Dependents:   PushToGo-F429

Revision:
8:21a33760bf10
Parent:
0:6cb2eaf8b133
Child:
10:e356188d208e
--- a/TelescopeConfiguration.cpp	Sun Sep 09 16:28:03 2018 -0400
+++ b/TelescopeConfiguration.cpp	Sun Sep 09 17:31:20 2018 -0400
@@ -17,10 +17,8 @@
 TelescopeConfiguration TelescopeConfiguration::instance =
 		TelescopeConfiguration();
 
-static const char *typeName(DataType type)
-{
-	switch (type)
-	{
+static const char *typeName(DataType type) {
+	switch (type) {
 	case DATATYPE_INT:
 		return "INT";
 	case DATATYPE_DOUBLE:
@@ -35,151 +33,121 @@
 }
 
 static const ConfigItem default_config[] =
-		{
-		{ .config = "latitude", .name = "Your latitude", .help =
+		{ { .config = "latitude", .name = "Your latitude", .help =
 				"Latitude of observer, in degrees north of equator.", .type =
-				DATATYPE_DOUBLE, .value =
-		{ .ddata = 42 }, .min =
-		{ .ddata = -90 }, .max =
-		{ .ddata = 90 } },
-		{ .config = "longitude", .name = "Your longitude", .help =
+				DATATYPE_DOUBLE, .value = { .ddata = 42 }, .min =
+				{ .ddata = -90 }, .max = { .ddata = 90 } }, { .config =
+				"longitude", .name = "Your longitude", .help =
 				"Longitude of observer, in degrees east of Greenwich.", .type =
-				DATATYPE_DOUBLE, .value =
-		{ .ddata = -73 }, .min =
-		{ .ddata = -180 }, .max =
-		{ .ddata = 180 } },
-		{ .config = "timezone", .name = "Your timezone", .help =
-				"Timezone in hours ahead of UTC time.", .type = DATATYPE_INT,
-				.value =
-				{ .idata = -4 }, .min =
-				{ .idata = -12 }, .max =
-				{ .idata = 12 } },
+				DATATYPE_DOUBLE, .value = { .ddata = -73 }, .min = { .ddata =
+				-180 }, .max = { .ddata = 180 } }, { .config = "timezone",
+				.name = "Your timezone", .help =
+						"Timezone in hours ahead of UTC time.", .type =
+						DATATYPE_INT, .value = { .idata = -4 }, .min = {
+						.idata = -12 }, .max = { .idata = 12 } },
 				{ .config = "motor_steps", .name = "Steps per Revolution",
 						.help =
 								"Motor steps/revolution.\nIf you hard-programed the microstepping, here should use total microstep resolution.",
-						.type = DATATYPE_INT, .value =
-						{ .idata = 400 }, .min =
-						{ .idata = 1 }, .max =
-						{ .idata = 1000000 } },
-				{ .config = "gear_reduction", .name = "Gear Ratio", .help =
-						"Gearbox reduction ratio. ", .type = DATATYPE_DOUBLE,
-						.value =
-						{ .ddata = 1 }, .min =
-						{ .ddata = 0 }, .max =
-						{ .ddata = 10000 } },
-				{ .config = "worm_teeth", .name = "Worm Teeth", .help =
-						"Number of teeth on the ring gear.", .type =
-						DATATYPE_INT, .value =
-				{ .idata = 180 }, .min =
-				{ .idata = 1 }, .max =
-				{ .idata = 10000 } },
+						.type = DATATYPE_INT, .value = { .idata = 400 }, .min =
+								{ .idata = 1 }, .max = { .idata = 1000000 } }, {
+						.config = "gear_reduction", .name = "Gear Ratio",
+						.help = "Gearbox reduction ratio. ", .type =
+								DATATYPE_DOUBLE, .value = { .ddata = 1 }, .min =
+								{ .ddata = 0 }, .max = { .ddata = 10000 } }, {
+						.config = "worm_teeth", .name = "Worm Teeth", .help =
+								"Number of teeth on the ring gear.", .type =
+								DATATYPE_INT, .value = { .idata = 180 }, .min =
+								{ .idata = 1 }, .max = { .idata = 10000 } },
 				{ .config = "ra_invert", .name = "Invert RA direction",
 						.help =
 								"Invert RA driving direction?\n Save and restart to take effect",
-						.type = DATATYPE_BOOL, .value =
-						{ .bdata = false } },
+						.type = DATATYPE_BOOL, .value = { .bdata = false } },
 				{ .config = "dec_invert", .name = "Invert DEC direction",
 						.help =
 								"Invert DEC driving direction?\n Save and restart to take effect",
-						.type = DATATYPE_BOOL, .value =
-						{ .bdata = false } },
-				{ .config = "default_slew_speed", .name = "Default slew speed",
-						.help = "Default slewing speed in deg/s", .type =
-								DATATYPE_DOUBLE, .value =
-						{ .ddata = 3 }, .min =
-						{ .ddata = 1 }, .max =
-						{ .ddata = 10 } },
+						.type = DATATYPE_BOOL, .value = { .bdata = false } }, {
+						.config = "default_slew_speed", .name =
+								"Default slew speed", .help =
+								"Default slewing speed in deg/s", .type =
+								DATATYPE_DOUBLE, .value = { .ddata = 3 }, .min =
+								{ .ddata = 1 }, .max = { .ddata = 10 } }, {
+						.config = "goto_slew_speed", .name =
+								"Default slew speed", .help =
+								"Slewing speed used for goto, in deg/s", .type =
+								DATATYPE_DOUBLE, .value = { .ddata = 3 }, .min =
+								{ .ddata = 1 }, .max = { .ddata = 10 } },
 				{ .config = "default_track_speed_sidereal", .name =
 						"Default track speed", .help =
 						"Default slewing speed in multiple of sidereal rate.",
-						.type = DATATYPE_DOUBLE, .value =
-						{ .ddata = 1 }, .min =
-						{ .ddata = 0 }, .max =
-						{ .ddata = 100 } },
+						.type = DATATYPE_DOUBLE, .value = { .ddata = 1 }, .min =
+								{ .ddata = 0 }, .max = { .ddata = 100 } },
 				{ .config = "correction_speed_sidereal", .name =
 						"Default correction speed", .help =
 						"Correction speed in multiple of sidereal rate.",
-						.type = DATATYPE_DOUBLE, .value =
-						{ .ddata = 32 }, .min =
-						{ .ddata = 0 }, .max =
-						{ .ddata = 100 } },
+						.type = DATATYPE_DOUBLE, .value = { .ddata = 32 },
+						.min = { .ddata = 0 }, .max = { .ddata = 100 } },
 				{ .config = "default_guide_speed_sidereal", .name =
 						"Default guiding speed", .help =
 						"Default guiding speed in multiple of sidereal rate.",
-						.type = DATATYPE_DOUBLE, .value =
-						{ .ddata = 0.5 }, .min =
-						{ .ddata = 0 }, .max =
-						{ .ddata = 100 } },
-				{ .config = "acceleration", .name = "Acceleration", .help =
-						"Acceleration in deg/s^2.", .type = DATATYPE_DOUBLE,
-						.value =
-						{ .ddata = 2 }, .min =
-						{ .ddata = 0.01 }, .max =
-						{ .ddata = 1000 } },
+						.type = DATATYPE_DOUBLE, .value = { .ddata = 0.5 },
+						.min = { .ddata = 0 }, .max = { .ddata = 100 } }, {
+						.config = "acceleration", .name = "Acceleration",
+						.help = "Acceleration in deg/s^2.", .type =
+								DATATYPE_DOUBLE, .value = { .ddata = 2 }, .min =
+								{ .ddata = 0.01 }, .max = { .ddata = 1000 } },
 				{ .config = "max_speed", .name = "Max slewing speed", .help =
 						"Max slewing speed. Reduce this value if losing steps.",
-						.type = DATATYPE_DOUBLE, .value =
-						{ .ddata = 4 }, .min =
-						{ .ddata = 1 }, .max =
-						{ .ddata = 100 } },
+						.type = DATATYPE_DOUBLE, .value = { .ddata = 4 }, .min =
+								{ .ddata = 1 }, .max = { .ddata = 100 } },
 				{ .config = "min_slew_angle", .name = "Min slewing distance",
 						.help =
 								"Min slew angle, in deg. Angle difference below this value will be approached by correction alone.",
-						.type = DATATYPE_DOUBLE, .value =
-						{ .ddata = 0.3 }, .min =
-						{ .ddata = 0.001 }, .max =
-						{ .ddata = 10 } },
-				{ .config = "correction_tolerance", .name =
-						"Correction Tolerance", .help =
-						"Correction tolerance in deg", .type = DATATYPE_DOUBLE,
-						.value =
-						{ .ddata = 0.03 }, .min =
-						{ .ddata = 0.001 }, .max =
-						{ .ddata = 1 } },
+						.type = DATATYPE_DOUBLE, .value = { .ddata = 0.3 },
+						.min = { .ddata = 0.001 }, .max = { .ddata = 10 } }, {
+						.config = "correction_tolerance", .name =
+								"Correction Tolerance", .help =
+								"Correction tolerance in deg", .type =
+								DATATYPE_DOUBLE, .value = { .ddata = 0.03 },
+						.min = { .ddata = 0.001 }, .max = { .ddata = 1 } },
 				{ .config = "min_correction_time",
 						.name = "Min Correction Time",
 						.help =
 								"Minimum correction time in milliseconds. Corrections less than this will be ignored.",
-						.type = DATATYPE_INT, .value =
-						{ .idata = 5 }, .min =
-						{ .idata = 1 }, .max =
-						{ .idata = 1000 } },
+						.type = DATATYPE_INT, .value = { .idata = 5 }, .min = {
+								.idata = 1 }, .max = { .idata = 1000 } },
 				{ .config = "max_correction_angle", .name =
 						"Max Correction Angle",
 						.help =
 								"Max correction angle in deg. Corrections larger than this value will still be executed, but give you a warning since it will take a long time and something is likely wrong.",
-						.type = DATATYPE_DOUBLE, .value =
-						{ .ddata = 5 }, .min =
-						{ .ddata = 0 }, .max =
-						{ .ddata = 180 } },
+						.type = DATATYPE_DOUBLE, .value = { .ddata = 5 }, .min =
+								{ .ddata = 0 }, .max = { .ddata = 180 } },
 				{ .config = "max_guide_time", .name = "Max Guiding Time",
 						.help =
 								"Max guide time in milliseconds. Guide pulses larger than this value will be truncated.",
-						.type = DATATYPE_INT, .value =
-						{ .idata = 5000 }, .min =
-						{ .idata = 100 }, .max =
-						{ .idata = 10000000 } },
+						.type = DATATYPE_INT, .value = { .idata = 5000 }, .min =
+								{ .idata = 100 }, .max = { .idata = 10000000 } },
 				{ .config = "acceleration_step_time", .name =
 						"Acceleration Step Time",
 						.help =
 								"Acceleration step time in milliseconds. The default value should work for most situations.",
-						.type = DATATYPE_INT, .value =
-						{ .idata = 5 }, .min =
-						{ .idata = 1 }, .max =
-						{ .idata = 1000 } },
-				{ .config = "" } };
+						.type = DATATYPE_INT, .value = { .idata = 5 }, .min = {
+								.idata = 1 }, .max = { .idata = 1000 } },
+				{ .config = "pec_granularity", .name =
+						"PEC Granularity",
+						.help =
+								"Number of PEC slots per revolution of the worm",
+						.type = DATATYPE_INT, .value = { .idata = 512 }, .min = {
+								.idata = 32 }, .max = { .idata = 16384} }, {
+						.config = "" } };
 
 int TelescopeConfiguration::eqmount_config(EqMountServer *server,
-		const char *cmd, int argn, char *argv[])
-{
+		const char *cmd, int argn, char *argv[]) {
 	char buf[256];
-	if (argn == 0)
-	{
+	if (argn == 0) {
 		// Print all config names
 		ConfigNode *p = instance.head;
 		stprintf(server->getStream(), "%s", cmd);
-		for (; p; p = p->next)
-		{
+		for (; p; p = p->next) {
 			stprintf(server->getStream(), " %s", p->config->config);
 			// Get string representing the value
 //			getStringFromConfig(p->config, buf, sizeof(buf));
@@ -188,62 +156,43 @@
 //					typeName(p->config->type), buf);
 		}
 		stprintf(server->getStream(), "\r\n");
-	}
-	else
-	{
+	} else {
 		char *config_name = argv[0]; // Name of the config in question
 		ConfigItem *config = instance.getConfigItem(config_name);
-		if (!config)
-		{
+		if (!config) {
 			stprintf(server->getStream(), "%s Error: config %s not found\r\n",
 					cmd, config_name);
 			return ERR_PARAM_OUT_OF_RANGE;
 		}
-		if (argn == 1)
-		{
+		if (argn == 1) {
 			// Print value of the config
 			getStringFromConfig(config, buf, sizeof(buf));
 			stprintf(server->getStream(), "%s %s\r\n", cmd, buf);
-		}
-		else if (argn == 2)
-		{
-			if (strcmp(argv[1], "default") == 0)
-			{
+		} else if (argn == 2) {
+			if (strcmp(argv[1], "default") == 0) {
 				// Print default value of the config
 				// TODO
-			}
-			else if (strcmp(argv[1], "name") == 0)
-			{
+			} else if (strcmp(argv[1], "name") == 0) {
 				// Print name
 				stprintf(server->getStream(), "%s %s\r\n", cmd, config->name);
-			}
-			else if (strcmp(argv[1], "help") == 0)
-			{
+			} else if (strcmp(argv[1], "help") == 0) {
 				// Print help
 				stprintf(server->getStream(), "%s %s\r\n", cmd, config->help);
-			}
-			else if (strcmp(argv[1], "type") == 0)
-			{
+			} else if (strcmp(argv[1], "type") == 0) {
 				// Print type
 				stprintf(server->getStream(), "%s %s\r\n", cmd,
 						typeName(config->type));
-			}
-			else if (strcmp(argv[1], "info") == 0)
-			{
+			} else if (strcmp(argv[1], "info") == 0) {
 				// Print type, value, name and help
 				getStringFromConfig(config, buf, sizeof(buf));
 				stprintf(server->getStream(), "%s %s,%s,%s,%s\r\n", cmd,
 						typeName(config->type), buf, config->name,
 						config->help);
-			}
-			else if (strcmp(argv[1], "limit") == 0)
-			{
+			} else if (strcmp(argv[1], "limit") == 0) {
 				// Print min/max
 				if (config->type != DATATYPE_STRING
-						&& config->type != DATATYPE_BOOL && !config->extra)
-				{
-					switch (config->type)
-					{
+						&& config->type != DATATYPE_BOOL && !config->extra) {
+					switch (config->type) {
 					case DATATYPE_INT:
 						stprintf(server->getStream(), "%s %d %d\r\n", cmd,
 								config->min.idata, config->max.idata);
@@ -255,59 +204,45 @@
 					default:
 						break;
 					}
-				}
-				else
-				{
+				} else {
 					stprintf(server->getStream(),
 							"%s limit not supported for %s.\r\n", cmd,
 							config->config);
 				}
-			}
-			else
-			{
+			} else {
 				// Set value
 				char *value = argv[1];
 				char *s;
 				int i;
 				double d;
 				bool b;
-				switch (config->type)
-				{
+				switch (config->type) {
 				case DATATYPE_INT:
 					i = strtol(value, &s, 10);
-					if (s == value || setIntToConfig(config, i))
-					{
+					if (s == value || setIntToConfig(config, i)) {
 						return ERR_PARAM_OUT_OF_RANGE;
 					}
 					break;
 				case DATATYPE_DOUBLE:
 					d = strtod(value, &s);
-					if (s == value || setDoubleToConfig(config, d))
-					{
+					if (s == value || setDoubleToConfig(config, d)) {
 						return ERR_PARAM_OUT_OF_RANGE;
 					}
 					break;
 				case DATATYPE_BOOL:
-					if (strcmp(value, "true") == 0)
-					{
+					if (strcmp(value, "true") == 0) {
 						b = true;
-					}
-					else if (strcmp(value, "false") == 0)
-					{
+					} else if (strcmp(value, "false") == 0) {
 						b = false;
-					}
-					else
-					{
+					} else {
 						return ERR_PARAM_OUT_OF_RANGE;
 					}
-					if (setBoolToConfig(config, b))
-					{
+					if (setBoolToConfig(config, b)) {
 						return ERR_PARAM_OUT_OF_RANGE;
 					}
 					break;
 				case DATATYPE_STRING:
-					if (setStringToConfig(config, value))
-					{
+					if (setStringToConfig(config, value)) {
 						return ERR_PARAM_OUT_OF_RANGE;
 					}
 					break;
@@ -318,11 +253,9 @@
 	return 0;
 }
 
-TelescopeConfiguration::TelescopeConfiguration()
-{
+TelescopeConfiguration::TelescopeConfiguration() {
 	ConfigNode *q = NULL, *r;
-	for (const ConfigItem *p = default_config; *(p->config) != '\0'; p++)
-	{
+	for (const ConfigItem *p = default_config; *(p->config) != '\0'; p++) {
 		r = new ConfigNode;
 		r->next = q;
 		r->config = new ConfigItem(*p);
@@ -336,20 +269,16 @@
 					TelescopeConfiguration::eqmount_config));
 }
 
-int TelescopeConfiguration::getIntFromConfig(ConfigItem *config)
-{
-	if (config->type != DATATYPE_INT)
-	{
+int TelescopeConfiguration::getIntFromConfig(ConfigItem *config) {
+	if (config->type != DATATYPE_INT) {
 		error("Data type mismatch: wanted %s, actual %s",
 				typeName(DATATYPE_INT), typeName(config->type));
 	}
 	return config->value.idata;
 }
 
-double TelescopeConfiguration::getDoubleFromConfig(ConfigItem *config)
-{
-	if (config->type != DATATYPE_DOUBLE && config->type != DATATYPE_INT)
-	{
+double TelescopeConfiguration::getDoubleFromConfig(ConfigItem *config) {
+	if (config->type != DATATYPE_DOUBLE && config->type != DATATYPE_INT) {
 		error("Data type mismatch: wanted %s, actual %s",
 				typeName(DATATYPE_DOUBLE), typeName(config->type));
 	}
@@ -357,25 +286,20 @@
 			config->value.ddata : config->value.idata;
 }
 
-bool TelescopeConfiguration::getBoolFromConfig(ConfigItem *config)
-{
-	if (config->type != DATATYPE_BOOL)
-	{
+bool TelescopeConfiguration::getBoolFromConfig(ConfigItem *config) {
+	if (config->type != DATATYPE_BOOL) {
 		error("Data type mismatch: wanted %s, actual %s",
 				typeName(DATATYPE_BOOL), typeName(config->type));
 	}
 	return config->value.bdata;
 }
 
-bool TelescopeConfiguration::setIntToConfig(ConfigItem *config, int value)
-{
-	if (config == NULL)
-	{
+bool TelescopeConfiguration::setIntToConfig(ConfigItem *config, int value) {
+	if (config == NULL) {
 		debug_if(TC_DEBUG, "Null config");
 		return true;
 	}
-	if (config->type != DATATYPE_DOUBLE && config->type != DATATYPE_INT)
-	{
+	if (config->type != DATATYPE_DOUBLE && config->type != DATATYPE_INT) {
 		debug_if(TC_DEBUG, "Data type mismatch: wanted %s, actual %s",
 				typeName(DATATYPE_INT), typeName(config->type));
 		return true;
@@ -387,15 +311,13 @@
 	return false;
 }
 
-bool TelescopeConfiguration::setDoubleToConfig(ConfigItem *config, double value)
-{
-	if (config == NULL)
-	{
+bool TelescopeConfiguration::setDoubleToConfig(ConfigItem *config,
+		double value) {
+	if (config == NULL) {
 		debug_if(TC_DEBUG, "Null config");
 		return true;
 	}
-	if (config->type != DATATYPE_DOUBLE)
-	{
+	if (config->type != DATATYPE_DOUBLE) {
 		error("Data type mismatch: wanted %s, actual %s",
 				typeName(DATATYPE_DOUBLE), typeName(config->type));
 		return true;
@@ -404,15 +326,12 @@
 	return false;
 }
 
-bool TelescopeConfiguration::setBoolToConfig(ConfigItem *config, bool value)
-{
-	if (config == NULL)
-	{
+bool TelescopeConfiguration::setBoolToConfig(ConfigItem *config, bool value) {
+	if (config == NULL) {
 		debug_if(TC_DEBUG, "Null config");
 		return true;
 	}
-	if (config->type != DATATYPE_BOOL)
-	{
+	if (config->type != DATATYPE_BOOL) {
 		debug_if(TC_DEBUG, "Data type mismatch: wanted %s, actual %s",
 				typeName(DATATYPE_BOOL), typeName(config->type));
 		return true;
@@ -421,15 +340,13 @@
 	return false;
 }
 
-bool TelescopeConfiguration::setStringToConfig(ConfigItem *config, char* value)
-{
-	if (config == NULL)
-	{
+bool TelescopeConfiguration::setStringToConfig(ConfigItem *config,
+		char* value) {
+	if (config == NULL) {
 		debug_if(TC_DEBUG, "Null config");
 		return true;
 	}
-	if (config->type != DATATYPE_STRING)
-	{
+	if (config->type != DATATYPE_STRING) {
 		debug_if(TC_DEBUG, "Data type mismatch: wanted %s, actual %s",
 				typeName(DATATYPE_STRING), typeName(config->type));
 		return true;
@@ -438,11 +355,9 @@
 	return false;
 }
 
-ConfigItem* TelescopeConfiguration::getConfigItemCheck(const char* name)
-{
+ConfigItem* TelescopeConfiguration::getConfigItemCheck(const char* name) {
 	ConfigItem *config = getConfigItem(name);
-	if (!config)
-	{
+	if (!config) {
 		error("Config not found: %s", name);
 		return NULL;
 	}
@@ -450,12 +365,10 @@
 }
 
 char* TelescopeConfiguration::getStringFromConfig(ConfigItem *config,
-		char buf[], int len)
-{
+		char buf[], int len) {
 	if (!buf)
 		return NULL;
-	switch (config->type)
-	{
+	switch (config->type) {
 	case DATATYPE_DOUBLE:
 		snprintf(buf, len, "%.8f", config->value.ddata);
 		break;
@@ -472,13 +385,10 @@
 	return buf;
 }
 
-void TelescopeConfiguration::setConfig(const char* name, char *value)
-{
+void TelescopeConfiguration::setConfig(const char* name, char *value) {
 	ConfigItem *config = instance.getConfigItem(name);
-	if (config == NULL)
-	{
-		if (*value == '\0')
-		{
+	if (config == NULL) {
+		if (*value == '\0') {
 			// Empty value string, don't add
 			return;
 		}
@@ -494,35 +404,25 @@
 		n->default_config = NULL;
 		n->next = instance.head;
 		instance.head = n;
-		if (strcmp(value, "true") == 0 || strcmp(value, "false") == 0)
-		{
+		if (strcmp(value, "true") == 0 || strcmp(value, "false") == 0) {
 			config->type = DATATYPE_BOOL;
-		}
-		else if (!isalpha(value[0]))
-		{
-			if (strchr(value, '.') == NULL)
-			{ // Look for decimal point
+		} else if (!isalpha(value[0])) {
+			if (strchr(value, '.') == NULL) { // Look for decimal point
 				config->type = DATATYPE_INT;
-			}
-			else
-			{
+			} else {
 				config->type = DATATYPE_DOUBLE;
 			}
-		}
-		else
-		{
+		} else {
 			config->type = DATATYPE_STRING;
 		}
 	}
 
-	switch (config->type)
-	{
+	switch (config->type) {
 	case DATATYPE_INT:
 		config->value.idata = strtol(value, NULL, 10);
 		if (!config->extra
 				&& (config->value.idata > config->max.idata
-						|| config->value.idata < config->min.idata))
-		{
+						|| config->value.idata < config->min.idata)) {
 			error("'%s' value out of range: must be > %d and < %d",
 					config->config, config->max.idata, config->min.idata);
 		}
@@ -531,8 +431,7 @@
 		config->value.ddata = strtod(value, NULL);
 		if (!config->extra
 				&& (config->value.ddata > config->max.ddata
-						|| config->value.ddata < config->min.ddata))
-		{
+						|| config->value.ddata < config->min.ddata)) {
 			error("'%s' value out of range: must be > %f and < %f",
 					config->config, config->max.ddata, config->min.ddata);
 		}
@@ -546,8 +445,7 @@
 	}
 }
 
-ConfigItem* TelescopeConfiguration::getConfigItem(const char* name)
-{
+ConfigItem* TelescopeConfiguration::getConfigItem(const char* name) {
 	ConfigNode *p;
 	for (p = head; p && (strcmp(p->config->config, name) != 0); p = p->next)
 		;
@@ -557,10 +455,8 @@
 		return p->config;
 }
 
-TelescopeConfiguration::~TelescopeConfiguration()
-{
-	for (ConfigNode *q = head; q;)
-	{
+TelescopeConfiguration::~TelescopeConfiguration() {
+	for (ConfigNode *q = head; q;) {
 		ConfigNode *p = q->next;
 		delete q->config;
 		delete q;
@@ -568,14 +464,12 @@
 	}
 }
 
-void TelescopeConfiguration::readFromFile(FILE* fp)
-{
+void TelescopeConfiguration::readFromFile(FILE* fp) {
 	char line[256];
 
 	int lineno = 0;
 
-	while (true)
-	{
+	while (true) {
 		if (fgets(line, sizeof(line), fp) == NULL)
 			break;
 		char *p = line;
@@ -583,8 +477,7 @@
 		// Skip any white characters in the front
 		while (*p && isspace(*p))
 			p++;
-		if (*p == '\0')
-		{
+		if (*p == '\0') {
 			/*Empty line*/
 			continue;
 		}
@@ -593,8 +486,7 @@
 			continue;
 		// Find the '=' sign
 		char *q = strchr(p, '=');
-		if (q == NULL)
-		{
+		if (q == NULL) {
 			/*Syntax error*/
 			debug("Syntax error in line %d\n", lineno);
 			continue;
@@ -608,8 +500,7 @@
 		q = q + 1;
 		while (*q && isspace(*q))
 			q++;
-		if (*q == '\0')
-		{
+		if (*q == '\0') {
 			/*Empty value, just keep the default*/
 			continue;
 		}
@@ -628,11 +519,9 @@
 	}
 }
 
-void TelescopeConfiguration::writeToFile(FILE* fp)
-{
+void TelescopeConfiguration::writeToFile(FILE* fp) {
 	char buf[256];
-	for (ConfigNode *p = instance.head; p; p = p->next)
-	{
+	for (ConfigNode *p = instance.head; p; p = p->next) {
 		getStringFromConfig(p->config, buf, sizeof(buf));
 		fprintf(fp, "%s = %s\n", p->config->config, buf);
 	}