

/*
 * Include Files
 *
 */
#if defined(MATLAB_MEX_FILE)
#include "tmwtypes.h"
#include "simstruc_types.h"
#else
#include "rtwtypes.h"
#endif

/* %%%-SFUNWIZ_wrapper_includes_Changes_BEGIN --- EDIT HERE TO _END */
#ifndef MATLAB_MEX_FILE
#include <math.h>
#include <Arduino.h>
#include "MyoBridge.h"
#iclude "MyoBridge.cpp"
#include "SoftwareSerial.cpp"
#include "SoftwareSerial.h"

#define ARDUINO 100;

	
	//SoftwareSerial connection to MyoBridge
	SoftwareSerial bridgeSerial(2,3);
	  bridgeSerial.begin(115200);
     bridge.begin();
     
      //set the function that handles EMG data
  	bridge.setEMGDataCallBack(handleEMGData);
 	 //tell the Myo we want the filtered EMG data
  	bridge.setEMGMode(EMG_MODE_SEND);
  	//disable sleep mode, so we get continous data even when not synced 
  	bridge.disableSleep();    

#endif
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
#define y_width 8
/*
 * Create external references here.  
 *
 */
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
/* extern double func(double a); */
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */

/*
 * Output functions
 *
 */
void readEMG_Outputs_wrapper(uint8_T *y0)
{
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
/* This sample sets the output equal to the input
      y0[0] = u0[0]; 
 For complex signals use: y0[0].re = u0[0].re; 
      y0[0].im = u0[0].im;
      y1[0].re = u1[0].re;
      y1[0].im = u1[0].im;
*/
#ifndef MATLAB_MEX_FILE

        
  void handleEMGData(int8_t data[8]) {
      int i = 0;
      for(i = 0; i<8; i++){
          y0[i] = data[i];
    }
  }
  //update the connection to MyoBridge
  bridge.update();

#endif
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
}
