| ??? 05/05/08 16:51 Read: times |
#154435 - Config. Parameter save to Flash |
In a application I need to do the following :
- Allow the user to alter 6 timing parameters ( all have a range of 1-90 sec) - Use one Inc push button and Dec push button to alter and once the right value is reached, press Enter push button to write value to Flash. - Pressing Enter also brings up the next parameter to edit in the sequence and once all 6 parameters are saved, wait for a reset to enter RUN mode. While I have put together some obvious C-code, I really feel it can be compressed and made more elegant.Just have a look at the code meant to alter and save the first parameter. At the end it closes access to the first parameter and opens up the second one. I can simply copy and paste this code 5 more times changing only the parameter name - but that woould be funny right ?
void EditSaveVal (void)
{
if ( CTParam ) // Edit the Cycle Time values
{
if ( !IncPB ) // Handle Increment command
{
if ( CycleTime < 90 )
{
++CycleTime;
}
else
{
CycleTime = 90; // Freeze at Upper limit
}
}
if ( !DecPB ) // Handle Decrement command
{
if ( CycleTime > 1 )
{
--CycleTime;
}
else
{
CycleTime = 0; // Freeze at lower limit
}
}
if ( !EnterPB )
{
CTParam = 0; // Cycle Time edit over
PRTParam = 1; // Allow Press. Ramp time edit next
<flash saving routine..>
}
sprintf( string , " Cycle Time Sec: %02u", CycleTime);
display(string);
msDelay(200);
}
}
Raghu |
| Topic | Author | Date |
| Config. Parameter save to Flash | 01/01/70 00:00 | |
| erase, then write, both are ... | 01/01/70 00:00 | |
| The chip is a Silabs F8051F020 | 01/01/70 00:00 | |
| Walking write | 01/01/70 00:00 | |
| an issue and an answer | 01/01/70 00:00 | |
| Some questions | 01/01/70 00:00 | |
| Brief postings.... | 01/01/70 00:00 | |
| Parameter Storage.... | 01/01/70 00:00 | |
| The issue with migration..from ASM to C | 01/01/70 00:00 | |
killing a possible misconception | 01/01/70 00:00 |



