Esempio n. 1
0
int main(void) {
  DDRB = (1 << RelayPin);  
  while(1) {
    
    currentTemp = getTemp();
    
    if(currentTemp < OnTemp && !isHeating) {
      _delay_ms(SwitchingDelay);
      currentTemp = getTemp();
      if(currentTemp < OnTemp) {
        enableHeater();
      }
    }

    if(currentTemp > OnTemp && isHeating) {
      _delay_ms(SwitchingDelay);
      currentTemp = getTemp();
      if(currentTemp > OnTemp) {
        disableHeater();
      }
    }

    //_delay_ms(100);
  }
}
Esempio n. 2
0
int main (void)
{
    float temp;
    float hum;
    char *buffer = malloc(BUFFER_SIZE);
    char *data = malloc(DATA_SIZE);
    FILE *temp_fp;
    FILE *hum_fp;

    if (wiringPiSetup () == -1)
        return 1;
    while(1) {
        getData(buffer, data);
        temp = getTemp(data);
        hum = getHum(data);

        temp_fp = fopen("/baby/temperature", "w+");
        hum_fp = fopen("/baby/humidity", "w+");
        fprintf(temp_fp, "%.1f\n", temp);
        fprintf(hum_fp, "%.1f\n", hum);
        fclose(temp_fp);
        fclose(hum_fp);       
        printf("Temperature: %.1foC (%.1foF)\nRelative Humidity: %.1f%%\n", temp, temp * 1.8 + 32, hum);
        delay(2000);
    }

    free(buffer);
    free(data);

    return 0;
}
Esempio n. 3
0
void adc_showTemp()
{
	t_print("Temp is ");
	t_print(getTemp());
	t_putc(248);
	t_print("C\n");
}
Esempio n. 4
0
IOReturn IOI2CMaxim1631::callPlatformFunction(const OSSymbol *functionName,
				bool waitForFunction, void *param1, void *param2,
				void *param3, void *param4)
{
	UInt32 maximReg = (UInt32)param1;
	SInt32 *temp_buf = (SInt32 *)param2;

	DLOG("IOI2CMaxim1631::callPlatformFunction(%x) %s %s %08lx %08lx %08lx %08lx\n",
			fI2CAddress, functionName->getCStringNoCopy(), waitForFunction ? "TRUE" : "FALSE",
			(UInt32) param1, (UInt32) param2, (UInt32) param3, (UInt32) param4);

	if (functionName->isEqualTo(fGetSensorValueSym) == true)
	{
		if (isI2COffline() == true)
			return( kIOReturnOffline );

		if (temp_buf == NULL)
			return( kIOReturnBadArgument );

		return(getTemp( maximReg, temp_buf ));
	}

	return(super::callPlatformFunction(functionName, waitForFunction,
				param1, param2, param3, param4));
}
Esempio n. 5
0
void printVreal(uint8_t port) {
	static int x = 0;
	char buf[33];
	itoa(x, buf, 10);
	double reCalc = 0.0;
	switch (portModeMeasure[port]) {
	case Vol :
		reCalc = measurement;
		dtostrf(reCalc ,7,3, voltageValueBuffer);
		break;
	case Light :
		reCalc = getLightIntensity();
		dtostrf(reCalc ,7,1, voltageValueBuffer);
		break;
	case Temp :
		reCalc = getTemp();
		dtostrf(reCalc ,7,1, voltageValueBuffer);
		break;
	case Noise :
		reCalc = getNoise();
		dtostrf(reCalc ,7,1, voltageValueBuffer);
		break;
	case Distance :
		reCalc = getDistance();
		dtostrf(reCalc ,7,1, voltageValueBuffer);
		break;
	}
	uart_puts(buf);
	uart_putc('\t');
	uart_puts(voltageValueBuffer+1);
	uart_putc('\n');
	x++;
}
void loop() {
  getTemp();
  if (oldtemp != temp) { //if value has changed reset LEDs
   //print temp value to 7 seg.s
   updateSevseg(temp);
  }
}
Esempio n. 7
0
int main(void) {
    srand (time(NULL));
    cloudplugs_global_init();
    printf("****CLOUDPLUGS EXAMPLE****\n");
    cp_session cps = cloudplugs_create_session();

    /**< By default the library uses a plain text connection to CloudPlugs,
         uncomment the following to change the behavior and to use a SSL secure connection */
    //cloudplugs_enable_ssl(cps, CP_TRUE);

    char* res = NULL;
    size_t res_len;
    cp_res cp_res;

    cloudplugs_set_auth(cps, AUTH_PLUGID, AUTH_PASS, AUTH_MASTER);

    const char* channel = "temperature";

    char buffer [15];
    sprintf (buffer, "{\"data\":%d}", getTemp());

    cp_res = cloudplugs_publish_data(cps, channel, buffer, &res, &res_len);
    if(cp_res)
        printf("PUBLISH: [ERROR-> %s] [HTTP_RES %d] %s\n", cloudplugs_get_last_err_string(cps), cloudplugs_get_last_http_result(cps), res);
    else
        printf("PUBLISH: %s\n", res);

    if(res) free(res);

    cloudplugs_destroy_session(cps);

    fflush(stdout);
    cloudplugs_global_shutdown();
    return 0;
}
Esempio n. 8
0
//gets celsius value from sensor and returns fahrenheit value
float TMP36::getFah()
{
    int cTemp = getTemp();
    
    float fah = (cTemp*1.8)+32;
    
    return fah;
}
bool CPlanetTextureGenerator::isWater(const unsigned int x, const unsigned int y, const CHeightMap* heightMap) const
{
	const float	waterLevel = heightMap->getBorderValue(currPlanetParams->liquidPart);
	const float	terrHeight = heightMap->get(x, y) - waterLevel;

	float temp = getTemp(x, y, heightMap);
	return	terrHeight < 0.0f && (temp > 0.0f || temp < -200.0f);
}
Esempio n. 10
0
void decode(char *data, int length, int noisy){
    //int i;
    //for(i=0; i<length; i++){
    //    fprintf(stderr,"%0.2X ",data[i]);
    //}
    //fprintf(stderr,"\n"); */
    time_t seconds = time (NULL);
    //There are two varieties of data, both of them have wind speed
    // first variety of the data
    if ((data[2] & 0x0f) == 1){ // this has wind speed, direction and rainfall
        if(noisy)
            fprintf(stderr,"Wind Speed: %.1f ",getWindSpeed(data));
        weatherData.windSpeed = getWindSpeed(data);
        weatherData.wsTime = seconds;
        if(noisy)
            fprintf(stderr,"Wind Direction: %s ",Direction[getWindDirection(data)]);
        weatherData.wdTime = seconds;
        weatherData.windDirection = getWindDirection(data);
        if(noisy){
            fprintf(stderr,"Rain Counter: %d ",getRainCount(data));
            fprintf(stderr,"\n");
        }
        weatherData.rainCounter = getRainCount(data);
        weatherData.rcTime = seconds;
        reportsSeen |= 0x01; //I've seen report 1 type 2 now
    }
    // this is the other variety
    if ((data[2] & 0x0f) == 8){ // this has wind speed, temp and relative humidity
        if(noisy)
            fprintf(stderr,"Wind Speed: %.1f ",getWindSpeed(data));
        weatherData.windSpeed = getWindSpeed(data);
        weatherData.wsTime = seconds;
        if(noisy)
            fprintf(stderr,"Temperature: %.1f ",getTemp(data));
        weatherData.temperature = getTemp(data);
        weatherData.tTime = seconds;
        if(noisy){
            fprintf(stderr,"Humidity: %d ", getHumidity(data));
            fprintf(stderr,"\n");
        }
        weatherData.humidity = getHumidity(data);
        weatherData.hTime = seconds;
        reportsSeen |= 0x02;  // I've seen report 1 type 2 now

    }
}
Esempio n. 11
0
//-----------------------------------------
int add(int left, int right)
{
	emitInt("ld", left);
	emitInt("add", right);
	int temp = getTemp();
	emitInstruction2("st", symbol[temp]);
	return temp;
}
Esempio n. 12
0
void SNShield::getAll(){
    float acc[3];
    this->temp = getTemp();
    this->lux = getLux();
    readAccelData(acc);
    this->accx = acc[0];
    this->accy = acc[1];
    this->accz = acc[2];
}
Esempio n. 13
0
void CentralLB::BuildStatsMsg()
{
#if CMK_LBDB_ON
  // build and send stats
  const int osz = theLbdb->GetObjDataSz();
  const int csz = theLbdb->GetCommDataSz();

  int npes = CkNumPes();
  CLBStatsMsg* msg = new CLBStatsMsg(osz, csz);
  _MEMCHECK(msg);
  msg->from_pe = CkMyPe();
#if (defined(_FAULT_MLOG_) || defined(_FAULT_CAUSAL_))
	msg->step = step();
#endif
  //msg->serial = CrnRand();

/*
  theLbdb->TotalTime(&msg->total_walltime,&msg->total_cputime);
  theLbdb->IdleTime(&msg->idletime);
  theLbdb->BackgroundLoad(&msg->bg_walltime,&msg->bg_cputime);
*/
#if CMK_LB_CPUTIMER
  theLbdb->GetTime(&msg->total_walltime,&msg->total_cputime,
		   &msg->idletime, &msg->bg_walltime,&msg->bg_cputime);
#else
  theLbdb->GetTime(&msg->total_walltime,&msg->total_walltime,
		   &msg->idletime, &msg->bg_walltime,&msg->bg_walltime);
#endif
#if defined(TEMP_LDB)
	float mytemp=getTemp(CkMyPe()%physicalCoresPerNode);
	int freq=cpufreq_sysfs_read (CkMyPe()%logicalCoresPerNode);
	msg->pe_temp=mytemp;
	msg->pe_speed=freq;
#else
  msg->pe_speed = myspeed;
#endif

  DEBUGF(("Processor %d Total time (wall,cpu) = %f %f Idle = %f Bg = %f %f\n", CkMyPe(),msg->total_walltime,msg->total_cputime,msg->idletime,msg->bg_walltime,msg->bg_cputime));

  msg->n_objs = osz;
  theLbdb->GetObjData(msg->objData);
  msg->n_comm = csz;
  theLbdb->GetCommData(msg->commData);
//  theLbdb->ClearLoads();
  DEBUGF(("PE %d BuildStatsMsg %d objs, %d comm\n",CkMyPe(),msg->n_objs,msg->n_comm));

  if(CkMyPe() == cur_ld_balancer) {
    msg->avail_vector = new char[CkNumPes()];
    LBDatabaseObj()->get_avail_vector(msg->avail_vector);
    msg->next_lb = LBDatabaseObj()->new_lbbalancer();
  }

  CmiAssert(statsMsg == NULL);
  statsMsg = msg;
#endif
}
Esempio n. 14
0
void get_hwstats(void)
{
  getTemp(&hw.temp1, &hw.temp2, &hw.temp3);
  //printf("Temp.= %4.1f, %4.1f, %4.1f;",hw.temp1, hw.temp2, hw.temp3);
  getFanSp(&hw.rot1, &hw.rot2, &hw.rot3);
  //printf(" Rot.= %4d, %4d, %4d\n", hw.rot1, hw.rot2, hw.rot3);
  getVolt(&hw.vc0, &hw.vc1, &hw.v33, &hw.v50p, &hw.v50n, &hw.v12p, &hw.v12n);
  //printf(" Vcore = %4.2f, %4.2f; Volt. = %4.2f, %4.2f, %5.2f, %6.2f, %5.2f\n", 
  //       hw.vc0, hw.vc1, hw.v33, hw.v50p, hw.v12p, hw.v12n, hw.v50n);
}
Esempio n. 15
0
/*
 * Update Current Sensors and update the Sensors data Cache
 */
