Skip to content

Commit

Permalink
[#312] Save power curve in profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
ClockSelect committed Jul 24, 2017
1 parent 8d6feaa commit 0538a8e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Binary file modified bin/myevic.bin
Binary file not shown.
15 changes: 14 additions & 1 deletion src/dataflash.c
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,7 @@ const uint8_t ProfileFilter[32] =
/* 0060 */ 0b00000000,
/* 0068 */ 0b00000000,
/* 0070 */ 0b00000011,
/* 0078 */ 0b00000000,
/* 0078 */ 0b11110000,
/* 0080 */ 0b11101011,
/* 0088 */ 0b11111110,
/* 0090 */ 0b10000000,
Expand All @@ -1392,6 +1392,11 @@ const uint8_t ProfileFilter[32] =
/* 00F8 */ 0b00000000
};

// Saved status bits
// - Power curve enable state
const uint32_t StatusFilter = 0b00010000000000000000000000000000;


//-------------------------------------------------------------------------
// Apply newly reloaded parameters
//-------------------------------------------------------------------------
Expand Down Expand Up @@ -1427,10 +1432,18 @@ __myevic__ void LoadProfile( int p )
s = (uint8_t*)params;
d = (uint8_t*)DataFlash.params;

uint32_t new_status = *(uint32_t*)&s[offsetof(dfParams_t,Status)];
uint32_t old_status = *(uint32_t*)&d[offsetof(dfParams_t,Status)];

new_status &= StatusFilter;
old_status &= ~StatusFilter;

for ( idx = 0 ; idx < DATAFLASH_PARAMS_SIZE ; ++idx )
if ( ProfileFilter[idx/8] & ( 0x80 >> ( idx & 7 ) ) )
d[idx] = s[idx];

*(uint32_t*)&d[offsetof(dfParams_t,Status)] = old_status | new_status;

DFCheckValuesValidity();
ApplyParameters();
}
Expand Down
4 changes: 4 additions & 0 deletions src/menus.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,10 @@ __myevic__ int PreheatMEvent( int event )
if ( dfPreheatPwr < 10 ) dfPreheatPwr = 10;
}
}
else
{
gFlags.edit_value ^= 1;
}
UpdateDFTimer = 50;
gFlags.refresh_display = 1;
vret = 1;
Expand Down

0 comments on commit 0538a8e

Please sign in to comment.