well, as you can see from the title, I need to put together some of the most odd and obscure features of C. i have this structure containing some settings:
typedef struct
{
unsigned int channel : 4;
unsigned int octave : 4;
unsigned int sens : 1;
unsigned int patch : 7;
unsigned int waveform : 3;
unsigned int threshold : 9;
unsigned int tone : 4;
}Settings;
and i want to be able to change them using my menu-driven display and a "multipurpose function" that, called with those variables (obviously given by reference and not by value), can show and edit them, instead of writing the same code tons of time. here's a little effort (the parts between /**/ comments are the pieces of code i wansn't able to write):
void editSetting(char *str, /* don't know what to put here */)
{
/* storing the old value */
byte state = IDLE; //variable containing the status of my keypad
byte save = 255; // 255=do nothing 1=save and exit 0=exit only
lcd.setCursor(0, 1);
lcd.print(str); //the function also accepts and writes a string used as a description
lcd.setCursor(9, 2);
while(save != 255)
{
state = buttonCheck(A0)
switch(state)
{
case UP: /* increments the variable */
break;
case DOWN: /* decrements the variable */
break;
case SEL: save = 1;
break;
case BACK: save = 0;
break;
}
if(state==SEL || state== BACK)
break;
lcd.print(/*variable*/);
}
if(state == SEL)
/*just quit*/
if(state == back)
/*reset the variable to the old value saved before and then quit*/
}
hope i was clear, and thanks in advance for your help!