void Sensors::update_sensors(void){
	 float curr_moisture=moisture_read();
	    float curr_temps= getTemp();
	    float curr_flowrate=getWaterFlowRate();
	    sensors_values.cached_moisture=curr_moisture;
	    sensors_values.cached_temperature=curr_temps;
		sensors_values.cached_waterlevel = getWaterLevel(); // Boolean indicates if we have water or not.
		sensors_values.cached_flowvolume+=curr_flowrate/60000;//FlowRate(L/m) to FlowRate(m3/s).
		sensors_values.cached_fieldCapacity=readFieldCapacity();
}
Esempio n. 16
0
double getUnit(uint8_t port) {
	switch (portModeMeasure[port]) {
	case Vol : return measurement; break;
	case Light : return getLightIntensity(); break;
	case Temp : return getTemp(); break;
	case Noise : return getNoise(); break;
	case Distance : return getDistance(); break;
	default : return -1;
	}
}
Esempio n. 17
0
void drawROC(TString& type, TString& ytitle, TString& xtitle, TString& head, TString &leg1, TString& leg2, TString& leg3, TString & leg4){
  TCanvas *c = new TCanvas(Form("%s",type.Data()), Form("%s",type.Data()) ,5,49,400,400);
  SetStyleCanvas(c);

  TGraphAsymmErrors *grae1ROCdetrel = new TGraphAsymmErrors();
  TGraphAsymmErrors *grae1ROCdettrk = new TGraphAsymmErrors();
  TGraphAsymmErrors *grae1ROCpf = new TGraphAsymmErrors();
  TGraphErrors *grae1ROCLKT = new TGraphErrors();
  
  ROCDetectorRelIsoData(grae1ROCdetrel);
  ROCDetectorTrkIsoData(grae1ROCdettrk);
  ROCParticleIsoData(grae1ROCpf);

  TGraphErrors *graeTbkgData = new TGraphErrors();
  TGraphErrors *graeTsigData = new TGraphErrors();
  EffLKTIsoData(graeTsigData);
  SetDataQCDEffLKT(graeTbkgData);
  grae1ROCLKT = getROC(graeTsigData, graeTbkgData);

  //ROCLKTIsoData(grae1ROCLKT);
 
  //limit trk ROC to 10 points 
  grae1ROCdettrk = getModifiedROC(grae1ROCdettrk, 10);
 
  TGraphAsymmErrors *temp = new TGraphAsymmErrors();
  temp=getTemp(1, 14);
  SetStyleGraphErrors(temp, 2, 23, 0, 0.0,  ytitle, xtitle, 0.77, 1.02);

  SetStyleGraphErrors(grae1ROCdetrel, 2, 23, 0, 0.8,  ytitle, xtitle, 0.8, 1.1);
  SetStyleGraphErrors(grae1ROCdettrk, 3, 22, 0, 0.8, ytitle, xtitle, 0.8, 1.1);
  SetStyleGraphErrors(grae1ROCpf, 4, 20, 0, 0.8, ytitle, xtitle, 0.8, 1.1);
  SetStyleGraphErrors(grae1ROCLKT, 6, 20, 0, 0.8, ytitle, xtitle, 0.8, 1.1);

  //draw error band *****
  grae1ROCdetrel->SetFillColor(2);
  grae1ROCdetrel->SetFillStyle(3001);

  grae1ROCdettrk->SetFillColor(3);
  grae1ROCdettrk->SetFillStyle(3001);

  grae1ROCpf->SetFillColor(4);
  grae1ROCpf->SetFillStyle(3001);
  //end draw error band *****

  temp->Draw("APC");
  grae1ROCdetrel->Draw("3CPSame");
  grae1ROCdettrk->Draw("3CPSame");
  grae1ROCpf->Draw("3CPSame");
  grae1ROCLKT->Draw("PSame");

  SetLegend(grae1ROCpf, grae1ROCdetrel, grae1ROCdettrk, grae1ROCLKT, "Data", leg1, leg2, leg3, leg4, "PL","PL","PL","P",0.6, 0.20, 0.9,0.50);
  SetLabel(0.19,0.88,36);

  c->Print(Form("%s.eps",type.Data()));
}
Esempio n. 18
0
//-----------------------------------------
int mult(int left, int right)
{
   int temp;
   emitLoad(left);
   emitInstructionSI("mult", right);
   freeTemp(left);
   freeTemp(right);
   temp = getTemp();
   emitInstructionSI("st", temp);
   return temp;
}
Esempio n. 19
0
void temperature_thread(void const *argument) {
	float temp;

	while (1){
		osSignalWait(TEMP_DATA_READY_SIGNAL, osWaitForever);

		temp = getTemp();
		MAIL_send_input(MAIL_TEMP, k_filter_temp(temp));

		osSignalClear(temperature_thread_id, ACC_DATA_READY_SIGNAL);
	}
}
Esempio n. 20
0
unsigned char isThereTemperatureReady()
{
    if(waitNRF()==0)
    {
        getTemp();
        setAddr(17, 2);
        showTemp();
        NRF_down();
        return 1;
    };

    return 0;
};
int main(void)
{
	int isTime =0;
	int next = 0;
	double readTemp=0;
	double lowerRange = 0;
	double upperRange = 0;
	init();
	
	while(next != 1){
		lowerRange = denTemp - 1;
		upperRange = denTemp + 1;
		readTemp = getTemp();
		printStr("Denaturing temp is "); //send App
		uart_putchar(denTemp);
		uart_putchar('\n');
		_delay_ms(1000);
		printStr("readTemp is "); //send App
		uart_putchar(readTemp);
		uart_putchar('\n');
		_delay_ms(1000);
		
		if (readTemp < lowerRange)
		{
			PORTB = Heat_ON;
			PORTB = Fan_OFF;
			PORTD = LED_OFF;
		}
		
		if (readTemp > lowerRange && readTemp < upperRange)
		{
			PORTB = Heat_OFF;
			PORTB = Fan_OFF;
			PORTD = LED_ON;
		}
		
		
		if (readTemp > upperRange)
		{
			PORTB = Heat_OFF;
			PORTB = Fan_ON;
			PORTD = LED_OFF;
		}
	}
	
	
	
	
}
Esempio n. 22
0
void temperatureJob() {
    sensor.requestTemperatures();  // get all the tempratures first to speed up, moved up from getTemp()
    for (int i =0; i < deviceCount; i++ ) {
     request.body = getTemp(i);
      if (mycounter % PUSHFREQ == 0  && pushtoubiflag == true ) {
            String mypath = String("/api/v1.6/variables/");
            mypath.concat(ubivar[i]);
            mypath.concat("/values");
            request.path = mypath;
            http.post(request, response, headers);
            if( debug ) Serial << "http response: " << request.body << endl;
      }
      if( debug) debugSerial(i);
      //delay(200);  //seems like there is a natrual delay of about 150 ms
    }
}
Esempio n. 23
0
void updateTerminal() {
    // Clear terminal
    terminalSendPString(TERMINAL_CLEAR);

    terminalSendPString("CheckIt-StoreIt Terminal v0.81b");
    terminalSendPString(TERMINAL_RETURN);
    terminalSendPString(TERMINAL_RETURN);
    terminalSendPString("Last Measurements");
    terminalSendPString(TERMINAL_RETURN);

    // Carbon
    terminalSendPString("    Carbon:       ");
    sprintf(buffer, TERMINAL_NUMBER_FORMAT, getCarbon());
    terminalSendString(buffer);
    terminalSendPString(" ppm");
    terminalSendPString(TERMINAL_RETURN);

    // Salinity
    terminalSendPString("    Salinity:     ");
    sprintf(buffer, TERMINAL_NUMBER_FORMAT, getSalinity());
    terminalSendString(buffer);
    terminalSendPString(" ppt");
    terminalSendPString(TERMINAL_RETURN);

    // Flow Rate
    terminalSendPString("    Flow Rate:    ");
    sprintf(buffer, TERMINAL_NUMBER_FORMAT, getFlowRate());
    terminalSendString(buffer);
    terminalSendPString(" Lps");
    terminalSendPString(TERMINAL_RETURN);

    // Temperature
    terminalSendPString("    Temperature:  ");
    sprintf(buffer, TERMINAL_NUMBER_FORMAT, getTemp(fahrenheit));
    if (fahrenheit) {
        terminalSendString(buffer);
        terminalSendPString(" F");
    } else {
        terminalSendString(buffer);
        terminalSendPString(" C");
    }
    terminalSendPString(TERMINAL_RETURN);

    // Clear line
    sendTerminalCommandLine();
}
Esempio n. 24
0
// Read high resolution temperature
// -- returns temperature in 1/100ths degrees
// -- DS1620 must be in 1-shot mode
int TempSensor::getHrTemp()
{
  startConversion(true);                        // initiate conversion
  byte cfg = 0;
  while (cfg < DONE) {                          // let it finish
    cfg = getReg(ACCESS_CFG);
  }
  int tHR = getTemp(RD_TEMP);                   // get whole degrees reading
  byte cRem = getReg(RD_CNTR);                  // get counts remaining
  byte slope = getReg(RD_SLOPE);                // get counts per degree
  if (tHR >= 0)
    tHR = (tHR * 100 - 25) + ((slope - cRem) * 100 / slope);
  else {
    tHR = -tHR;
    tHR = (25 - tHR * 100) + ((slope - cRem) * 100 / slope);
  }
  return tHR;
}
Esempio n. 25
0
void ST7735_UpdateTemperatureGraph(uint32_t numSamples, uint16_t adcValue)
{
    uint16_t temperature = getTemp(adcValue);
    
    // DEBUG
    // Magnify the plot to see the noise distribution better
    // ST7735_PlotPoint((temperature - 2200)*15);
    ST7735_PlotPoint(temperature);  // Measured temperature
    if((numSamples&(N-1))==0){          // fs sampling, fs/N samples plotted per second
        ST7735_PlotNextErase();  // overwrites N points on same line
    }
    if((numSamples%FS)==0){    // fs sampling, 1 Hz display of numerical data
        ST7735_SetCursor(3,1); 
        ST7735_OutUDec(adcValue);            // 0 to 4095
        ST7735_OutString(" "); // clear previous number
        ST7735_SetCursor(3,2); 
        ST7735_sDecOut2(temperature); // 0.01 C 
    }
}
Esempio n. 26
0
int main(int argc, char** argv){
	//variable declarations
	struct pollfd fdset[1];
	int rc;
	char buf[MAX_BUF];

	init();

	//set signal handler
	if (signal(SIGINT, signal_handler) == SIG_ERR)
		printf("\ncan't catch SIGINT\n");

	while (1) {
		memset((void*)fdset, 0, sizeof(fdset));
	
		fdset[0].fd = button_fd;
		fdset[0].events = POLLPRI;

		rc = poll(fdset, POLLIN, TIMEOUT);

		if (rc < 0){
			printf("\npoll() failed!\n");
			break;
		}
	
		if (rc == 0){
			//Set PWM duty cycle based on potentiometer every 100ms
			set_pwm(LED1_PWM, LED1_PWM_FREQ, read_ain(POT)/41);
			fflush(stdout);
		}

		if((fdset[0].revents & POLLPRI) == POLLPRI) {
			//Output temperature to stdout when button is pressed
			read(fdset[0].fd, (void *)buf, MAX_BUF);
			printf("\nCurrent Temperature = %d degrees C", getTemp());
			led0_value = led0_value^1;
			set_gpio_value(LED0, led0_value);
		}			
		
	}

	return -1;
}
Esempio n. 27
0
//----------timerIntHandler0----------
void timerIntHandler(void){
    if(timerInt){
        timerInt = 0;           // Reset flag
        
        // Measure temp and input to DSP class 
        getTemp(&tempTemp);
        inputTemp(&tempTemp);
        
        // Measure soilhum and input to DSP class 
        {
            uint8 i;
            for(i = 0; i<6 ; i++){
                getSoilHum(i, &tempSoilHum[i]);
                inputSoilHum(i, &tempSoilHum[i]);
            }
        }
        
        RedLED_Write(LED_OFF);                      // Turn off red LED    
    }    
}
glm::fvec3 CPlanetTextureGenerator::getTerrainColor(const unsigned int x, const unsigned int y, const CHeightMap* heightMap) const
{
	float waterLevel = heightMap->getBorderValue(currPlanetParams->liquidPart);
	float terrHeight = 0;
	glm::fvec3 currColor = glm::fvec3(0.0f);

	const unsigned int sideLen = heightMap->getWidth();

	float cx = x - sideLen / 2.0f;
	float cy = y - sideLen / 2.0f;
	float distance = sqrtf(cx*cx + cy*cy);
	if (distance > sideLen / 2) return currColor;
		
	terrHeight = heightMap->get(x,y) - waterLevel;
	float slope = heightMap->getSlope(x, y);

	if (terrHeight <= 0.0f) currColor = currPlanetParams->liquidColor;
	else
	if (terrHeight < 0.05f) currColor = currPlanetParams->terrainLowColor;
	else
	if (terrHeight < 0.350f) currColor = currPlanetParams->terrainMedColor;
	else
	if (terrHeight <= 1.0f) currColor = currPlanetParams->terrainHightColor;

	float wetness = getWetness(x, y, heightMap); 
	float temp    = getTemp(x, y, heightMap);

	if (wetness > 0.1f && temp < 0.0f && temp > -200.0f)	currColor = currPlanetParams->iceColor;
	
	if (terrHeight <= 0.0f) currColor += slope * 0.5f;
	else currColor += slope * 2.0f;

	if (currColor.r > 1.0f) currColor.r = 1.0f;
	if (currColor.g > 1.0f) currColor.g = 1.0f;
	if (currColor.b > 1.0f) currColor.b = 1.0f;
	if (currColor.r < 0.0f) currColor.r = 0.0f;
	if (currColor.g < 0.0f) currColor.g = 0.0f;
	if (currColor.b < 0.0f) currColor.b = 0.0f;

	return currColor;
}
Esempio n. 29
0
void sendMeasureUART (uint8_t port) {
	double reCalc = 0.0;
	switch (portModeMeasure[port]) {
	case Vol :
		reCalc = measurement;
		dtostrf(reCalc ,7,3, voltageValueBuffer);
		break;
	case Light :
		reCalc = getLightIntensity();
		dtostrf(reCalc ,7,1, voltageValueBuffer);
		break;
	case Temp :
		reCalc = getTemp();
		dtostrf(reCalc ,7,1, voltageValueBuffer);
		break;
	case Noise :
		reCalc = getNoise();
		dtostrf(reCalc ,7,3, voltageValueBuffer);
		break;
	case Distance :
		reCalc = getDistance();
		dtostrf(reCalc ,7,1, voltageValueBuffer);
		break;
	}
	uart_puts("P:");

	uart_putc((char) port +48);
	uart_putc(';');
	// +1 wegen leerzeichen ... -- vorzeichen platzhalter
	uart_puts(voltageValueBuffer+1);

	switch (portModeMeasure[port]) {
	case Vol : uart_puts(" V"); break;
	case Light : uart_puts(" L"); break;
	case Temp : uart_puts(" C"); break;
	case Noise : uart_puts(" S"); break;
	case Distance : uart_puts(" cm"); break;
	}

	uart_putc('\n');
}
Esempio n. 30
0
//==============================================================================
void show_parameters()
{ 
            sec=s;
            lcd_gotoxy(6,1);
            lcd_putc("DS3231 RTC");              
            lcd_gotoxy(1,3);                                
            printf(lcd_putc, "Date: %02u/%02u/%02u ", dt, mt, yr); 
            //showDay(dy, 16, 3); 
            
            lcd_gotoxy(1,4);
            printf(lcd_putc, "Temp: %2.2g'C ", getTemp());          
            
            lcd_gotoxy(1,2);
            switch(hr_format) 
            {                                  
                     case 1: 
                     {  
                              switch(am_pm) 
                              { 
                                       case 1: 
                                       { 
                                                printf(lcd_putc, "Time: %02u:%02u:%02u PM ", hr, min, s);    
                                                break;    
                                       }                                                                        
                                       default: 
                                       {              
                                                printf(lcd_putc, "Time: %02u:%02u:%02u AM ", hr, min, s);    
                                                break;    
                                       } 
                              }      
                              break; 
                     }              
                     default: 
                     {          
                              printf(lcd_putc, "Time: %02u:%02u:%02u     ", hr, min, s);    
                              break;                                  
                     }    
            }
         //delay_ms(600);
}