Hi All,
Having a little issue with phi_prompt, at the bottom of the code under
void top_menu_function_5()
when I add line
int choice=yn_dialog(“Start now?”);
I get the following
Example_menu:200: error: stray '' in program
Example_menu:200: error: stray '' in program
My_Menu_1_0.cpp: In function 'void top_menu_function_5()':
Example_menu:200: error: 'u201cStart' was not declared in this scope
Code below, truncated to fit (9500 characters is not enough)
the error will be in the next post...
/*
.______ __ __ __ .______ .______ ______ .___ ___. .______ .___________.
| _ \ | | | | | | | _ \ | _ \ / __ \ | \/ | | _ \ | |
| |_) | | |__| | | | | |_) | | |_) | | | | | | \ / | | |_) | `---| |----`
| ___/ | __ | | | | ___/ | / | | | | | |\/| | | ___/ | |
| | | | | | | | | | | |\ \----.| `--' | | | | | | | | |
| _| |__| |__| |__| _____| _| | _| `._____| \______/ |__| |__| | _| |__|
_______ .______ __ __ __ __
| \ | _ \ | | | | | | | |
| .--. || |_) | | | | | | | | |
| | | || / | | | | | | | |
| '--' || |\ \----. __ | `----.| | | `--' |
|_______/ | _| `._____| (__) |_______||__| \______/
http://liudr.wordpress.com
*/
/*
.___ ___. _______ .__ __. __ __
| \/ | | ____|| \ | | | | | |
| \ / | | |__ | \| | | | | |
| |\/| | | __| | . ` | | | | |
| | | | | |____ | |\ | | `--' |
|__| |__| |_______||__| \__| \______/
*/
// Menu texts
PROGMEM prog_char top_menu_item00[]="Interval"; // The interval between frames
PROGMEM prog_char top_menu_item01[]="Frames"; // The number of frames to be taken
PROGMEM prog_char top_menu_item02[]="Steps"; // The number of motor steps per frame
PROGMEM prog_char top_menu_item03[]="Delay"; // The delay before first frame taken
PROGMEM prog_char top_menu_item04[]="Start"; // Start the sequence of frames
PROGMEM const char *top_menu_items[] = {top_menu_item00, top_menu_item01, top_menu_item02, top_menu_item03, top_menu_item04};
//This program is the main menu. It handles inputs from the keys, updates the menu or executes a certain menu function accordingly.
int global_style=1; // This is the style of the menu
void top_menu()
{
int menu_pointer_1=0; // This stores the menu choice the user made.
phi_prompt_struct myMenu; // This structure stores the main menu.
// Initialize the top menu
myMenu.ptr.list=(char**)&top_menu_items; // Assign the list to the pointer
myMenu.low.i=0; // Default item highlighted on the list
myMenu.high.i=4; // Last item of the list is size of the list - 1.
myMenu.width=lcd_columns-((global_style&phi_prompt_arrow_dot)!=0)-((global_style&phi_prompt_scroll_bar)!=0); // Auto fit the size of the list to the screen. Length in characters of the longest list item.
myMenu.step.c_arr[0]=lcd_rows-1; // rows to auto fit entire screen
myMenu.step.c_arr[1]=1; // one col list
myMenu.step.c_arr[2]=0; // y for additional feature such as an index
myMenu.step.c_arr[3]=lcd_columns-4-((global_style&phi_prompt_index_list)!=0); // x for additional feature such as an index
myMenu.col=0; // Display menu at column 0
myMenu.row=1; // Display menu at row 1
myMenu.option=global_style; // Option 0, display classic list, option 1, display 2X2 list, option 2, display list with index, option 3, display list with index2.
while(1) // This loops every time a menu item is selected.
{
lcd.clear(); // Refresh menu if a button has been pushed
center_text("Macro Slide");
myMenu.option=global_style; // This makes sure the change of menu style is updated if there is a menu style option in this level of menu.
myMenu.width=lcd_columns-((global_style&phi_prompt_arrow_dot)!=0)-((global_style&phi_prompt_scroll_bar)!=0); // This makes sure the change of menu style is updated if there is a menu style option in this level of menu. Auto fit the size of the list to the screen. Length in characters of the longest list item.
myMenu.step.c_arr[3]=lcd_columns-4-((global_style&phi_prompt_index_list)!=0); // This makes sure the change of menu style is updated if there is a menu style option in this level of menu. x for additional feature such as an index
select_list(&myMenu); // Use the select_list to ask the user to select an item of the list, that is a menu item from your menu.
menu_pointer_1=myMenu.low.i; // Get the selected item number and store it in the menu pointer.
switch (menu_pointer_1) // See which menu item is selected and execute that correspond function
{
case 0:
top_menu_function_1();
break;
case 1:
top_menu_function_2();
break;
case 2:
top_menu_function_3();
break;
case 3:
top_menu_function_4();
break;
case 4:
top_menu_function_5();
break;
default:
break;
}
}
}
Continue from first post...
the rest of the code with the error causing lines, see last few lines...
// Menu functions go here. The functions are called when their menu items are selected. They are called only once so if you want to do something repeatedly, make sure you have a while loop.
void top_menu_function_1() //Replace this with the actual function of menu item #1
{
int user_input1=1000; // This is the storage for the integer
phi_prompt_struct myIntegerInput;
myIntegerInput.ptr.i_buffer=&user_input1; // Pass the address of the buffer. After library function call, user input will be stored in this variable.
myIntegerInput.low.i=0; // Lower limit of the number is 0
myIntegerInput.high.i=20000; // Upper limit of the number is 20
myIntegerInput.step.i=100; // Step size. User choice increments 2 every time you push up and decrements 2 when you press down.
myIntegerInput.col=7; // Display number at column 7
myIntegerInput.row=1; // Display number at row 1
myIntegerInput.width=2; // The number occupies 2 characters space.
myIntegerInput.option=0; // Option 0, space pad right, option 1, zero pad left, option 2, space pad left.
lcd.clear();
lcd.print(" 0 - 20,000ms"); // Prompt user for input
input_integer(&myIntegerInput); // This actually calls the library function to ask user for input. The input is stored in user_input, not the return value. The call supplies the address ("&") of the phi_prompt structure to the library function input_integer.
lcd.clear();
lcd.print("Frame Inrerval :"); // Display the user choice one more time
lcd.setCursor(0,1);
lcd.print(user_input1); // Prompt user for input
lcd.print(" ms");
wait_on_escape(4000);
}
void top_menu_function_2() //Replace this with the actual function of menu item #2
{
int user_input2=100; // This is the storage for the integer
phi_prompt_struct myIntegerInput;
myIntegerInput.ptr.i_buffer=&user_input2; // Pass the address of the buffer. After library function call, user input will be stored in this variable.
myIntegerInput.low.i=0; // Lower limit of the number is 0
myIntegerInput.high.i=500; // Upper limit of the number is 20
myIntegerInput.step.i=10; // Step size. User choice increments 2 every time you push up and decrements 2 when you press down.
myIntegerInput.col=7; // Display number at column 7
myIntegerInput.row=1; // Display number at row 1
myIntegerInput.width=2; // The number occupies 2 characters space.
myIntegerInput.option=0; // Option 0, space pad right, option 1, zero pad left, option 2, space pad left.
lcd.clear();
lcd.print("# of frames"); // Prompt user for input
input_integer(&myIntegerInput); // This actually calls the library function to ask user for input. The input is stored in user_input, not the return value. The call supplies the address ("&") of the phi_prompt structure to the library function input_integer.
lcd.clear();
lcd.print("# of Frames is :"); // Display the user choice one more time
lcd.setCursor(0,1);
lcd.print(user_input2); // Prompt user for input
lcd.print(" frames");
wait_on_escape(4000);
}
void top_menu_function_3() //Settings
{
int user_input3=50; // This is the storage for the integer
phi_prompt_struct myIntegerInput;
myIntegerInput.ptr.i_buffer=&user_input3; // Pass the address of the buffer. After library function call, user input will be stored in this variable.
myIntegerInput.low.i=0; // Lower limit of the number is 0
myIntegerInput.high.i=100; // Upper limit of the number is 20
myIntegerInput.step.i=10; // Step size. User choice increments 2 every time you push up and decrements 2 when you press down.
myIntegerInput.col=7; // Display number at column 7
myIntegerInput.row=1; // Display number at row 1
myIntegerInput.width=2; // The number occupies 2 characters space.
myIntegerInput.option=0; // Option 0, space pad right, option 1, zero pad left, option 2, space pad left.
lcd.clear();
lcd.print("Steps per Frame"); // Prompt user for input
input_integer(&myIntegerInput); // This actually calls the library function to ask user for input. The input is stored in user_input, not the return value. The call supplies the address ("&") of the phi_prompt structure to the library function input_integer.
lcd.clear();
lcd.print(user_input3); // Prompt user for input
lcd.print(" Motor Steps"); // Display the user choice one more time
lcd.setCursor(0,1);
lcd.print("Per Frame");
wait_on_escape(4000);
}
void top_menu_function_4() //Replace this with the actual function of menu item #4
{
int user_input4=10; // This is the storage for the integer
phi_prompt_struct myIntegerInput;
myIntegerInput.ptr.i_buffer=&user_input4; // Pass the address of the buffer. After library function call, user input will be stored in this variable.
myIntegerInput.low.i=0; // Lower limit of the number is 0
myIntegerInput.high.i=60; // Upper limit of the number is 20
myIntegerInput.step.i=10; // Step size. User choice increments 2 every time you push up and decrements 2 when you press down.
myIntegerInput.col=7; // Display number at column 7
myIntegerInput.row=1; // Display number at row 1
myIntegerInput.width=2; // The number occupies 2 characters space.
myIntegerInput.option=0; // Option 0, space pad right, option 1, zero pad left, option 2, space pad left.
lcd.clear();
lcd.print(" Start Delay "); // Prompt user for input
input_integer(&myIntegerInput); // This actually calls the library function to ask user for input. The input is stored in user_input, not the return value. The call supplies the address ("&") of the phi_prompt structure to the library function input_integer.
lcd.clear();
lcd.print("Start Delay is :"); // Display the user choice one more time
lcd.setCursor(0,1);
lcd.print(user_input4); // Prompt user for input
lcd.print(" Seconds");
wait_on_escape(4000);
}
void top_menu_function_5() //Replace this with the actual function of menu item #5
{
int choice=yn_dialog(“Start now?”);
lcd.clear();
lcd.setCursor(0,1);
lcd.print(choice); // Display the user choice one more time
wait_on_escape(4000);
}
Any help appreciated.
Steve...
Use yn_dialog("Start now?")
instead of yn_dialog(“Start now?”)
. Use the right quotes.
That did the trick, thanks mkwired.
Liudr, I did a cut & past from your Phi_prompt documentation 20110523.pdf
Thanks again.
Steve...
Nivin37:
That did the trick, thanks mkwired.
Liudr, I did a cut & past from your Phi_prompt documentation 20110523.pdf
Thanks again.
Steve...
Hahaha! I was caught by the same problem of left and right double quotations. Did you copy paste code from my documentation? Please do that with the sample code instead 
liudr:
Nivin37:
That did the trick, thanks mkwired.
Liudr, I did a cut & past from your Phi_prompt documentation 20110523.pdf
Thanks again.
Steve...
Hahaha! I was caught by the same problem of left and right double quotations. Did you copy paste code from my documentation? Please do that with the sample code instead 
Yes I did, not any more...
I have another small request.
At the end of the
wait_on_escape(xx);
time I would like the menu to move down to the next item or if I "do some down stuff"
and when at the last menu item there is a,
int choice=yn_dialog("Start now?");
I would like to "do some down stuff" which would take me back to the first top menu item & not reply with a 1 or 0.
Is this possible?
Steve...
You can make a modification to do that. I planned for it but never got around to implement the feature.
The last part of the phi_prompt structure is this:
void (*update_function)(phi_prompt_struct *);
All you have to do to use it is to assign a function address to it and insert a line of code in wait_on_escape to call it before escaping. Give it a try.