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.

My gauge coding style recommendation

Featured Replies

Please read my suggestions open-minded and criticize it.I would like to see clearly before jumping into biggergauge programming projects (well, I am in already...)I am a newbie in gauge programing, but I have quite a lotC programming experience. Recently I had to touch a gaugecode and I was shocked about the logic it was designed.Later I learned that - at least partially - it was comingfrom the RECOMMENDED structure of gauge programming.The main problem is the "including-everything-together"method. It has the following disadvantages:- everything is global, you are forced to figure out funny variable and function names to avoid conflicts;- it is rather difficult to manage which gauge can see and use which variables;- difficult to test, what happens if I remove/replace a module;- compilation time is long (everything is compiled)I played a bit around and I created a programming stylethat is very closed to the traditional, but allows youto do structured programming.Traditional structure starts like this:=======================================================MAIN GAUGE PACK FILE (TRADITIONAL)//-----------------------------------------------------#define GAUGE_NAME "COM_Radio"#define GAUGEHDR_VAR_NAME ComHdr#define GAUGE_W 100#include "my_gauge_1.c"//-----------------------------------------------------#define GAUGE_NAME "Gyro"#define GAUGEHDR_VAR_NAME GyroHdr#define GAUGE_W 200#include "my_gauge_2.c"...=======================================================I modified the code structure as follows:- removed includes and defined gauge header vars extern- reorganized module code to allow macros work- used all macros to define static vars/structures- only gauge hdr macro is let to global- defined all callbacks as staticThe additional advantage is that I could use constant names for general components:- bacground (static element name)- pbackground (pointer to above)- rect (mouse rectangle)- callBack (gauge call back function)Here is my suggested structure (please be aware of that- for historical reasons - I had to play with an olderversion FS code, but I hope it does not matter):=======================================================My versionextern GAUGEHDR comhdr; // com radioextern GAUGEHDR gyrohdr; // gyroscope...// The gauge table is the same in both versionsGAUGE_TABLE_BEGIN() GAUGE_TABLE_ENTRY(&ComHdr) GAUGE_TABLE_ENTRY(&GyroHdr)GAUGE_TABLE_END()==============================================================================================================INDIVIDUAL GAUGE FILE FOR COM RADIO#include "gauges_2k2.h" // or newer//--- Mouse function ---------------------------------static BOOL FSAPI mouse_cb_1( ... ){ ...}// name of mouse rectangle can be same in each modulestatic MOUSE_BEGIN( rect, HELP_NONE, 0, 0 ) MOUSE_CHILD_FUNCT( ... )MOUSE_END//--- Element callbacks ------------------------------FLOAT64 FSAPI element_1_cb( ... ){ ...}//--- Gauge Callback Function ------------------------// name of function can be same in each modulestatic void FSAPI callBack ( ... ){ ...}//--- Gauge header -----------------------------------// Only gauge var name and gauge name should be set// Notice: GAUGE_HEADER_FS700 is the only macro not static!#define GAUGEHDR_VAR_NAME ComHdrstatic PELEMENT_HEADER pbackground;GAUGE_HEADER_FS700(153, "COM_Radio", &pbackground, rect, callBack, 0, 0, 0);//--- Gauge elements ---------------------------------#define GAUGE_CHARSET DEFAULT_CHARSET#define GAUGE_FONT_DEFAULT "Courier New"#define GAUGE_WEIGHT_DEFAULT FW_NORMAL... all gauge element macros defined as static ...static MAKE_STATIC( background, // this can be the same in each module BMP_COM_BG, &pswitch, NULL, IMAGE_USE_TRANSPARENCY|IMAGE_USE_ERASE, 0, 0,0)// this can be the same in each modulestatic PELEMENT_HEADER pbackground = &background.header;=======================================================That's all by now, but I have some other ideas as well ;)Gabor

This is why I program in XML :)CheersShad

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.