Skip to content

Commit

Permalink
Merge branch 'eeprom' into 'master'
Browse files Browse the repository at this point in the history
added eeprom, user configuration can now be stored and restored from eeprom

See merge request !17
  • Loading branch information
RobertFach committed Jan 28, 2018
2 parents 916e2d8 + 7dbb25c commit 2971d36
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 62 deletions.
5 changes: 5 additions & 0 deletions software/gigascan/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Robert Fach
e-mail : robert.fach@gmx.net
*/

#define HARDWARE_VERSION_1_1_0

#if defined(HARDWARE_VERSION_1_1_0)
//Stepper Pins for Pan Stepper
#define PAN_STEP_PIN 24
#define PAN_DIR_PIN 22
Expand All @@ -36,4 +39,6 @@ e-mail : robert.fach@gmx.net
#define ENCODER_BTN_PIN -44
#define DISPLAY_RESET_BTN_PIN -49 //negative means active internal pull-up

#endif//HARDWARE_VERSION_1_1_0

const char SPLASHSCREEN[] PROGMEM = { "00000000000000000000000000001111111100001100101000000000000000000000000000000000000000000011111111111100110010100000000000000000000000000000000000000000011111111110111110000000000000000000000000000000000000000000001001111111111001111110000000000000000000000000000000000000000001011010111111101111111100000000000000000000000000000000000000000111000011111111111111111000000000000000000000000000000000000000001010011111111111111111100000000000000000000000000000000000000000001001111111111111111110000000000000000000000000000000000000000001000111111111111111100000000000000000000000000000000000000000000100000111110111111111010000000000000000000000000000000000000000000001111111011111111101000000000000000000000000000000000000000000001111111100111111111000000000000000000000000000000000000000000001111101111011111111000000000000000000000000000000000000000000000111110011101111111000000000000000000000000000000000000000000000111111010010001111110000000000000000000000000000000000000000000101111100000000011110000000000000000000000000000000000000000000000111111100000001010000000000000000000000000000000000000000000000111111100000000100000000000000000000000000000000000000000000000001110100000000000000000000000000000000000000000000000000000000000001010000000000000000000000000000000000000000000000000000000001001101000000000000000000000000000000000000000000000000000000000110110000000000000000000000000000000000000000000000000000000000000111100000000000000000000000000000000000000000000000000000000000011110000001110000000000000000000000000000000000000000000000000001110000001111110000000000000000000000000000000000000000000000000111010001111111000000000000000000000000000000000000000000000000011100000110001110000000000000000000000000000000000000000000000001011000010000011100000000000000000000000000000000000000000000000001100001000001110000000000000000000000000000000000000000000000010111000111000111100100000000000000000000000000000000000000000000011100011110001111000000000000000000000000000000000000000000000000110001111000101101000000000000000000000000000000000000000000000111000010100011110100000000000000000000000000000000000000000000001110000010000111010000000000000000000000000000000000000000000000111000001000011111000000000000000000000000000000000000000000000001110001100001011110000000000000000000000000000000000000000000000111111100000101111010100000000000000000000000000000000000000000000111100000001111101100000000000000000000000000000000000000000000001101000000111110001000000000000000000000000000000000000000000001000000000011110001000000000000000000000000000000000000000000000000000000001111100100000000000000000000000000000000000000000000000000000001011100010000000000000000000000000000000000000000000000000000001100110001000000000000000000000000000000000010000100000000000000000011111100000000000000000000000000000000001110110000000000000001011111110000000000000000000000000000000000001010000000000000000001111110000000000000000000000000000001001101111001000000000000011111111010000000000000000000000000000100010011111100000000000001111111100000000000000000000000000000010111011111110100000000101111111111000000000000000000000000000011001111111111111000000010111111111100000000000000000000000000000110001111111111100000001101111111110000000000000000000000000000001010111111111000000000110011111111000000000000000000000000000000000111111111110101100001001111111100000000000000000000000000000000111111111111110110010000111111110000000000000000000000000000011101111111111111110111100001111110000000000000000000000000000011110111111111111101011110001111110000100000000000000000000000000111111111111111110001111110111110000111110000000000000000000001011111111111111111000011111111111100011011000000000000000000000001111111111111111110011111111100100010011110000000000000000000011111111111111111110011111111110000001000011000000000000000000011101001111111111111100111111111001000110011011000000000000010000111100111111111111110011111111110100011101101100000000000000110110001011111111111111111111111111010001100110010000000000000011010000011111111111111111111111111110000001011110000000000000011101000001111111111111111111111111111100000101110000000000000011110100000011111111111111111111111111110000010110000000000000010011001100010111111111111111111111111110100011011000000000000001101101110001011111111110011111111111111001111000010000000000000110110011000100111111111001111111111111100101110000000000000000000110000100000011111111110011111111111111111110000000000000000000011110010001001111111110011111111111111111100000000000000000000000110110001111111111110000111111111111111110100000000000000000000011111000011111011111100011111111111111111000000000000000000000000001000011111100011110101111111111111011110000000000000000000000000000011111100001111011111111111111101110000000000000000000000000000011111111000010011011111111111111000000000000000000000000000000001111111100100001101011111111111000000000000000000000000000000000111111110011000000000111111111010100000000000000000000000000000011111111101100000001111111111100011000000000000000000000000000001111111111010000000111111111111100110000000000000000000000000000111111111101000000001011111110111010000000000000000000000000000001111111100000000000001111110010001000000000000000000000000000010111111110000000000000100111101100100000000000000000000000000000011111100000000000000000010100000000000000000000000000000000000011111110100000000000000011011100000000000000000000000000000000001111110000000000000000001000010000000000000000000000000000000000100011001100000000000000000000000000000000000000000000000000000010001110100000000000000000000000000000000000000000000000000000001001111100000000000000000000000000000000000000000000000000000000100011110000000000100000000000000000000000000000000000000000000100011111000000101100000000000000000000000000000000000000000000001101111100000001111000000000000000000000000000000000000000000001010111101000001111111000000000000000000000000000000000000000000000011110100001100011100000000000000000000000000000000000000000000000111110000100000111000000000000000000000000000000000000000000000010111000010000011100000000000000000000000000000000000000000000001011110001010000111000000000000000000000000000000000000000000000101101000111100011000000000000000000000000000000000000000000000000111100011110001110000000000000000000000000000000000000000000001001111000111000111010000000000000000000000000000000000000000000000011100000100001100000000000000000000000000000000000000000000000001110000010000110100000000000000000000000000000000000000000000000011100011000001110000000000000000000000000000000000000000000000000111111100010111000000000000000000000000000000000000000000000000011111100000011100000000000000000000000000000000000000000000000000011100000011110000000000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000011011000000000000000000000000000000000000000000000000000000000101100100000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000001011100000000000000000000000000000000000000000000000001000000001111111000000000000000000000000000000000000000000000010100000001111111000000000000000000000000000000000000000000000011110000000001111101000000000000000000000000000000000000000000011111100010010111111000000000000000000000000000000000000000000000111111101110011111000000000000000000000000000000000000000000000111111110111101111100000000000000000000000000000000000000000000111111111001111111100000000000000000000000000000000000000000000101111111110111111100000000000000000000000000000000000000000000010111111111011111000001000000000000000000000000000000000000000000001111111111111111000100000000000000000000000000000000000000000011111111111111111100100000000000000000000000000000000000000000001111111111111111110010100000000000000000000000000000000000000000111111111111111110000111000000000000000000000000000000000000000001111111101111111010110100000000000000000000000000000000000000000011111100111111111100100000000000000000000000000000000000000000000011111011111111110000000000000000000000000000000000000000001010011001111111111110000000000000000000000000"};
31 changes: 31 additions & 0 deletions software/gigascan/src/eeprom-config.cpp
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));
}
37 changes: 37 additions & 0 deletions software/gigascan/src/eeprom-config.h
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
Loading

0 comments on commit 2971d36

Please sign in to comment.