Go Back   Home > Forums > >
Home Forums Rules Articles diyAudio Store Blogs Gallery Wiki Register Donations FAQ Calendar Search Today's Posts Mark Forums Read

The Lounge A place to talk about almost anything but politics and religion.

C Programming problem
C Programming problem
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
Old 1st December 2005, 07:35 PM   #1
FuriousD is offline FuriousD  United Kingdom
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_MUTE (RC_ECODE|CBITS(13))

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


C Programming problemHide 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

Forum Jump

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 02:08 AM.

Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 16.67%
vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Copyright ©1999-2017 diyAudio