Pages: [1]   Go Down
Author Topic: error: invalid conversion from 'const char*' to 'int'  (Read 1896 times)
0 Members and 1 Guest are viewing this topic.
Melbourne, AU
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Like all things hard, learning about all things soft...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

when changing from...

Code:
void top_menu_function_5() //Replace this with the actual function of menu item #5
{
    int choice=yn_dialog("Start");
    lcd.clear();
    lcd.setCursor(0,1);
    lcd.print(choice); // Display the user choice one more time
    delay(user_input4);
    int motorspeed = 100;  // This sets up the speed the motor will turn
    motor2.step(user_input3, BACKWARD, SINGLE);  //Move the motor forward by the number of "Steps per frame
    motor2.release();  //  make sure the motor is at rest.
   wait_on_escape(4000);
   
}

to...

Code:
void top_menu_function_5() //Replace this with the actual function of menu item #5
{
    int yn_dialog("Start");
    lcd.clear();
    lcd.setCursor(0,1);
    //lcd.print(choice); // Display the user choice one more time
    delay(user_input4);
    int motorspeed = 100;  // This sets up the speed the motor will turn
    motor2.step(user_input3, BACKWARD, SINGLE);  //Move the motor forward by the number of "Steps per frame
    motor2.release();  //  make sure the motor is at rest.
   wait_on_escape(4000);
   
}

I get this error...

Code:
My_Menu_2_0.cpp: In function 'void top_menu_function_5()':
menu:202: error: invalid conversion from 'const char*' to 'int'

If you need the full sketch, please ask.

Can someone point out what I'm doing wrong.

Thanks.

Steve...
Logged

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 511
Posts: 19338
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the intention of this line?

Code:
    int yn_dialog("Start");
Logged

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Melbourne, AU
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Like all things hard, learning about all things soft...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the intention of this line?

Code:
    int yn_dialog("Start");

I'm using phi_prompt as a menu for a sketch with a LCD.

This is an extract from the document on phi_prompt.

13) int yn_dialog(char msg[]);
Parameters:
This renders a YES/NO dialog so the user can choose YES or NO.
Return values:
1 for YES and 0 for NO so the program can decide what to do in case of YES and NO. The dialog auto scales to occupy the entire display so you don‟t have to specify you have a 20X4 display or 16*2 display. See fig. 6-3 below.
Eg. int choice=yn_dialog(“Engage death ray now?”);
(a)
(b)
Figure 6-3. YES/NO dialog auto scales on 16X2 and 20X4 displays. (a) 16X2 display. (b) 20X4 display. Intended message was “Engage death ray now?”. The text is automatically wrapped to occupy multiple lines. The message will be clipped if it doesn‟t fit on a smaller display.

Steve...
Logged

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 511
Posts: 19338
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
Eg. int choice=yn_dialog(“Engage death ray now?”);

Yes, so why did you get rid of the variable that holds the response? The way you have it you are calling the function but discarding the result.
Logged

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 511
Posts: 19338
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

when changing from...

Code:
...
    int choice=yn_dialog("Start");
...

to...

Code:
...
    int yn_dialog("Start");
 ...

I get this error...


Put it another way. Why did you make this change in the first place?
Logged

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Melbourne, AU
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Like all things hard, learning about all things soft...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
Eg. int choice=yn_dialog(“Engage death ray now?”);

Yes, so why did you get rid of the variable that holds the response? The way you have it you are calling the function but discarding the result.

My apologies I got it wrong in the second part of the code, my intention is to change from a yes/no to just a OK. the changed code should be...

Code:
void top_menu_function_5() //Replace this with the actual function of menu item #5
{
    int ok_dialog("Start");
    lcd.clear();
    lcd.setCursor(0,1);
    //lcd.print(choice); // Display the user choice one more time
    delay(user_input4);
    int motorspeed = 100;  // This sets up the speed the motor will turn
    motor2.step(user_input3, BACKWARD, SINGLE);  //Move the motor forward by the number of "Steps per frame
    motor2.release();  //  make sure the motor is at rest.
   wait_on_escape(4000);
   
}

And the extract from the document...

12) int ok_dialog(char msg[]);
Parameters:
This renders an OK dialog. Primarily you want to show the user a message and the user needs to press a key to continue. Otherwise the function keeps waiting. It doesn‟t actually return a value. The return value type is there to be consistent with the YES/NO dialog and any future dialog functions. The OK dialog just needs the char array that has the message to show to the user. The message will be truncated if there is not enough space. The dialog auto scales to occupy the entire display so you don‟t have to specify you have a 20X4 display or 16*2 display. See fig. 6-2 below.
Eg. ok_dialog(“Death ray was engaged. Annihilation in progress...”);

Steve...
Logged

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 511
Posts: 19338
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
    int ok_dialog("Start");

You are getting confused here. ok_dialog is a function. It returns something. That something needs to go somewhere. Then you can test the somewhere. Like:


Code:
  int proceed = ok_dialog("Start");
  if (proceed)
     {
     // good to go
     } 
Logged

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 511
Posts: 19338
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Or, more simply:

Code:
  if (ok_dialog("Start"))
     {
     // good to go
     } 

Although judging by the description you posted, the return value doesn't mean anything. So it could just be:

Code:
  ok_dialog("Start");
Logged

http://www.gammon.com.au/electronics

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Melbourne, AU
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Like all things hard, learning about all things soft...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Or, more simply:

Code:
  if (ok_dialog("Start"))
     {
     // good to go
     } 

Although judging by the description you posted, the return value doesn't mean anything. So it could just be:

Code:
  ok_dialog("Start");

Ok thanks Nick, changing to

Code:
  ok_dialog("Start");

Now has the menu working, I just need now to work out why My stepper is not moving.

Steve...
Logged

Pages: [1]   Go Up
Jump to: