So I see how your example works but I have a question on handling the final submenu. For example:
Code:
// This is the main Menu for the settings
static const char Main_Menu [7][11] =
{
{"Main Menu" },
{"1.Motor " },
{"2.Comm " },
{"3.Valve " },
{"4.Movement" },
{"5.Calib " },
{"6.Info " }
};
static const char Motor_Menu [4][11] =
{
{"Motor Menu" },
{"1.G-Ratio " },
{"2.Encoder " },
{"3.Step " }
};
static const char GRatio_Menu [6][11] =
{
{"Gear Ratio" },
{"1.3.14 " },
{"2.4.75 " },
{"3.9.85 " },
{"4.14.91 " },
{"5.22.25 " }
};
Given the above menu strings I would like to accomplish the following:
1) User enters the main settings menu and then selects option #1 Motor settings
2) User then selects #1 Gear Ratio
3) inside the Gear Ration settings menu the user selects #2 4.75
So with that in mind I would need the following code:
Code:
menu GR_1 =
{
"1. 3.14",
Set_GR_3_14,
3,
0
};
menu GR_2 =
{
"2. 4.75",
Set_GR_4_75,
3,
0
};
etc...
Then I would need the following functions:
Code:
void Set_GR_3_14(void)
{
GR = 314; //no floating point stuff in my little system
}
void Set_GR_4_75(void)
{
GR = 475; //no floating point stuff in my little system
}
etc...
Now maybe I should have mentioned this sooner but my target is an 8-bit microcontroller so I don't have a lot of code space. This approach seems a little code space intensive.
What I am trying to do is have a generic function that I can simply pass an index value to so that it takes less code.
Code:
void Set_GR(int idx)
{
int options = {314, 475, etc...};
GR = options[idx];
}
Unless I have completely missed the point I am not sure your suggested code is going to fit in my code space.
Any other ideas?
Thanks,
v_dave