C Programming problem - diyAudio
Go Back   Home > Forums > Member Areas > The Lounge

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
Reply
 
Thread Tools Search this Thread
Old 1st December 2005, 07:35 PM   #1
diyAudio Member
 
Join Date: Jun 2004
Location: UK
Default C Programming problem

Hi All.

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))

Help please.
  Reply With Quote
Old 1st December 2005, 09:38 PM   #2
just another
diyAudio Moderator
 
wintermute's Avatar
 
Join Date: Aug 2003
Location: Sydney
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??

Tony.
__________________
Any intelligence I may appear to have is purely artificial!
Some of my photos
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Up to date PIC programming TroelsM Everything Else 4 6th May 2009 08:54 PM
microcontroller programming traf Digital Source 7 12th September 2007 12:49 PM
PIC programming serosmaness Digital Source 12 6th February 2005 10:33 PM
PIC programming future Parts 33 4th June 2003 04:26 AM


New To Site? Need Help?

All times are GMT. The time now is 03:32 AM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright 1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2