Hello,
I have the code below in which function void PutStringValue(byte Param)
doesn't return "" value according to each case. from my obesrvations RetStr = ""; dosen't work all the times
Any idea why?
And another strange thig is that when i call the function eg. PutStringValue(10), the Param in the function parameter is 0010 or 010
so..any idea?
I'm using an arduino uno.
char *RetStr;
void DrawMenu()
{
byte Len;
if (CrtMenu.ID != pMenu.ID)
{
lcd.clear(BLACK);
pMenu.ID = CrtMenu.ID;
pMenu.Pos = 0;
for(byte i=0; i < CrtMenu.Size; i++)
{
PutStringValue(CrtMenu.Item[i].fParam);
Len = 16 + strlen(CrtMenu.Item[i].Label) * 8;
if(i == CrtMenu.Pos)// If i is the current position, then write the string on white on black bg
{
lcd.drawText(CrtMenu.Item[i].X-8, CrtMenu.Item[i].Y, ">", 0, hText, txtBGColor);
lcd.drawText(CrtMenu.Item[i].X, CrtMenu.Item[i].Y, CrtMenu.Item[i].Label, 0, hText, txtBGColor);
lcd.drawText(CrtMenu.Item[i].X + Len, CrtMenu.Item[i].Y, RetStr, 0, hText, txtBGColor);
}
else
{
lcd.drawText(CrtMenu.Item[i].X, CrtMenu.Item[i].Y, CrtMenu.Item[i].Label, 0, nText, txtBGColor);
lcd.drawText(CrtMenu.Item[i].X + Len, CrtMenu.Item[i].Y, RetStr, 0, nText, txtBGColor);
}
}
}
els
{
if(CrtMenu.Pos != pMenu.Pos)
{
Len = 16 + strlen(CrtMenu.Item[pMenu.Pos].Label) * 8;
lcd.drawText(CrtMenu.Item[pMenu.Pos].X-8, CrtMenu.Item[pMenu.Pos].Y, ">", 0, txtBGColor, txtBGColor);
lcd.drawText(CrtMenu.Item[pMenu.Pos].X, CrtMenu.Item[pMenu.Pos].Y, CrtMenu.Item[pMenu.Pos].Label, 0, nText, txtBGColor);
PutStringValue(CrtMenu.Item[pMenu.Pos].fParam);
lcd.drawText(CrtMenu.Item[pMenu.Pos].X + Len, CrtMenu.Item[pMenu.Pos].Y, RetStr, 0, nText, txtBGColor);
Len = 16 + strlen(CrtMenu.Item[CrtMenu.Pos].Label) * 8;
lcd.drawText(CrtMenu.Item[CrtMenu.Pos].X-8, CrtMenu.Item[CrtMenu.Pos].Y, ">", 0, hText, txtBGColor);
lcd.drawText(CrtMenu.Item[CrtMenu.Pos].X, CrtMenu.Item[CrtMenu.Pos].Y, CrtMenu.Item[CrtMenu.Pos].Label, 0, hText, txtBGColor);
PutStringValue(CrtMenu.Item[CrtMenu.Pos].fParam);
lcd.drawText(CrtMenu.Item[CrtMenu.Pos].X + Len, CrtMenu.Item[CrtMenu.Pos].Y, RetStr, 0, hText, txtBGColor);
pMenu.Pos = CrtMenu.Pos;
}
}
}
void PutStringValue(byte Param)
{
RetStr = "";
switch(Param)
{
case ROM_Sequence://Sequence Off=0/On=1
if (ROM_VAL[Param].Value == 0)
RetStr = "Off ";
else
RetStr = "On ";
break;
case ROM_S1_TrigAt://Sensor1 triggerat0=Low/1=High Value
case ROM_S2_TrigAt://Sensor2 trigger at 0=Low/1=HighValue
if (ROM_VAL[Param].Value == 0)
RetStr = "High";
else
RetStr = "Low ";
break;
case ROM_D1_TrigBy://Device1 is triggered by 0=None/1=Sensor1/2=Sensor2
case ROM_D2_TrigBy://Device2 is triggered by 0=None/1=Sensor1/2=Sensor2
switch(ROM_VAL[Param].Value)
{
case 0:
RetStr = "None";
break;
case 1:
RetStr = "Sen1";
break;
case 2:
RetStr = "Sen2";
break;
}
break;
case ROM_D2_Mode://Device2 0=None,1=Camera,2=Flash,3=Split
switch(ROM_VAL[Param].Value)
{
case 0:
RetStr = "None";
break;
case 1:
RetStr = "Came";
break;
case 2:
RetStr = "Flas";
break;
case 3:
RetStr = "Spli";
break;
}
break;
case ROM_SDelay://Sequence Delay 0-9999[ms] between Shutter1 and Shutter2 if ROM_Sequence=1
case ROM_Bulb://Exposure in Bulb Mode 0-3599[s]
itoa(ROM_VAL[Param].Value, RetStr, 10);
//sprintf(RetStr, "%d", ROM_VAL[Param].Value);
break;
default:
RetStr = "";
}
RetStr = "";
// Serial.print(" RetStr => ");Serial.print(RetStr);Serial.println();
}
.............................