Hi everyone,
I have a bit of a situation here. From the code below, its just a function for obtaining key codes from 1-6 and left and right. the left and right keys are detached from the system but it serves as a 1-6 button function. the right button to increase from 1-6 and the left button is to decrease from 6-1.
the problem i am facing right now is that i cant seem to get the same value that the keys 1-6 are holding when i press the left/right keys.
example:
1. i pressed button number 5. so i am currently on channel 5.
2. i press the right key. by right it should display channel 6 and if i press the right key again, it should be displaying channel 1 (in a loop)
3. what i get is, after pressing button number 5, and then pressing the right key, it displayed channel 1 instead of channel 6.
4. this shows that i may not be saving the value from the 1-6 keys.
Is there any opinions on how I should deal this with?
thanks
Code:
switch (ky_getKyCode()) {
case K_1:
d_kyRaCmd = L_PCH1_KEY; /* Channel 1 */
break;
case K_2:
d_kyRaCmd = L_PCH2_KEY; /* Channel 2 */
break;
case K_3:
d_kyRaCmd = L_PCH3_KEY; /* Channel 3 */
break;
case K_4:
d_kyRaCmd = L_PCH4_KEY; /* Channel 4 */
break;
case K_5:
d_kyRaCmd = L_PCH5_KEY; /* Channel 5 */
break;
case K_6:
d_kyRaCmd = L_PCH6_KEY; /* Channel 6 */
break;
case K_RIGHT_R: /* right key for remote*/
{
if((key_counter != 0) && (key_counter < 6))
{
pchno = key_counter; /* Store working Channel number */
pchno++;
}
else
{
key_counter = 1;
pchno = d_wpch; /* Store working Channel number */
}
}
break;
case K_LEFT_R: /*left key for remote*/
{
if(key_counter > 0)
{
pchno = key_counter; /* Store working Channel number */
pchno--;
}
else
{
key_counter = 6;
pchno = key_counter; /* Store working Channel number */
}
}
break;
}
if (key_counter == 1)d_kyRaCmd = L_PCH1_KEY;
else if (key_counter == 2)d_kyRaCmd = L_PCH2_KEY;
else if (key_counter == 3)d_kyRaCmd = L_PCH3_KEY;
else if (key_counter == 4)d_kyRaCmd = L_PCH4_KEY;
else if (key_counter == 5)d_kyRaCmd = L_PCH5_KEY;
else if (key_counter == 6)d_kyRaCmd = L_PCH6_KEY;
if(key_counter >6)
{
key_counter = 1;
}
else
{
key_counter = pchno; /* Store working Channel number */