|The Lounge A place to talk about almost anything but politics and religion.|
Please consider donating to help us continue to serve you.
Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
||Thread Tools||Search this Thread|
|1st December 2005, 08:35 PM||#1|
Join Date: Jun 2004
C Programming problem
I'm an audiophile and an electronics designer by day. I have a RC5 remote control design that I have inherited in C that runs my pre-amp, but it interferes with my TV. Unfortunately i'm a Pascal man completely. I have picked up most things, but I need to be able to decipher the constant declarations below. They denote the translation from the decoded manchester input from the IR receiver. But I have searched every thing I can find on google and have found no reference to the syntax used.
Can anyone out there help me to get a binary representation of each of the constant values. i.e. RC_VOLUP etc It's the CBITS line that is really messing me up!
// definitions of remote keys
#define CBITS(x) (((x) & 0x3f) | ((x & 0x40) ? 0x1000 : 0))
#define RC_ECODE (0x10 << 6)
#define RC_NONE 0x0000
#define RC_VOLUP (RC_ECODE|CBITS(16))
#define RC_VOLDOWN (RC_ECODE|CBITS(17))
#define RC_INPUTLEFT (RC_ECODE|CBITS(85))
#define RC_INPUTRIGHT (RC_ECODE|CBITS(86))
#define RC_STANDBY (RC_ECODE|CBITS(12))
#define RC_MUTE (RC_ECODE|CBITS(13))
#define RC_SELECT (RC_ECODE|CBITS(87))
|1st December 2005, 10:38 PM||#2|
Join Date: Aug 2003
Blog Entries: 22
ok I'm guessing that it is the question mark that is confusing the issue??? it is a ternary operator, basically what it says is (if x logically anded with 0x40 is true then 0x1000 else 0
so we end up with the argument to cbits being anded with 0x3f then or'ed with either 0x1000 or 0 depending on the result of anding the argument with 0x40....
is that clear??
Any intelligence I may appear to have is purely artificial!
Some of my photos
|Thread Tools||Search this Thread|
|Thread||Thread Starter||Forum||Replies||Last Post|
|Up to date PIC programming||TroelsM||Everything Else||4||6th May 2009 09:54 PM|
|microcontroller programming||traf||Digital Source||7||12th September 2007 01:49 PM|
|PIC programming||serosmaness||Digital Source||12||6th February 2005 11:33 PM|
|PIC programming||future||Parts||33||4th June 2003 05:26 AM|
|New To Site?||Need Help?|