element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Experimenting with Gesture Sensors
  • Challenges & Projects
  • Design Challenges
  • Experimenting with Gesture Sensors
  • More
  • Cancel
Experimenting with Gesture Sensors
Forum Does the runGesture function inside gesture.c make sense to you?
  • Challenge Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Experimenting with Gesture Sensors to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 3 replies
  • Subscribers 42 subscribers
  • Views 860 views
  • Users 0 members are here
Related

Does the runGesture function inside gesture.c make sense to you?

BigG
BigG over 2 years ago

I am reviewing the Firmware Framework code to see where I need to make changes for my own application and I came across this code inside gesture.c which does not make sense to me...

void runGesture(int pixels[], GestureResult *gesResult)
{
  // Initialize result structure
  memset(gesResult, 0, sizeof(GestureResult));
  gesResult->state = STATE_INACTIVE;
  gesResult->gesture = GEST_NONE;

  // Noise filter
  if (gestCfg.enable_window_filter) {
    noiseWindow3Filter(pixels, gestCfg.window_filter_alpha, reset_flag);
  }

  // Process pixels for dynamic gesture
  if (1) {
    DynamicGestureResult dynamicResult;
    runDynamicGesture(&gestCfg, pixels, &dynamicResult);
    gesResult->state = dynamicResult.state;
    gesResult->n_sample = dynamicResult.n_sample;
    gesResult->maxpixel = dynamicResult.maxpixel;
    gesResult->x = dynamicResult.x;
    gesResult->y = dynamicResult.y;
  }
  // Process pixels for tracking
  if (0) {
    TrackingResult trackResult;
    runTracking(&gestCfg.trackingConfig, pixels, &trackResult);
    gesResult->state = trackResult.state;
    gesResult->maxpixel = trackResult.maxpixel; // Will override dynamic result if any
    gesResult->x = trackResult.x; // Will override dynamic result if any
    gesResult->y = trackResult.y; // Will override dynamic result if any
  }
}

How do these conditions get met...

// Process pixels for dynamic gesture
if (1) { ..... }

// Process pixels for tracking
if (0) { ..... }

Now wondering what it should read... any idea?

  • Sign in to reply
  • Cancel

Top Replies

  • misaz
    misaz over 2 years ago +4 verified
    It make sense. I call it macro-less #ifdef. I was also currios about it but later I realized that it is most probably code representation of following mode selector from EVKIT GUI: If you want to…
  • BigG
    BigG over 2 years ago in reply to misaz +1
    Brilliant. Now it makes sense. Thanks for the explanation.
  • rsjawale24
    rsjawale24 over 2 years ago in reply to misaz +1
    Good observation! I didn't notice that the stock firmware and Firmware framework are different!
  • misaz
    +1 misaz over 2 years ago

    It make sense. I call it macro-less #ifdef. I was also currios about it but later I realized that it is most probably code representation of following mode selector from EVKIT GUI:

    image

    If you want to run gesture detecting algorithm than set 1 in first if, if you want to just track movements, then set 1 in second if. Most probably you can safely set 1 to both ifs and then you will be running both algorithms at once. Setting both ifs to zero does not make sense.

    Also note that this code style indicate that firmware compiled from Firmware Framework is not the same as stock firmware because stock firmware can change this in runtime.

    • Cancel
    • Vote Up +4 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
  • BigG
    0 BigG over 2 years ago in reply to misaz

    Brilliant. Now it makes sense. Thanks for the explanation.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • rsjawale24
    0 rsjawale24 over 2 years ago in reply to misaz

    Good observation! I didn't notice that the stock firmware and Firmware framework are different!

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube