Go Down

Topic: Problems with R/C 6ch transmission (Read 4 times) previous topic - next topic

Carlos mononoke

So, if i have understand you well, for use mode variable, the gMode is a variable that I must declare before setup or is something that  I can use becouse the library have it.
And when I use if stament I understand that I am allowing to read and copy, but when I am out the flags from rc control will change but the arduino don´t go becouse gMode != RC_CONTROL but Will I need to change gMode to oder value in the code,not? which value/state is this??

DuaneB

You have the idea mostly right.

You mentioned that you have a menu and in two menu options you want RC Control - you could represent each of your menu options as a mode - MODE_MANUAL, MODE_RC_NORMAL, MODE_RC_XXX etc

Then you can have a 'switch case' statement inside loop which does different things depending on the value of gMode -

Code: [Select]

switch(gMode)
{
case MODE_MANUAL:
  // put your manual control code here
break;
case MODE_RC_NORMAL:
  // put your manual control code here
break;
case MODE_RC_XXX:
  // put your manual control code here
break;
}


If you modes are very different, one way that I have done this in the past is to have the code I want for each mode in a separate function -

Code: [Select]
switch(gMode)
{
case MODE_MANUAL:
  doModeManual();
  break;
case MODE_RC_NORMAL:
  doModeRCNormal();
break;
case MODE_RC_XXX:
doModeRCXXX();
break;
// etc etc etc
}


This might also help - http://www.arduino.cc/en/Reference/SwitchCase

Duane B

rcarduino.blogspot.com

Carlos mononoke

Yes,i have use switch/case stament for built the menus, and the thing is gMode tath is a variable that i don´t need to define becouse is created by library which values can take( mode_manual,mode_rc,rc_control....)

do you know what I mean?? where can I see the values that i can espect from gMode or i need to define the variable gmode and decide whitch values will contain... and in this case witch kind of variables are this?

DuaneB

Hi,
gMode was just a suggestion, its not in the library ,if you already have a switch/case set up with your modes, add the RC Code to the modes you need it in and leave it out of the others, thats enough to achieve what you want.

Duane B



Carlos mononoke

sorry I am not understanding well, what kind of variable will be gMode(int,boolean...)?
becouse I am understanding that will be one that I can define the spected values (RC_MODE,NO_RC_MODE)

Thanks!!!

Go Up