/**
 * Gets the current temperature of the microbit.
 * @return the current temperature, in degrees celsius.
 *
 * Example:
 * @code
 * uBit.thermometer.getTemperature();
 * @endcode
 */
int MicroBitThermometer::getTemperature()
{
    if (isSampleNeeded())
        updateTemperature();

    return temperature;
}
bool MPU9250_DMP::read(float* acc, float* gyr, float* mag, int16_t* temp, ORIENTATION* ori)
{
	if ( fifoAvailable() && dmpUpdateFifo() == INV_SUCCESS )
	{
		if (acc) {
			acc[0] = calcAccel(ax);
			acc[1] = calcAccel(ay);
			acc[2] = calcAccel(az);
		}
		if (gyr) {
			gyr[0] = calcGyro(gx);
			gyr[1] = calcGyro(gy);
			gyr[2] = calcGyro(gz);
		}
		if (mag) {
			mag[0] = calcMag(mx);
			mag[1] = calcMag(my);
			mag[2] = calcMag(mz);
		}
		if ((_features & DMP_FEATURE_6X_LP_QUAT) && ori) {
			computeEulerAngles();
			ori->pitch = pitch;
			ori->yaw = yaw;
			ori->roll = roll;
		}
		if (temp) {
			updateTemperature();
			*temp = temperature;
		}
		return true;
	}
	return false;
}
void Worker::compute( )
{  
  	osgArt->update();	
     	memcpy (q->bits(),osgArt->grabFrameBuffer().scaled(frame->width(),frame->height()).bits(),frame->width() *frame->height()*4);	
  	miVisor->update();
	updateTemperature();
}
示例#4
0
void ServiceData::handleEvent(uint16_t evt, void* p_data, uint16_t length) {
		switch(evt) {
		case CONFIG_CROWNSTONE_ID: {
			updateCrownstoneId(*(uint16_t*)p_data);
			break;
		}
		case STATE_SWITCH_STATE: {
			updateSwitchState(*(uint8_t*)p_data);
			break;
		}
		case STATE_ACCUMULATED_ENERGY: {
			updateAccumulatedEnergy(*(int32_t*)p_data);
			break;
		}
		case STATE_POWER_USAGE: {
			updatePowerUsage(*(int32_t*)p_data);
			break;
		}
		case STATE_TEMPERATURE: {
			updateTemperature(*(int8_t*)p_data);
			break;
		}
		default:
			return;
		}
		EventDispatcher::getInstance().dispatch(EVT_ADVERTISEMENT_UPDATED);
	}
示例#5
0
	void QMSMFormSystemOverview::slotRefreshGui(void) {
		if(isVisible()){
			updateActiveProcesses();
			updateUtilization();
			updateTemperature();
		}
	}
