Hello all,
I think I need your help to resolve this.
I have a radio that accepts commands via its serial port.
My project is to remote control it (wireless or infrared) to change memories, volume, etc...
Until now everything is OK so I'm posting only the program part I have stucked.
With the following subroutine I want to increase the volume.
So, first I want to read the current volume setting and then add 10 to increase the volume by ten units.
But the radio is not accepting that command (and only that command).
I think the problem is with the number format of the variables i use.
As you can see from the code, the volume (and most other radio settings) has values from 0 - 254.
For some unknown to me reason, the radio uses 2 bytes for theses values and not one.
So, first byte gets values from 0 - 2 and second byte gets values from 0-99.
To display them correctly to my serial LCD i use the HEX modifier and the appear OK as I manualy (not remotely) change the volume.
At the end of the program I have entered some commands (for testing) to change the volume and they work fine !
But when I place the variables in the SEROUT2 command nothing happens and the volume remains at the same level.
What am I doing wrong ? Do you see something that needs to be changed for this thing to work ?
Thanx in advance
Fanias
I think I need your help to resolve this.
I have a radio that accepts commands via its serial port.
My project is to remote control it (wireless or infrared) to change memories, volume, etc...
Until now everything is OK so I'm posting only the program part I have stucked.
With the following subroutine I want to increase the volume.
So, first I want to read the current volume setting and then add 10 to increase the volume by ten units.
But the radio is not accepting that command (and only that command).
I think the problem is with the number format of the variables i use.
As you can see from the code, the volume (and most other radio settings) has values from 0 - 254.
For some unknown to me reason, the radio uses 2 bytes for theses values and not one.
So, first byte gets values from 0 - 2 and second byte gets values from 0-99.
To display them correctly to my serial LCD i use the HEX modifier and the appear OK as I manualy (not remotely) change the volume.
At the end of the program I have entered some commands (for testing) to change the volume and they work fine !
But when I place the variables in the SEROUT2 command nothing happens and the volume remains at the same level.
What am I doing wrong ? Do you see something that needs to be changed for this thing to work ?
Code:
'################################################################################################################################
' VOLUME UP SUBROUTINE
'
VOLUP: ' All variables are set as bytes
'
'--------------------------------------------------------------------------------------------------------------------------------
' Volume in range 000 - 254
' f1 values are 00,01,02
' f2 values are 00 - 99
'--------------------------------------------------------------------------------------------------------------------------------
SEROUT2 CIVP,CIVS,[$FE,$FE,CIVA,$E0,$14,$01,$FD] ' Send this to the radio to read Audio SETTING - WORKS !!!
SERIN2 CIVP,CIVS,[SKIP 6,f1,f2] ' Skip first 6 useless bytes and read next 2 volume bytes - WORKS !!!
'--------------------------------------------------------------------------------------------------------------------------------
' The next 4 lines are only for testing and to display a total volume value (000-254) to LCD in decimal
'--------------------------------------------------------------------------------------------------------------------------------
x1 = f1 & %00001111 ' read units - WORKS !!!
x2 = f2 >> 4 ' divide / 2^4 = 16 (tens) - WORKS !!!
x3 = f2 & %00001111 ' read units - WORKS !!!
Z = x1 * 100 + x2 * 10 + x3 ' a number between 0 - 254
'--------------------------------------------------------------------------------------------------------------------------------
f3 = f1 ' Same value for testing purposes only
f4 = f2 + 10 ' Increase volume by 10 units - This is what I want to do
pause 50 ' Give some time to radio to recover from SERIN2
SEROUT2 CIVP,CIVS,[$FE,$FE,civa,$E0,$14,$01,$f3,$f4,$FD] ' Send this to the radio for NEW VOLUME setting - NOT WORKING :(
'SEROUT2 CIVP,CIVS,[$FE,$FE,civa,$E0,$14,$01,f3,f4,$FD] ' Send this to the radio for NEW VOLUME setting (no $) - NOT WORKING :(
'--------------------------------------------------------------------------------------------------------------------------------
serout2 lcdp,lcds,[i,line1," DEC : ", DEC3 Z,"-",DEC2 f3, DEC2 f4] ' Just print to serial LCD for debugging - It's correct + 10
serout2 lcdp,lcds,[i,line2," HEX : ", DEC3 Z,"-",HEX2 f1, HEX2 f2] ' Just print to serial LCD for debugging - It's correct
pause 50 ' Give some time to radio to recover from SEROUT2
'--------------------------------------------------------------------------------------------------------------------------------
' The following 3 lines are only for testing purposes - they all work OK !!!!!!!!!!!!
'--------------------------------------------------------------------------------------------------------------------------------
SEROUT2 CIVP,CIVS,[$FE,$FE,civa,$E0,$14,$01,$00,$00,$FD] ' Mute, no sound, Z = 0 - WORKS OK !!!
SEROUT2 CIVP,CIVS,[$FE,$FE,civa,$E0,$14,$01,$01,$28,$FD] ' 50% volume, Z = 128 - WORKS OK !!!
SEROUT2 CIVP,CIVS,[$FE,$FE,civa,$E0,$14,$01,$02,$54,$FD] ' 100% volume, Z = 254 - WORKS OK !!!
SEROUT2 CIVP,CIVS,[$FE,$FE,civa,$E0,$14,$01,$00,$00,$FD] ' Mute again - my ears !!! - WORKS OK !!!
'--------------------------------------------------------------------------------------------------------------------------------
RETURN ' Go back to main routine to check for another button press
'
'################################################################################################################################
Fanias