-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added eeprom, user configuration can now be stored and restored from eeprom See merge request !17
- Loading branch information
Showing
4 changed files
with
129 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <eeprom-config.h> | ||
|
||
#include <EEPROM.h> | ||
|
||
StoreStruct default_config = DEFAULT_CONFIG; | ||
|
||
StoreStruct user_config = DEFAULT_CONFIG; | ||
|
||
void loadConfig() { | ||
// To make sure there are settings, and they are YOURS! | ||
// If nothing is found it will use the default settings. | ||
if (EEPROM.read(CONFIG_START + 0) == CONFIG_VERSION[0] && | ||
EEPROM.read(CONFIG_START + 1) == CONFIG_VERSION[1] && | ||
EEPROM.read(CONFIG_START + 2) == CONFIG_VERSION[2]) { | ||
for (unsigned int t=0; t<sizeof(user_config); t++) | ||
*((char*)&user_config + t) = EEPROM.read(CONFIG_START + t); | ||
} else { | ||
resetToDefaultConfig(); | ||
} | ||
} | ||
|
||
void resetToDefaultConfig() { | ||
for (unsigned int t=0; t<sizeof(default_config); t++) | ||
EEPROM.write(CONFIG_START + t, *((char*)&default_config + t)); | ||
loadConfig(); | ||
} | ||
|
||
void saveConfig() { | ||
for (unsigned int t=0; t<sizeof(user_config); t++) | ||
EEPROM.write(CONFIG_START + t, *((char*)&user_config + t)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#ifndef __EEPROM_CONFIG_H__ | ||
#define __EEPROM_CONFIG_H__ | ||
|
||
#define CONFIG_VERSION "PB1" | ||
|
||
#define CONFIG_START 32 | ||
|
||
struct StoreStruct { | ||
char version[4]; | ||
double crop_factor; | ||
int focal_length; | ||
int horizontal_overlap; | ||
int vertical_overlap; | ||
int pan_steps_per_degree; | ||
int tilt_steps_per_degree; | ||
double maximum_pan_speed; | ||
double pan_acceleration; | ||
double maximum_tilt_speed; | ||
double tilt_acceleration; | ||
int stabilize_and_write_delay; | ||
int focus_delay; | ||
int trigger_delay; | ||
int scan_max_pan_left; | ||
int scan_max_pan_right; | ||
int scan_max_tilt_up; | ||
int scan_max_tilt_down; | ||
}; | ||
|
||
extern StoreStruct user_config; | ||
|
||
#define DEFAULT_CONFIG { CONFIG_VERSION, 1.6, 70, 30, 30, 56, 35 /*50 for big gear*/, 3000.0, 2000.0, 2000.0, 2000.0, 500, 250, 500, -10, 10, 5, -5} | ||
|
||
void loadConfig(); | ||
void resetToDefaultConfig(); | ||
void saveConfig(); | ||
|
||
#endif |
Oops, something went wrong.