Table-ize the Mode A to C conversions, add a Mode C to Mode A conversion function.
This commit is contained in:
parent
10b5cde505
commit
60f1f3bcb6
7 changed files with 68 additions and 7 deletions
12
track.h
12
track.h
|
|
@ -200,4 +200,16 @@ struct aircraft *trackUpdateFromMessage(struct modesMessage *mm);
|
|||
/* Call periodically */
|
||||
void trackPeriodicUpdate();
|
||||
|
||||
/* Convert from a (hex) mode A value to a 0-4095 index */
|
||||
static inline unsigned modeAToIndex(unsigned modeA)
|
||||
{
|
||||
return (modeA & 0x0007) | ((modeA & 0x0070) >> 1) | ((modeA & 0x0700) >> 2) | ((modeA & 0x7000) >> 3);
|
||||
}
|
||||
|
||||
/* Convert from a 0-4095 index to a (hex) mode A value */
|
||||
static inline unsigned indexToModeA(unsigned index)
|
||||
{
|
||||
return (index & 0007) | ((index & 0070) << 1) | ((index & 0700) << 2) | ((index & 07000) << 3);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue