Example #1
0
bool AlarmView::showAlarms(QOccurrenceModel* model, const QDateTime& startTime, int /*warnDelay*/)
{
    mModel = model;
    mStartTime = startTime;

    connect(model,SIGNAL(modelReset()),this,SLOT(updateAlarms()));

    return updateAlarms();
}
Example #2
0
bool AlarmView::showAlarms(QOccurrenceModel* model, const QDateTime& startTime, int warnDelay)
{
    mStartTime = startTime;
    mDelay = warnDelay;

    if (mModel != model) {
        if (mModel)
            disconnect(model,SIGNAL(modelReset()),this,SLOT(updateAlarms()));
        mModel = model;
        connect(model,SIGNAL(modelReset()),this,SLOT(updateAlarms()));
    }

    return updateAlarms();
}
Example #3
0
static void updateSensorsAndScreen() {
#ifndef GPS_ENABLED
  PORTD |= LED;
#else //GPS_ENABLED
  if (gGpsLastData.fix != 0) {
		PORTD |= LED;
	}
	else {
		PORTD ^= LED;
	}
	
#ifdef DEBUG
  //testCalcHome();
#endif // DEBUG
  
	if (gHomePosSet) {
	  calcHome(gGpsLastValidData.pos.latitude,
	           gGpsLastValidData.pos.longitude,
			       gHomePos.latitude,
				     gHomePos.longitude,
					   &gHomeDistance,
					   &gHomeBearing);
#ifdef STATISTICS_ENABLED
		if (gHomeDistance > gStatMaxDistance) {
      gStatMaxDistance = gHomeDistance;
    }
#endif //STATISTICS_ENABLED
	}
#endif //GPS_ENABLED
  
#ifdef ADC_ENABLED 
  measureAnalog();
#endif //ADCENABLED

#ifdef SENSORS_ENABLED
  updateSensors();
#endif

#ifdef ALARM_ENABLED
  updateAlarms();
#endif // ALARM_ENABLED

#ifdef GPS_ENABLED
  if (gGpsLastValidData.speed < STATISTICS_MIN_SPEED_SHOW) {
    if (gStatisticsShowCount < STATISTICS_DELAY_SHOW) {
      gStatisticsShowCount += 1;
    }			  
  }
  if (gStatisticsShowCount == STATISTICS_DELAY_SHOW) {
    gStatisticsShow = 1;
  }
#endif //GPS_ENABLED
}  
Example #4
0
void CWindowAlarm::showEvent ( QShowEvent * event )
{
	updateAlarms();
}
Example #5
0
void calculator_task(void* vptr) {


    CalculationState calcState;
    uint16_t tankChange_ml = 0;
    uint16_t adc = 0;
    OS_ERR err;


    calculator_lcd_init();
    adc_init();
    timer_init();

    // init values
    calcState.depth_mm = 0;
    calcState.rate_mm_per_m = 0;
    calcState.air_ml = 50 * 1000;  // init air in ml
    calcState.elapsed_time_s = 0;
    calcState.current_alarms = ALARM_NONE;
    calcState.display_units = CALC_UNITS_METRIC;

    for (;;)
    {
        while (1)
        {
            // determine  DisplayUnits - check if SW2 has been toggled
            OSSemPend(&g_sw2_sem, 0, OS_OPT_PEND_NON_BLOCKING, 0, &err);
            // Check for change
            if (OS_ERR_NONE == err)
            {
                calcState.display_units = (calcState.display_units == CALC_UNITS_METRIC ? CALC_UNITS_IMPERIAL : CALC_UNITS_METRIC);
            } else if (OS_ERR_PEND_WOULD_BLOCK == err)
            {
                // no update
                break;
            } else
            {
                assert(0); // error state
            }
        }

        adc = adc_read();


        /* RATE and DEPTH */
        // calculate ASCENT RATE  int32_t rate_mm_per_m;
        int32_t descent_rate = ADC2RATE(adc);

        if(calcState.depth_mm > 0 || (calcState.depth_mm == 0 && descent_rate > 0)) {
            calcState.rate_mm_per_m = 1000 * descent_rate;
        } else {
            calcState.rate_mm_per_m = 0;
        }

        // calculate DEPTH  int32_t depth_mm;
        calcState.depth_mm += depth_change_in_mm(calcState.rate_mm_per_m / 1000);

        // no flying divers
        if(calcState.depth_mm < 0) {
            calcState.depth_mm = 0;
        }


        /* UPDATE AIR */

        // check SW2 air changes
        if(calcState.depth_mm == 0) {
            tankChange_ml =   getTankChange_ml();
            calcState.air_ml = (calcState.air_ml + tankChange_ml > 2000000) ? 2000000 : calcState.air_ml + tankChange_ml;
        } else {
            // calculate  uint32_t air_ml;
            uint32_t gas_rate = gas_rate_in_cl(calcState.depth_mm) * 10; // cl -> ml
            if(gas_rate < calcState.air_ml) {
                calcState.air_ml -= gas_rate;
            } else {
                calcState.air_ml = 0;
            }
        }

        /* UPDATE TIMER */

        // apply the timer logic
        timer_update(&calcState);

        // get value from timer
        calcState.elapsed_time_s = get_dive_time_in_seconds();

        // alarms
        updateAlarms(&calcState);
        postAlarms(&calcState);

        /* DISPLAY STATE */

        // determine alarm state  enum CurrentAlarm current_alarm;
        calculator_lcd_update(&calcState);

        // sleep 500 ms
        OSTimeDlyHMSM(0, 0, 0, 500, OS_OPT_TIME_HMSM_STRICT, &err);
    }
}