示例#6
0
void SestoSenso::GetFocusParams()
{
    if (updatePosition())
        IDSetNumber(&FocusAbsPosNP, nullptr);

    if (updateTemperature())
        IDSetNumber(&TemperatureNP, nullptr);
}
void ThermalCalibrationHelper::collectSample(UAVObject *sample)
{
    QMutexLocker lock(&sensorsUpdateLock);

    if (!m_acquiring) {
        return;
    }

    switch (sample->getObjID()) {
    case AccelSensor::OBJID:
        m_accelSamples.append(accelSensor->getData());
        m_debugStream << "ACCEL:: " << m_accelSamples.last().temperature
                      << "\t" << QDateTime::currentDateTime().toString("hh.mm.ss.zzz")
                      << "\t" << m_accelSamples.last().x
                      << "\t" << m_accelSamples.last().y
                      << "\t" << m_accelSamples.last().z << endl;
        break;

    case GyroSensor::OBJID:
        m_gyroSamples.append(gyroSensor->getData());
        m_debugStream << "GYRO:: " << m_gyroSamples.last().temperature
                      << "\t" << QDateTime::currentDateTime().toString("hh.mm.ss.zzz")
                      << "\t" << m_gyroSamples.last().x
                      << "\t" << m_gyroSamples.last().y
                      << "\t" << m_gyroSamples.last().z << endl;
        break;

    case BaroSensor::OBJID:
    {
        float temp = getTemperature();
        BaroSensor::DataFields data = baroSensor->getData();
#ifdef SIMULATE
        data.Temperature = temp;
        data.Pressure   += 10.0f * temp;
#endif
        m_baroSamples.append(data);
        m_debugStream << "BARO:: " << m_baroSamples.last().Temperature
                      << "\t" << QDateTime::currentDateTime().toString("hh.mm.ss.zzz")
                      << "\t" << m_baroSamples.last().Pressure
                      << "\t" << m_baroSamples.last().Altitude << endl;
        // must be done last as this call might end acquisition and close the debug log file
        updateTemperature(temp);
        break;
    }

    case MagSensor::OBJID:
        m_magSamples.append(magSensor->getData());
        m_debugStream << "MAG:: " << "\t" << QDateTime::currentDateTime().toString("hh.mm.ss.zzz")
                      << "\t" << m_magSamples.last().x
                      << "\t" << m_magSamples.last().y
                      << "\t" << m_magSamples.last().z << endl;
        break;

    default:
        qDebug() << "Unexpected object" << sample->getObjID();
    }
}
示例#8
0
void TempSensor::updateSensor()
{
    // The BMP180 sensor doesn't need to be read every time through the loop
    if (updateTempCounter > delayCount)
    {
        updateTemperature();
        updatePressure();
        updateAltitude();
        updateTempCounter = 0;
    }
    else
    {
        updateTempCounter++;
    }
}
示例#9
0
void BMP180::update() {
    // make sure we've calibrated
    if (! calibrate()) return;
    // make sure we have a valid temperature at least once per second
    if ((_sinceLastTemperature > temperatureInterval) &&
            (! _pressureRequested)) {
        updateTemperature();
    }
    // don't update pressure when we're waiting for a temperature request
    if (_temperatureRequested) return;
    // update the pressure at the requested interval
    if ((_sinceLastPressure > pressureInterval) || (_pressureRequested)) {
        updatePressure();
    }
}
示例#10
0
void SestoSenso::TimerHit()
{
    if (!isConnected())
    {
        SetTimer(POLLMS);
        return;
    }

    if (FocusAbsPosNP.s == IPS_BUSY || FocusRelPosNP.s == IPS_BUSY)
    {
        if (isMotionComplete())
        {
            FocusAbsPosNP.s = IPS_OK;
            FocusRelPosNP.s = IPS_OK;
            IDSetNumber(&FocusRelPosNP, nullptr);
            IDSetNumber(&FocusAbsPosNP, nullptr);
            DEBUG(INDI::Logger::DBG_SESSION, "Focuser reached requested position.");
        }
        else
            IDSetNumber(&FocusAbsPosNP, nullptr);

        lastPos = FocusAbsPosN[0].value;
        SetTimer(POLLMS);
        return;
    }

    bool rc = updatePosition();
    if (rc)
    {
        if (lastPos != FocusAbsPosN[0].value)
        {
            IDSetNumber(&FocusAbsPosNP, nullptr);
            lastPos = FocusAbsPosN[0].value;
        }
    }

    rc = updateTemperature();
    if (rc)
    {
        if (fabs(lastTemperature - TemperatureN[0].value) >= 0.1)
        {
            IDSetNumber(&TemperatureNP, nullptr);
            lastTemperature = TemperatureN[0].value;
        }
    }

    SetTimer(POLLMS);
}
示例#11
0
inv_error_t MPU9250_DMP::update(unsigned char sensors)
{
	inv_error_t aErr = INV_SUCCESS;
	inv_error_t gErr = INV_SUCCESS;
	inv_error_t mErr = INV_SUCCESS;
	inv_error_t tErr = INV_SUCCESS;

	if (sensors & UPDATE_ACCEL)
		aErr = updateAccel();
	if (sensors & UPDATE_GYRO)
		gErr = updateGyro();
	if (sensors & UPDATE_COMPASS)
		mErr = updateCompass();
	if (sensors & UPDATE_TEMP)
		tErr = updateTemperature();

	return aErr | gErr | mErr | tErr;
}
示例#12
0
void Particle::update(float _dt)
{

//Stop updating and rendering particle when reaches outside bounding box

  if (m_position.m_x<m_xMin || m_position.m_x>m_xMax || m_position.m_y<m_yMin || m_position.m_y>m_yMax || m_position.m_z<m_zMin || m_position.m_z>m_zMax)
  {
    m_active=false;

  }
  else
  {

    //Update position and temperature, and burn particle
    updatePosition(_dt);
    updateTemperature(_dt);
    burnParticle(_dt);
  }

}
示例#13
0
/**
  * periodic callback.
  * Check once every second or so for a new temperature reading.
  */  
void MicroBitThermometer::idleTick()
{   
    if (isSampleNeeded())
        updateTemperature();
}
示例#14
0
void SerialConsole::readMessage()
{
    if (!rs232->isOpen())
        return;
    const double old_extruder_temperature = extruder_temperature;
    const double old_bed_temperature = bed_temperature;

    static const QRegExp sep("[\\s,]");

    while(rs232->canReadLine())
    {
        const QByteArray &msg = rs232->readLine().trimmed();
        if (msg.isEmpty())
            continue;
        history->append("-> " + msg);

        const QList<QString> &args = QString(msg).split(sep, QString::SkipEmptyParts);

        for(int i = 0 ; i < args.size() ; ++i)
        {
            const QString &arg = args[i];
            if (arg == "ok")
            {
                ack_timer->stop();
                ack_expected_before_sending_a_command--;
                if (!command_queue.isEmpty() && ack_expected_before_sending_a_command == 0)
                {
                    const QByteArray msg = command_queue.front();
                    command_queue.pop_front();
                    if (nb_processed_commands == 0)
                        start_time.start();
                    ++nb_processed_commands;
                    sendMessage(msg);
                }
                else if (command_queue.isEmpty())
                {
                    nb_processed_commands = 0;
                    emit updateWorkProgress(100);
                    emit updateETA(0.0);
                }
            }
            else if (arg.startsWith("X:"))
            {
                emit updateCoordinateX(arg.right(arg.size() - 2).toDouble());
            }
            else if (arg.startsWith("Y:"))
            {
                emit updateCoordinateY(arg.right(arg.size() - 2).toDouble());
            }
            else if (arg.startsWith("Z:"))
            {
                emit updateCoordinateZ(arg.right(arg.size() - 2).toDouble());
            }
            else if (arg == "rs" && i + 1 < args.size())
            {
                const QString &arg1 = args[i + 1];
                if (arg1.startsWith('N'))
                {
                    ++i;
                    const int line_number = arg1.right(arg1.size() - 1).toInt();
                    if (line_number >= 0 && line_number < command_history.size())
                    {
                        history->append("<- " + command_history[line_number].trimmed());
                        rs232->write(command_history[line_number]);
                        if (ack_timer->isActive())
                        {
                            ack_timer->stop();
                            ack_timer->start();
                        }
                    }
                    else
                    {
                        history->append("<- ");
                        rs232->write("\n");
                    }
                    if (ack_timer->isActive())
                    {
                        ack_timer->stop();
                        ack_timer->start();
                    }
                }
            }
            else if (arg.startsWith("T:"))
            {
                extruder_temperature = arg.right(arg.size() - 2).toDouble();
            }
            else if (arg.startsWith("B:"))
            {
                bed_temperature = arg.right(arg.size() - 2).toDouble();
            }
        }
    }
    if (extruder_temperature != old_extruder_temperature
            || bed_temperature != old_bed_temperature)
        emit updateTemperature(extruder_temperature, bed_temperature);
}
void CookingPanel::show(){
  /*
  _myGLCD->clrScr();
  _myButtons->deleteAllButtons();  
  setHeadText(_headText);
  setSubheadText(_subheadText);
 */
 
   long startTimeStamp = millis();
   long updateTimeStamp = startTimeStamp;
   
   int totalTime=0;

  _sizeX=_myGLCD->getDisplayXSize();
  _sizeY=_myGLCD->getDisplayYSize();
   
   clearScreen();
   
   
   isActive=true;
   
 int startY=25;

  _myGLCD->print("Set temperature: "+formatTemperature(_settings->temperature), 10, startY);
  _myGLCD->print("Actual temperature:", 10, startY+12);  
  _myGLCD->print("Total time: 1H:13m", 10, startY+12*2);
  _myGLCD->print("Finish time: 0H:90m", 10, startY+12*3);
  
  
  butTop = _myButtons->addButton(_sizeX-_buttonHeight-3, 2, _buttonHeight,  _buttonHeight, "X");
 
  
  _myButtons->drawButtons();
  
  
  updateTemperature();
  
  //drawGraphFrame();
  
  myGraph.setHeight(160);
  myGraph.drawFrame(tempC);
  
  while(isActive){
    
    if (_myTouch->dataAvailable() == true){
      
      int pressed_button = _myButtons->checkButtons();
      
      if(pressed_button==butTop){
        isActive=false;
        _eventCallbackFunction(0);
      }
      
      
      
    }
    
    
    
    
    if (millis()-updateTimeStamp > 1000){
      
      totalTime++;
      int secs=(millis()-startTimeStamp)/1000;
      secs=secs%60;
      int mins=((millis()-startTimeStamp)/60000)%60;
      //mins=mins%60;
      int hours=(millis()-startTimeStamp)/(60*60000);
      setHeadText("Cooking " + String(hours, DEC) + ":"+ String(mins, DEC) + ":"+ String(secs, DEC)+ " ");
      
     
      updateTimeStamp = millis();
    }
    
    if (totalTime%5==0){
       updateTemperature();
    }
        
    
    
    
    
  }
  
  
  
  //_eventCallbackFunction(0);
  
}
示例#16
0
文件: main.c 项目: altanis/AVR
/**
 * Main program loop
 */
