Ejemplo n.º 1
0
	void SensorDashboard::refreshData()
	{
		uint from = mPeriodFrom->dateTime().toTime_t();
		uint to = mPeriodTo->dateTime().toTime_t();

		emit getSensorData(from, to);
	}
Ejemplo n.º 2
0
String SensorDht22::get(void) {
    getSensorData();
    String message = "";
    message += "\"" + humidity_instruction_ + "\":{" + id_ + "," + humidity_ + "},";
    message += temperature_instruction_ + "\":{" + id_ + "," + temperature_ + "},";
    return message;
}
Ejemplo n.º 3
0
void LineSensor::update () {
    int* temp;

    temp = getSensorData();
    for (int i = 0; i < sensors; ++i) {
        current[i] = temp[i];
    }  

    delete[] temp;
    
}
Ejemplo n.º 4
0
void loop() {
	getSensorData();
	screenPrinting();

	if(networkManager.isConnected())
	{
		unsigned long currentMillis = millis();
		if(currentMillis > prievous + updateFeedInterval) {
			networkManager.updateFeed(temperature, 0, pressure, lightLevel);

			prievous = currentMillis;
		}
	}

	delay(500);
}
Ejemplo n.º 5
0
String SensorDs18b20::get(void) {
    // Get PH, Temperature, & EC Data
    getSensorData();

    // Initialize Message
    String message = "";

    // Append Temperature
    message += "\"";
    message += temperature_instruction_code_;
    message += " ";
    message += temperature_id_;
    message += "\":";
    message += String(temperature_filtered,1);
    message += ",";

    // Return Message
    return message;
}
Ejemplo n.º 6
0
/**
 * This function updates the arrays current and lastSeen. 
 * lastSeen will only be overwritten if current has at least one true.
 * 
 * @author Blake Lasky
 * 
 * @param current current line data array
 * @param lastSeen reading data from last time we got at least one true reading
 * @param pinSpots pins corresponding to the previous two data arrays
 * @param arraySize size of the previous three arrays
 */
void LineSensor::update () {
    int* temp;

    temp = getSensorData();

    if ( hasOneTrue() ) {      
        // shifts data from current to lastSeen and from temp to current
        for (int i = 0; i < sensors; ++i) {
            lastSeen[i] = current[i];
            current[i] = temp[i];
        }      
    } else {      
        //overwrites current with temp; does not affect lastSeen
        for (int i = 0; i < sensors; ++i) {
            current[i] = temp[i];
        }      
    }

    delete[] temp;
    
}
String SensorGc0011::get(void) {
  // Get Sensor Data
  getSensorData();

  // Initialize Message
  String message = "";
  
  // Append CO2 Data to Message
  message += "\"";
  message += co2_instruction_code_;
  message += " ";
  message += co2_instruction_id_;
  message += "\":";
  message += String(co2,0);
  message += ",";

  // Append Temperature Data to Message
  message += "\"";
  message += temperature_instruction_code_;
  message += " ";
  message += temperature_instruction_id_;
  message += "\":";
  message += String(temperature, 1);
  message += ",";

  // Append Humidity Data to Message
  message += "\"";
  message += humidity_instruction_code_;
  message += " ";
  message += humidity_instruction_id_;
  message += "\":";
  message += String(humidity, 1);
  message += ",";
  
  return message;
}
Ejemplo n.º 8
0
void GUIServer::run() {
	if (receiveCommand()) {
		m_UdpServer.beginPacket(m_UdpServer.remoteIP(),
				m_UdpServer.remotePort());
		m_UdpServer.write(m_Buffer[1]);
		m_UdpServer.write(m_Buffer[0]);

		Serial.print(F("Request ID: "));
		Serial.println(m_Buffer[0]);
		Serial.print(F("Method ID: "));
		Serial.println(m_Buffer[1]);
		Serial.print(F("value: "));
		Serial.println(m_Buffer[2]);
		switch (m_Buffer[1]) {
		case GETVERSION:
			m_UdpServer.write((uint8_t) 0);
			m_UdpServer.write(1);
			break;
		case GETALLSENSORS:
			getAllSensors();
			break;
		case GETSENSORDATA:
			getSensorData(m_Buffer[2]);
			break;
		case SETSENSORCONFIG:
			switch (m_Buffer[3]) {
			case 1:
				break;
			case 2:
				setSensorConfig(m_Buffer[2], m_Buffer[3], (char*) &m_Buffer[4]);
				break;
			case 3:
				setSensorConfig(m_Buffer[2], m_Buffer[3], (char*) &m_Buffer[4]);
				break;
			case 4:
				setSensorConfig(m_Buffer[2], m_Buffer[3],
						(uint8_t) m_Buffer[4]);
				break;
			case 5:
				setSensorConfig(m_Buffer[2], m_Buffer[3],
						(uint8_t) m_Buffer[4]);
				break;
			}
			break;
		case GETALLACTUATORS:
			getAllActuators();
			break;
		case GETACTUATORDATA:
			getActuatorData(m_Buffer[2]);
			break;
		case SETACTUATORDATA:
			switch (m_Buffer[3]) {
			case 1:
			case 3:
			case 4:
			case 5:
			case 6:
				setActuatorData(m_Buffer[2], m_Buffer[3],
						(uint8_t) m_Buffer[4]);
				break;
			case 2:
				setActuatorData(m_Buffer[2], m_Buffer[3], (char*) m_Buffer[4]);
			}
			break;
		case SETACTUATORCONFIG:
			switch (m_Buffer[3]) {
			case 1:
				break;
			case 2:
				setActuatorConfig(m_Buffer[2], m_Buffer[3],
						(char*) &m_Buffer[4]);
				break;
			case 3:
				break;
			case 4:
				break;
			case 5:
				break;
			}
			break;
		case GETCLOCKTIMERS:
			getClockTimers(m_Buffer[2]);
			break;
		default:
			break;
		}
		m_UdpServer.endPacket();
	}

}
Ejemplo n.º 9
0
/*
 * Main Task
 */
