// Common code used by both sending and receiving Moteino sketches in wireless.
// shaft encoder scheme.  Helps ensure that RUN_MODE and radio send structures, 
// which must be identical side-to-side, stay in sync.
//
// Copyright (c) 2019-2020 John David Heinzmann 

// Constants for specifying mode in which program is to run
#define CAL            (0) // run sketch in calibration mode
#define DEV            (1) // debug data included in packets over radio
#define RUN            (2) // only essential data in packets over radio

#define RUN_MODE       (RUN)  // CAL, DEV or RUN 

// Set up structure for radio packet payload.  
// Both sides must have exact same structure to send from and receive into.
#if (RUN_MODE == RUN)
  typedef struct 
  {
    int                 junk; // needed to avoid stalling on radio.send (huh?)
    int           remTime_ms; // [ms], remote side elapsed time
    float              theta; // [rad], shaft angle
    float               batV; // [V], wireless sensor battery voltage
    boolean              TDC; // true when TDC has been reached, otherwise false
  } Payload;
#else // must be CAL or DEV
  typedef struct 
  {
    unsigned int  remTime_ms; // [ms], remote side elapsed time
    float              theta; // [rad], shaft angle
    float                  X; // [g], acceleration in X direction
    float                  Y; // [g], acceleration in Y direction
    float               batV; // [V], wireless sensor battery voltage
    boolean              TDC; // true when TDC has been reached, otherwise false
  } Payload;
#endif

