Brain dead day
Thomas Hayes
Posts: 1,164
Hello everyone.
I am trying to program a Sanyo XP-41 projector. I have my AXI file and source code that works fine. (So why did I say I want to program this projector?) I want to make the AXI code more standard with my other code, thus making it easier to swap out projectors without changing the soucre code.
The Sanyo uses ASCII code and a 'CR' command to execute a command.ie 'C00'(power on?) command would look like this in my existing code
SEND_STRING PROJ,"PROJ_ON,CR"
I want to be able to lose the ",CR" so it matches my other rooms code that looks like this:
SEND_STRING PROJ,PROJ_ON
looks simple but when I try to combine the 'CRO' and 'CR' commands they don't work. I have tried different configurations and locations but no go.
Samples of what I have tried:
VOLATILE PROJ_ON[14] ={'C00,CR'}
VOLATILE PROJ_ON[14] ={"'C00',CR"}
VOLATILE PROJ_ON[14] ={"'C00','CR'"}
VOLATILE PROJ_ON[14] ={"C00,CR"}
VOLATILE PROJ_ON[14] ={'C00','CR'}
Anyone tell me what config. I've missed or where to go
I am trying to program a Sanyo XP-41 projector. I have my AXI file and source code that works fine. (So why did I say I want to program this projector?) I want to make the AXI code more standard with my other code, thus making it easier to swap out projectors without changing the soucre code.
The Sanyo uses ASCII code and a 'CR' command to execute a command.ie 'C00'(power on?) command would look like this in my existing code
SEND_STRING PROJ,"PROJ_ON,CR"
I want to be able to lose the ",CR" so it matches my other rooms code that looks like this:
SEND_STRING PROJ,PROJ_ON
looks simple but when I try to combine the 'CRO' and 'CR' commands they don't work. I have tried different configurations and locations but no go.
Samples of what I have tried:
VOLATILE PROJ_ON[14] ={'C00,CR'}
VOLATILE PROJ_ON[14] ={"'C00',CR"}
VOLATILE PROJ_ON[14] ={"'C00','CR'"}
VOLATILE PROJ_ON[14] ={"C00,CR"}
VOLATILE PROJ_ON[14] ={'C00','CR'}
Anyone tell me what config. I've missed or where to go
0
Comments
VOLATILE PROJ_ON[14] ={'C','0','0','C','R'} // If the 'CR' is an ASCII string
or
VOLATILE PROJ_ON[14] = {'C','0','0',$0D} // If the 'CR' is an actual carriage return.
--D
Better IMHO:
VOLATILE CHAR PROJ_ON[] ={'C','0','0','C','R'};
Assign a type and use a ; at the end; clearer and safer.
Don't assign a length, let the compiler do it for you.
Fred
VOLATILE PROJ_ON[4] ={"'C00',$0D"} is the right way.
I programmed a lot of sanyo but never use constants in this way.
I always do the following
SA_POW_ON = 'C00'
And in the program: send_string device,"SA_POW_ON,$0D"
Any way if you don't declare CR=$0D or CR=13 you can't use CR but you must use $0D or 13 instead.
Good luck
but wanted to modify it to appear like my other projectors that use ( SEND_STRING PROJ,PROJ_ON ) this way I would only have to change AXI files and not the code if I swapped a projector. Thanks everyone.
DEFINE_CONSTANTS
CHAR PWR_ON = 'C00'
CHAR PWR_OFF = 'CO1'
CR = $0D
or
TERM = $OD
Then in your code, you use the following:
SEND_STRING PROJ,"PWR_ON,CR"
or
SEND_STRING PROJ,"PWR_ON,TERM"
In this way, the string terminator (TERM) can be anything (even possibly a null-string, although I haven't tried that) and PWR_ON can be any single byte or string value.
Hope this helps.
Sheldon Samuels
I did a little test for you and to only way i get it worked is like this
DEFINE_CONSTANT
PROJ_ON[]={$43,$30,$30,$0D} // HEX FOR 'C00',$0D
SEND_STRING PROJ,"PROJ_ON"
Give it a try
Good luck
Works:
VOLATILE CHAR PROJ_ON[] ={'C','0','0',$0D}
VOLATILE CHAR PROJ_ON[] ={'C00'} Then SEND_STRING PROJ,"PROJ_ON,13"
DOESN'T WORK:
VOLATILE CHAR PROJ_ON[] ={'C00',$0D}
It doesn't make alot of sense to me why I had to separate the 'C00' just because I added $0D but who am I to ask as long as the code looks the way I want it to and it works.
VOLATILE CHAR PROJ_ON[10]
// ...later in code, startup maybe
PROJ_ON = "'C00',$0D"
Right, he did it and it worked and he tells us all about it above... :-)
And you figured it all yourself before I could post that and now I can't seem to find a way to delete the message
For strings like these, I just do 'em as variables so I can still use double quotes & all... If it's an array, I define 'em in DEFINE_START.
Just to be old fashioned...
- Chip
DEFINE_CONSTANTS
CHAR PWR_ON = 'C00'
CHAR PWR_OFF = 'CO1'
And they work. I can't explain why. I haven't done all that much of this myself. But I do sometimes set up room names as follows:
CHAR RmNames[][20] =
{
'Name1',
'Name2',
'Name3',
etc.
}
as either variables or constants. I'm not always consistent in why I use one or the other. But either way, they work. Then I can recall a name simply by using a pointer to the array, like RmName[3] (to get 'Name3').
For what it's worth.