void MainTask(void* pdata) {
//	int frameDone = 0; // RC required
	printf("Starting Main task...\n");

	int16_t avgSensorData[9] = { 0 }; //Order: ACC- GYR - COMP
	uint32_t averagedDataDeltaT = 0;
	float filteredSensorData[9] = { 0 }; //Order: ACC- GYR - COMP

	int16_t rcValues[8];

	INT8U os_err = OS_ERR_NONE;
	uint8_t data_err = NO_ERR;

	struct logData* loggData = malloc(sizeof(struct logData));

	while (1) {
		//Semaphore for periodic task
		OSSemPend(mainTaskSem, 0, &os_err);


		//Sensor Test
		if (SDM_NEW_DATA_AVAILABLE == 1) {
			os_err = getSensorData(avgSensorData, &averagedDataDeltaT);
			data_err = filterSensorData(avgSensorData, filteredSensorData, averagedDataDeltaT); //only filter new data
		}

		if (RC_RECEIVER_NEW_DATA_AVAILABLE == 1 ){
			getRCvalues(rcValues); //new rc commands will be copied in local array
			printf("THROTTLE: %d\tROLL: %d\tYAW: %d\tPITCH: %d\n", rcValues[RC_THROTTLE_INDEX], rcValues[RC_ROLL_INDEX], rcValues[RC_YAW_INDEX], rcValues[RC_PITCH_INDEX]);
		}

		//assuming X axis from Filter is PITCH
		float pidPITCHMidVal = PIDPitchCalculation(rcValues[RC_PITCH_INDEX], (float) filteredSensorData[EULER_PITCH_INDEX]);

		//assuming X axis from Filter is ROLL
		float pidROLLMidVal = PIDRollCalculation(rcValues[RC_ROLL_INDEX], (float) filteredSensorData[EULER_ROLL_INDEX]);

		//assuming X axis from Filter is YAW
		float pidYAWMidVal = PIDYawCalculation(rcValues[RC_YAW_INDEX], (float) filteredSensorData[EULER_YAW_INDEX]);

//			printf("PITCH: %f\tROLL: %f\tYAW: %f\n", pidPITCHMidVal, pidROLLMidVal, pidYAWMidVal); //debug print

		mapToMotors(rcValues[RC_THROTTLE_INDEX], pidROLLMidVal, pidPITCHMidVal, pidYAWMidVal);



		//TODO Copy new Data to Struct for logging
//		int i;
//		for (i = 0; i < 9; ++i) { //copy logging data to txStruct
//			loggData->raw[i] = avgSensorData[i];
//			loggData->filter[i] = filteredSensorData[i];
//		}
//
//		loggData->pid[0] = pidPITCHMidVal;
//		loggData->pid[1] = pidROLLMidVal;
//		loggData->pid[2] = pidYAWMidVal;
//
//		int j;
//		for (j = 0; j < 8; ++j) {
//			loggData->rawRadio[i] = rcValues[i];
//		}
//		OSQPost(loggerQsem, (void*) loggData);
	}
}