int main(void)
{        
	DDRD = 0xff;
	PORTD = 0xf0;	
	PORTD |= _BV(3);
	
	UART_init(16000000, 19200);			
	LCD_init();
	PCF8583_init();
		
	PCF8583_set_time(12,00,0,0);
	PCF8583_set_date(24,1,2013);
	
	//set the alarm off
	PCF8583_get_status();
	PCF8583_status|=4;
	PCF8583_write(0,PCF8583_status);
	
	cbi(PORTD, 6);
	
	u16 code;
	
	LCD_clear();
	
	get_temperatureSilent();
	power_on();	
	while(1)
	{		
		if(m_requiresSettings == SETTING_ALL)
		{
			updateTime();
			updateTemperature();
			dayNightDecision();	
		}
		
		
			power_on();	
			
			code = decode_rc5();
			if ( code != 0 )
			{
				remote_switch(code);
				while ( UART_unread_data() ) UART_getc();
			}			
		
		//if uart recieved something
		if ( (PC_get_msg() == PC_CONNECT) & bit_is_clear(PORTD, 6) )
		{
			PC_connecting_show();
			do
			{		
				show_PC_menu();		
				code = PC_get_msg();				
				PC_switch( code );				
			}
			while( code != PC_DISCONNECT );
			PC_disconnecting_show();
		}		
	}	
	return 0;
}
示例#17
0
void loop()
{
	// If error detected, disable buttons.
	if (fsmState != ERROR_MODE)
	{
		buttonA.tick();
		buttonB.tick();
	}

	// If alarm condition is detected, modify FSM state accordingly
	// Alarm is just triggered outside the edit modes.
	if (wkAlarm.isTriggered(now()) && fsmState != EDIT_ALARM_MODE 
		&& fsmState != EDIT_TIME_MODE && fsmState != SHOW_ALARM_MODE)
	{
		oldFsmState = fsmState;
		// update the time, so the display is not stuck in garbage.
		updateTime();
		display.enableClockDisplay();
		fsmState = SHOW_ALARM_MODE;

		digitalClockDisplay();
		printAlarmStatus();
	}

	// After an alarm is cleared by the user, wait for a minute
	// and re-enable the alarm to provide for repeatable alarms
	// everyday without user intervention.
	if ((millis() - lastAlarmTrigger) > ONE_MINUTE && lastAlarmTrigger)
	{
		enableRtcAlarm();
		lastAlarmTrigger = 0;
	}


	switch (fsmState)
	{
		case EDIT_TIME_MODE:

			if (oldFsmState != fsmState)
			{
				display.enableNumericDisplay();
				display.writeMessage("hora");
				delay(600);
				updateTime();
				display.enableClockDisplay();
				activeDigit = 0;
				display.enableBlink(activeDigit);
			}

			oldFsmState = fsmState;
			break;

		case EDIT_ALARM_MODE:
			
			if (oldFsmState != fsmState)
			{
				display.enableNumericDisplay();
				display.writeMessage("alarme");
				delay(600);
				updateAlarm();
				display.enableClockDisplay();

				if (isRtcAlarmOn())
				{
					for (int i = 0; i < N; i++)
						display.enableDecimalPoint(i);
				} else {
					for (int i = 0; i < N; i++)
						display.disableDecimalPoint(i);
				}

				activeDigit = 0;
				display.enableBlink(activeDigit);
			}

			oldFsmState = fsmState;
			break;

		case SHOW_TIME_MODE:

			if (oldFsmState != fsmState)
			{
				updateTime();
				lastClockRead = millis();
				lastShowTimeStart = lastClockRead;
				display.enableClockDisplay();
			}

			oldFsmState = fsmState;

			if ((millis() - lastClockRead) > updateInterval)
			{
				updateTime();
				lastClockRead = millis();
			}

			if ((millis() - lastShowTimeStart) > SHOW_TIME_DURATION)
			{
				fsmState = SHOW_TEMP_MODE;
			}

			break;

		case SHOW_TEMP_MODE:
			
			if (oldFsmState != fsmState)
			{
				updateTemperature();
				lastTempRead = millis();
				lastShowTempStart = lastTempRead;
				display.enableTempDisplay();
			}

			oldFsmState = fsmState;

			if ((millis() - lastTempRead) > updateInterval)
			{
				updateTemperature();
				lastTempRead = millis();
			}

			if ((millis() - lastShowTempStart) > SHOW_TEMP_DURATION)
			{
				fsmState = SHOW_TIME_MODE;
			}

			break;

		case SHOW_ALARM_MODE:
			display.disableDisplay();
			display.disableColon();
			playAlarmSong();
			display.enableColon();
			display.enableDisplay();
			break;

		case ERROR_MODE:
			if (oldFsmState != fsmState)
			{	
				display.enableNumericDisplay();
				display.writeMessage("ERRO");
				Serial.println("Error detected, disabling buttons.");
				Serial.println("Error detected, disabling RTC alarm.");
				disableRtcAlarm();
			}
			break;
	}
}