예제 #1
0
파일: measure.c 프로젝트: ellingjp/ee472
void setBloodPress(CircularBuffer *spbuf, CircularBuffer *dpbuf) {
  // This is written to lab spec, with a flag to indicate "complete".
  // Right now, it does nothing, but I imagine it should probably be a global
  // variable to indicate to the compute task that the pressure measurement 
  // is ready, since this measurement takes a nontrivial amount of time

  static unsigned int i = 0;

  static tBoolean sysComplete = false;    
  static tBoolean diaComplete = false;

  int syspress = *(int *)cbGet(spbuf);

  // Restart systolic measurement if diastolic is complete

  if (syspress > 100)
    sysComplete = true;

  if (! sysComplete) {
    if (i%2==0) syspress+=3;
    else syspress--;
  }

  int diapress = *(int *)cbGet(dpbuf);

  // Restart diastolic measurement if systolic is complete  
  if (diapress < 40)
    diaComplete = true;

  if (!diaComplete) {
    if (i%2==0) diapress-=2;
    else diapress++;
  }

  if (diaComplete && sysComplete) {
    sysComplete = false;
    diaComplete = false;
    syspress = SYS_RAW_INIT;
    diapress = DIA_RAW_INIT;
  }

  cbAdd(spbuf, &syspress);
  cbAdd(dpbuf, &diapress);

  i++;
}
예제 #2
0
파일: gps.c 프로젝트: siwucha/Rob_inz
void UART4_IRQHandler()
{
	if (USART_GetITStatus(UART4, USART_IT_RXNE) != RESET)
	{
		char gps_letter = USART_ReceiveData(UART4);
		if(gps_letter != 0) cbAdd(&GPS_BUFFER, gps_letter);
		send_char(gps_letter);	//potrzebne do debugowania
		send_char('a');
	}
	USART_ClearITPendingBit(UART4, USART_IT_RXNE);
}
예제 #3
0
void
TestBindata::add ()
{
	// usually we should add a Pixmap here
	QFile f("files/testfile.mp3");
	f.open (QIODevice::ReadOnly);
	m_testdata = f.readAll ();
	m_client.bindata.add (m_testdata) (this, SLOT (cbAdd (QString)));
	f.close ();
	waitForAnswer ();
}
예제 #4
0
파일: measure.c 프로젝트: ellingjp/ee472
void setTemp(CircularBuffer *tbuf) {
  int temp = 0;
	//
	// Trigger the sample sequence.
	//
	ADCProcessorTrigger(ADC0_BASE, 1);
	//
	// Wait until the sample sequence has completed.
	//
	while(!ADCIntStatus(ADC0_BASE, 1, false))
	{
	}
	//
	// Read the value from the ADC.
	//
	ADCSequenceDataGet(ADC0_BASE, 1, &temp);

	
  cbAdd(tbuf, &temp);
}
예제 #5
0
파일: measure.c 프로젝트: ellingjp/ee472
void measureRunFunction(void *dataptr) {
  static tBoolean onFirstRun = true;
  static int rate;
  MeasureData *mData = (MeasureData *) dataptr;

  if (onFirstRun) {
    initializeMeasureTask();
    rate = *(int*) cbGet(mData->pulseRateRaw);
    onFirstRun = false;
  }
  
  // capture pulse rate
  if (IS_PULSE_CYCLE) {
    // Divide by two so raw pulse rate matches frequency
    rate = pulseRate/2;
    pulseRate = 0;
  }
  
  // only run on major cycle
  short measureSelect = *(mData->measureSelect);
	if(measureSelect == 0 || measureSelect == 1)
	{
		setTemp(mData->temperatureRaw);
    }
	if(measureSelect == 0 || measureSelect == 2)
	{
		setBloodPress(mData->systolicPressRaw, mData->diastolicPressRaw);
	}
	if(measureSelect == 0 || measureSelect == 3)
	{
      int prev = *(int*) cbGet(mData->pulseRateRaw);
      
      // Only save if +- 15%
      if (rate < prev*0.85 || rate > prev*1.15) {
        cbAdd(mData->pulseRateRaw, (void *)&rate);
      }
	}
	if(measureSelect == 0 || measureSelect == 4)
	{
		vTaskResume(ekgCaptureHandle);
	}
	else
	{
		vTaskSuspend(ekgCaptureHandle);
	}
    vTaskResume(computeHandle);  // run the compute task
     
#if DEBUG_MEASURE
    char num[30];
    int temp = *(int *)cbGet(mData->temperatureRaw);
    int sys = *(int *)cbGet(mData->systolicPressRaw);
    int dia = *(int *)cbGet(mData->diastolicPressRaw);
    int pulse = *(int *)cbGet(mData->pulseRateRaw);
    int batt = global.batteryState;

    usnprintf(num, 30, "<-- MEASURE DEBUG -->");
    RIT128x96x4StringDraw(num, 0, 0, 15);
    
    usnprintf(num, 30, "Raw temp: %d  ", temp);
    RIT128x96x4StringDraw(num, 0, 10, 15);

    usnprintf(num, 30, "Raw Syst: %d  ", sys);
    RIT128x96x4StringDraw(num, 0, 20, 15);

    usnprintf(num, 30, "Raw Dia: %d  ", dia);
    RIT128x96x4StringDraw(num, 0, 30, 15);

    usnprintf(num, 30, "Raw Pulse: %d  ", pulse);
    RIT128x96x4StringDraw(num, 0, 40, 15);
    
    usnprintf(num, 30, "Raw Batt: %d  ", batt);
    RIT128x96x4StringDraw(num, 0, 50, 15);
#endif
}