Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

MAKE_NEEDLE: Extremely baffled!

Featured Replies

Okay, I can't figure this one out at all. Anyone willing to put forth some assistance, I would be grateful. I'll try to make the question clear, since the issue isn't.I'm working on an EICAS gauge. I have the N1 needles working properly. Also displayed is the EGT readings. However, even though the EGT MAKE_NEEDLE functions are basically the same as the N1 setup, the EGT needles don't display properly.Here's an example of my code://-------------------------------------------------------------------#define GAUGE_MIN_EGTL 0#define GAUGE_MAX_EGTL 760NONLINEARITY egtl_nlt[]={ {{135,209},0,0}, {{132,226},421,0}, {{32,239},666,0}, {{35,175},730,0}, {{39,171},760,0}};FLOAT64 FSAPI egtl_ndl_cb(PELEMENT_NEEDLE pelement){ FLOAT64 val_egtl_ndl = pelement->source_var.var_value.n; if(val_egtl_ndl > GAUGE_MAX_EGTL) val_egtl_ndl = GAUGE_MAX_EGTL; if(val_egtl_ndl < GAUGE_MIN_EGTL) val_egtl_ndl = GAUGE_MIN_EGTL; return val_egtl_ndl;}MAKE_NEEDLE( ndl_egtl, BMP_NEEDLE_EGT, NULL, NULL, IMAGE_USE_ERASE, 0, 79,209, 1,56, GENERAL_ENGINE1_EGT, egtl_ndl_cb, egtl_nlt, 3)//-------------------------------------------------------------------If there are any glaring errors in here, please point me in the right direction for a fix. The needles show up on the gauge, but don't move, even though the digital readout (MAKE_STRING) works fine.Thanks,Matt

Okay, I'm an idiot... The problem lay not in the code or the nonlinearity table, but in the Token Variable. I forgot to convert it from Deg Ra to Deg C.

  • Moderator

Just out of curiosity, why do you bother with "named constants?"if(val_egtl_ndl > GAUGE_MAX_EGTL)val_egtl_ndl = GAUGE_MAX_EGTL;if(val_egtl_ndl < GAUGE_MIN_EGTL)val_egtl_ndl = GAUGE_MIN_EGTL;Why not simply:if(val_egtl_ndl > 760)val_egtl_ndl = 760;if(val_egtl_ndl ;)

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator

Hey, Bill.A couple of reasons, actually:1. Most of my programming experience came from VB, and it's habit. I had a #### of a time getting the OOP dynamic out of my head when I started this project.2. I'm still really new to C programming and it helps keep me clear on what's what!I don't mind the typing, really; I write, so typing isn't a difficulty.

Using #defines for numbers is a good idea as soon as they're used in more than one place. I know a lot of people who always use #defines for any kind of constant.

And why not even simpler ?val_egtl_ndl=max(GAUGE_MIN_EGTL,min(GAUGE_MAX_EGTL,val_egtl_ndl));;-)

  • Author

A quote from Kernighan and Ritchies's classic - The C Progamming Language:'It's bad practice to bury "magic numbers" like 300 or 20 in a program; they convey little information to someone who might have to read the program, and they are hard to change in a systematic way.'

Gerry Howard

  • Author

>And why not even simpler ?>>val_egtl_ndl=max(GAUGE_MIN_EGTL,min(GAUGE_MAX_EGTL,val_egtl_ndl));>>;-)Because simpler code isn't necessarily the faster in execution.The functions max and min will still have to make the comparisions in the original code and will have the additional overhead of 2 function calls.

Gerry Howard

  • Moderator

>Using #defines for numbers is a good idea as soon as they're>used in more than one place. I know a lot of people who always>use #defines for any kind of constant.Fair enough. I do in fact use "named constants" myself whenever the occasion demands... ;)Is there any inherent advantage to using #define rather than a variable declaration, aside from the visual clue that it IS a "constant?"#define myconstant 100vs.int myconstant = 100;

Fr. Bill    

AOPA Member: 07141481 AARP Member: 3209010556


     Avsim Board of Directors | Avsim Forums Moderator
  • Author

In theory there is an advantage to using #define. Where ever you use myconstant in code the pre-processor will substitute it before compling the code. Thus if you code:#define myconstant 100x = a * myconstant;what will be complied is:x = a * 100;This will generally be faster than the original statement, although in most situations you'd be hard pressed to notice it.One common convention is to use capitals for defined constants to make them even more obvious.#define MYCONSTANT 100x = a * MYCONSTANT;

Gerry Howard

"The functions max and min will still have to make the comparisions in the original code and will have the additional overhead of 2 function calls."Wrong. At least for the Microsoft C/C++ compilator, min & max are not real functions but macros ;-)

  • Author

But it's not true for all compiliers.Also macros can introduce problems with side effects. A max macro is typically defined as:#define max(A, :( ((A) > (:() ? (A) : (:()which evaluates both arguments twice.

Gerry Howard

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.