Skip to content

Commit

Permalink
make EEPROM profile selection optional
Browse files Browse the repository at this point in the history
  • Loading branch information
wertarbyte committed Oct 28, 2012
1 parent 3245868 commit 7c664d6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
10 changes: 8 additions & 2 deletions EEPROM.ino
Expand Up @@ -17,7 +17,10 @@ void readGlobalSet() {

void readEEPROM() {
uint8_t i;
if(global_conf.currentSet>2) global_conf.currentSet=0;
#ifdef MULTIPLE_CONFIGURATION_PROFILES
if(global_conf.currentSet>2)
#endif
global_conf.currentSet=0;
eeprom_read_block((void*)&conf, (void*)(global_conf.currentSet * sizeof(conf) + sizeof(global_conf)), sizeof(conf));
if(calculate_sum((uint8_t*)&conf, sizeof(conf)) != conf.checksum) {
blinkLED(6,100,3);
Expand Down Expand Up @@ -79,7 +82,10 @@ void writeGlobalSet(uint8_t b) {
}

void writeParams(uint8_t b) {
if(global_conf.currentSet>2) global_conf.currentSet=0;
#ifdef MULTIPLE_CONFIGURATION_PROFILES
if(global_conf.currentSet>2)
#endif
global_conf.currentSet=0;
conf.checksum = calculate_sum((uint8_t*)&conf, sizeof(conf));
eeprom_write_block((const void*)&conf, (void*)(global_conf.currentSet * sizeof(conf) + sizeof(global_conf)), sizeof(conf));
readEEPROM();
Expand Down
7 changes: 7 additions & 0 deletions MultiWii.ino
Expand Up @@ -613,7 +613,12 @@ void setup() {
STABLEPIN_PINMODE;
POWERPIN_OFF;
initOutput();
#ifdef MULTIPLE_CONFIGURATION_PROFILES
for(global_conf.currentSet=0; global_conf.currentSet<3; global_conf.currentSet++) { // check all settings integrity
#else
{
global_conf.currentSet=0;
#endif
readEEPROM();
}
readGlobalSet();
Expand Down Expand Up @@ -801,6 +806,7 @@ void loop () {
}
}
#endif
#ifdef MULTIPLE_CONFIGURATION_PROFILES
if (rcSticks == THR_LO + YAW_LO + PIT_CE + ROL_LO) i=1; // ROLL left -> Profile 1
else if (rcSticks == THR_LO + YAW_LO + PIT_HI + ROL_CE) i=2; // PITCH up -> Profile 2
else if (rcSticks == THR_LO + YAW_LO + PIT_CE + ROL_HI) i=3; // ROLL right -> Profile 3
Expand All @@ -811,6 +817,7 @@ void loop () {
blinkLED(2,40,i);
alarmArray[0] = i;
}
#endif
if (rcSticks == THR_LO + YAW_HI + PIT_HI + ROL_CE) { // Enter LCD config
#ifdef TRI
servo[5] = 1500; // we center the yaw servo in conf mode
Expand Down
2 changes: 2 additions & 0 deletions Serial.ino
Expand Up @@ -246,6 +246,7 @@ void evaluateCommand() {
#endif
headSerialReply(0);
break;
#ifdef MULTIPLE_CONFIGURATION_PROFILES
case MSP_SELECT_SETTING:
if(!f.ARMED) {
global_conf.currentSet = read8();
Expand All @@ -255,6 +256,7 @@ void evaluateCommand() {
}
headSerialReply(0);
break;
#endif
case MSP_IDENT:
headSerialReply(7);
serialize8(VERSION); // multiwii version
Expand Down
3 changes: 3 additions & 0 deletions config.h
Expand Up @@ -864,6 +864,9 @@
/***************** ***************/
/*************************************************************************************************/

/************ Support multiple configuration profile in EEPROM **********/
//#define MULTIPLE_CONFIGURATION_PROFILES

/************ EXperimental: force a stable, fixated (high) cycle time **********/
/* when activated, the displayed cycle time in GUI will not be correct.
* Tunable via LCD config menu.
Expand Down

0 comments on commit 7c664d6

Please sign in to comment.