static struct ureg calculate_light_attenuation( struct tnl_program *p,
						GLuint i, 
						struct ureg VPpli,
						struct ureg dist )
{
   struct ureg attenuation = register_param3(p, STATE_LIGHT, i,
					     STATE_ATTENUATION);
   struct ureg att = get_temp(p);

   /* Calculate spot attenuation:
    */
   if (!p->state->unit[i].light_spotcutoff_is_180) {
      struct ureg spot_dir_norm = register_param3(p, STATE_INTERNAL,
						  STATE_SPOT_DIR_NORMALIZED, i);
      struct ureg spot = get_temp(p);
      struct ureg slt = get_temp(p);

      emit_op2(p, OPCODE_DP3, spot, 0, negate(VPpli), spot_dir_norm);
      emit_op2(p, OPCODE_SLT, slt, 0, swizzle1(spot_dir_norm,W), spot);
      emit_op2(p, OPCODE_POW, spot, 0, spot, swizzle1(attenuation, W));
      emit_op2(p, OPCODE_MUL, att, 0, slt, spot);

      release_temp(p, spot);
      release_temp(p, slt);
   }

   /* Calculate distance attenuation:
    */
   if (p->state->unit[i].light_attenuated) {

      /* 1/d,d,d,1/d */
      emit_op1(p, OPCODE_RCP, dist, WRITEMASK_YZ, dist); 
      /* 1,d,d*d,1/d */
      emit_op2(p, OPCODE_MUL, dist, WRITEMASK_XZ, dist, swizzle1(dist,Y)); 
      /* 1/dist-atten */
      emit_op2(p, OPCODE_DP3, dist, 0, attenuation, dist); 

      if (!p->state->unit[i].light_spotcutoff_is_180) {
	 /* dist-atten */
	 emit_op1(p, OPCODE_RCP, dist, 0, dist); 
	 /* spot-atten * dist-atten */
	 emit_op2(p, OPCODE_MUL, att, 0, dist, att);	
      } else {
	 /* dist-atten */
	 emit_op1(p, OPCODE_RCP, att, 0, dist); 
      }
   }

   return att;
}
Exemplo n.º 2
0
double get_cell_presure(int nc, int x, int y)
{
	int krp, nm;
	double result = 0, norm = 0;
	VECTOR v0;
	PARTICLE *p;
	v0.x = v0.y = v0.z = 0;
	for (krp = 0; krp < KRP; krp++)
	{
		for (nm = 0; nm < NM; nm++)
		{
			p = &camera[krp][x][y][nc][nm];
			v0.x += p->v.x * p->weight;
			v0.y += p->v.y * p->weight;
			v0.z += p->v.z * p->weight;
			norm += p->weight;
		}
	}
	multiply(&v0, &v0, (1.0 / norm));

	for (krp = 0; krp < KRP; krp++)
	{
		for (nm = 0; nm < NM; nm++)
		{
			result += get_temp(&camera[krp][x][y][nc][nm], &v0);
		}
	}
	return (K*result/krp);
}
Exemplo n.º 3
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(web_sense_process, ev, data)
{
  static struct etimer timer;
  PROCESS_BEGIN();

  sensors_pos = 0;

  etimer_set(&timer, CLOCK_SECOND * 2);
#if CONTIKI_TARGET_SKY
  SENSORS_ACTIVATE(light_sensor);
  SENSORS_ACTIVATE(sht11_sensor);
#endif

  while(1) {
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer));
    etimer_reset(&timer);

#if CONTIKI_TARGET_SKY
    light1[sensors_pos] = get_light();;
    temperature[sensors_pos] = get_temp();
    sensors_pos = (sensors_pos + 1) % HISTORY;
#endif
  }

  PROCESS_END();
}
Exemplo n.º 4
0
int main(int argc, char **argv)
{
  int pth1;  

  pthread_t thread_serv_listen;
  pthread_attr_t attr; // set of attributes for the thread 
  pthread_attr_init(&attr); // get the default attributes 

  s = setup_listen(SERVER_PORT);
  if (s < 0) {
    printf("error opening server\n");
    exit(1);
  }else{
    printf("server started\n");
  }

  if( (pth1 = pthread_create( &thread_serv_listen, &attr, server_listen, NULL)) ){
    printf("Server listen thread creation failed: %d\n", pth1);
  }else{
    printf("Server thread created\n");
  }


  while(1){
//    printf("while1 read temp\n");
    usleep(1000000); // cakamo eno sekundo
    buf_put((element_t)get_temp());
  }
  close(s);

  return 0;
}
Exemplo n.º 5
0
int
main(void)
{
        struct items {
                char *up;
                char *load;
                char *fan;
                char *temp;
                char *mem;
                char *swap;
                char *diskio;
                char *fs_root;
                char *fs_home;
                char *fs_storage;
                char *net_speed;
                char *batt;
                char *vol;
                char *time;
                char *status;
        };

	if (!(dpy = XOpenDisplay(NULL))) {
		fprintf(stderr, "dwmstatus: cannot open display.\n");
		return 1;
    }

        struct items *i = malloc(sizeof(struct items));

	while(1) {
		i->up = get_up();
		i->load = get_load();
		i->fan = get_fan();
		i->temp = get_temp();
		i->mem = get_mem();
		i->swap = get_swap();
		i->diskio = get_diskio("sda");
                i->fs_root = get_space("/");
                i->fs_home = get_space("/home");
                i->net_speed = get_net_speed();
		i->batt = get_batt();
		i->vol = get_vol();
		i->time = mktimes("%m/%d/%Y %a %H:%M", tzkiev);

		i->status = smprintf(
                        "up:%s la:%s fan:%s temp:%s m:%s s:%s io:%s /:%s "
                        "~/:%s net:%s bat:%s vol:%s %s",
                        i->up, i->load, i->fan, i->temp, i->mem, i->swap,
                        i->diskio, i->fs_root, i->fs_home, i->net_speed,
                        i->batt, i->vol, i->time);
		setstatus(i->status);

                sleep(INTERVAL);
    }

        free(i);

	XCloseDisplay(dpy);

	return EXIT_SUCCESS;
}
Exemplo n.º 6
0
static void temp_sensor_poll(void)
{
	int temp_c;

	if (!has_power())
		return;

	if (get_temp(TMP432_LOCAL, &temp_c) == EC_SUCCESS)
		temp_val_local = C_TO_K(temp_c);

	if (get_temp(TMP432_REMOTE1, &temp_c) == EC_SUCCESS)
		temp_val_remote1 = C_TO_K(temp_c);

	if (get_temp(TMP432_REMOTE2, &temp_c) == EC_SUCCESS)
		temp_val_remote2 = C_TO_K(temp_c);
}
Exemplo n.º 7
0
/* Main function */
int main()
{
    Machine mach;
    double A, k;

    init(&mach);

    k = (log(mach.fan.max_speed) - log(mach.fan.min_speed)) / (mach.high_temp - mach.low_temp);
    A = mach.fan.max_speed * exp(-(mach.high_temp * k));

    while(1)
    {
        mach.temp = get_temp(mach.cores);
        mach.fan.speed = calc_fan_speed(mach, A, k);
        if(mach.fan.old_speed != mach.fan.speed)
        {
            set_fan_speed(mach.fan.speed);
            log_fan_speed(mach.fan.speed, mach.temp);
            mach.fan.old_speed = mach.fan.speed;
            mach.old_temp = mach.temp;
        }
        sleep(mach.polling_interval);
    }

    return SUCCESS;
}
Exemplo n.º 8
0
static void get_action(Server *server, char **tokens, uint8_t count)
{
    int sensors[1 + NCHAN_TC + NCHAN_TH];

    if ( !tokens || !count )
    {
	for (uint8_t i = 0; i <= NCHAN_TC + NCHAN_TH; i++)
	    sensors[i] = i;
	count = 1 + NCHAN_TC + NCHAN_TH;
    }
    else if ( parse_tokens(sensors, tokens, count, 0, NCHAN_TC + NCHAN_TH) )
	// Error response was generated by parse_tokens()
	return;

    write_pgmspace(okay_text);

    for (uint8_t i = 0; i < count; i++)
    {
	write_pgmspace(space_text);
	Serial.print(sensors[i]);
	write_pgmspace(space_text);
#ifdef USE_HID
	float temp = hidtemp_get_temp((uint8_t)(0xff & sensors[i]));
#else
	float temp = get_temp(server, sensors[i]);
#endif
	Serial.print(temp);
    }
    write_pgmspace(crlf_text);
}
Exemplo n.º 9
0
static struct brw_fp_src get_pixel_w( struct brw_wm_compile *c )
{
   if (src_is_undef(c->fp_pixel_w)) {
      struct brw_fp_dst pixel_w = get_temp(c);
      struct brw_fp_src deltas = get_delta_xy(c);

      /* XXX: assuming position is always first -- valid? 
       */
      struct brw_fp_src interp_wpos = src_reg(BRW_FILE_PAYLOAD, 0);

      /* deltas.xyw = DELTAS2 deltas.xy, payload.interp_wpos.x
       */
      emit_op3(c,
	       WM_PIXELW,
	       dst_mask(pixel_w, BRW_WRITEMASK_W),
	       interp_wpos,
	       deltas, 
	       src_undef());
      

      c->fp_pixel_w = src_reg_from_dst(pixel_w);
   }

   return c->fp_pixel_w;
}
Exemplo n.º 10
0
static struct prog_src_register get_pixel_xy( struct brw_wm_compile *c )
{
   if (src_is_undef(c->pixel_xy)) {
      struct prog_dst_register pixel_xy = get_temp(c);
      struct prog_src_register payload_r0_depth = src_reg(PROGRAM_PAYLOAD, PAYLOAD_DEPTH);
      
      
      /* Emit the out calculations, and hold onto the results.  Use
       * two instructions as a temporary is required.
       */   
      /* pixel_xy.xy = PIXELXY payload[0];
       */
      emit_op(c,
	      WM_PIXELXY,
	      dst_mask(pixel_xy, WRITEMASK_XY),
	      0,
	      payload_r0_depth,
	      src_undef(),
	      src_undef());

      c->pixel_xy = src_reg_from_dst(pixel_xy);
   }

   return c->pixel_xy;
}
Exemplo n.º 11
0
/**
 * Point size attenuation computation.
 */
static void build_atten_pointsize( struct tnl_program *p )
{
   struct ureg eye = get_eye_position_z(p);
   struct ureg state_size = register_param1(p, STATE_POINT_SIZE);
   struct ureg state_attenuation = register_param1(p, STATE_POINT_ATTENUATION);
   struct ureg out = register_output(p, VERT_RESULT_PSIZ);
   struct ureg ut = get_temp(p);

   /* dist = |eyez| */
   emit_op1(p, OPCODE_ABS, ut, WRITEMASK_Y, swizzle1(eye, Z));
   /* p1 + dist * (p2 + dist * p3); */
   emit_op3(p, OPCODE_MAD, ut, WRITEMASK_X, swizzle1(ut, Y),
		swizzle1(state_attenuation, Z), swizzle1(state_attenuation, Y));
   emit_op3(p, OPCODE_MAD, ut, WRITEMASK_X, swizzle1(ut, Y),
		ut, swizzle1(state_attenuation, X));

   /* 1 / sqrt(factor) */
   emit_op1(p, OPCODE_RSQ, ut, WRITEMASK_X, ut );

#if 0
   /* out = pointSize / sqrt(factor) */
   emit_op2(p, OPCODE_MUL, out, WRITEMASK_X, ut, state_size);
#else
   /* this is a good place to clamp the point size since there's likely
    * no hardware registers to clamp point size at rasterization time.
    */
   emit_op2(p, OPCODE_MUL, ut, WRITEMASK_X, ut, state_size);
   emit_op2(p, OPCODE_MAX, ut, WRITEMASK_X, ut, swizzle1(state_size, Y));
   emit_op2(p, OPCODE_MIN, out, WRITEMASK_X, ut, swizzle1(state_size, Z));
#endif

   release_temp(p, ut);
}
Exemplo n.º 12
0
static void build_pointsize( struct tnl_program *p )
{
   struct ureg eye = get_eye_position(p);
   struct ureg state_size = register_param1(p, STATE_POINT_SIZE);
   struct ureg state_attenuation = register_param1(p, STATE_POINT_ATTENUATION);
   struct ureg out = register_output(p, VERT_RESULT_PSIZ);
   struct ureg ut = get_temp(p);

   /* dist = |eyez| */
   emit_op1(p, OPCODE_ABS, ut, WRITEMASK_Y, swizzle1(eye, Z));
   /* p1 + dist * (p2 + dist * p3); */
   emit_op3(p, OPCODE_MAD, ut, WRITEMASK_X, swizzle1(ut, Y),
		swizzle1(state_attenuation, Z), swizzle1(state_attenuation, Y));
   emit_op3(p, OPCODE_MAD, ut, WRITEMASK_X, swizzle1(ut, Y),
		ut, swizzle1(state_attenuation, X));

   /* 1 / sqrt(factor) */
   emit_op1(p, OPCODE_RSQ, ut, WRITEMASK_X, ut );

#if 1
   /* out = pointSize / sqrt(factor) */
   emit_op2(p, OPCODE_MUL, out, WRITEMASK_X, ut, state_size);
#else
   /* not sure, might make sense to do clamping here,
      but it's not done in t_vb_points neither */
   emit_op2(p, OPCODE_MUL, ut, WRITEMASK_X, ut, state_size);
   emit_op2(p, OPCODE_MAX, ut, WRITEMASK_X, ut, swizzle1(state_size, Y));
   emit_op2(p, OPCODE_MIN, out, WRITEMASK_X, ut, swizzle1(state_size, Z));
#endif

   release_temp(p, ut);
}
Exemplo n.º 13
0
/* Seems like it could be tighter:
 */
static void build_pointsize( struct tnl_program *p )
{
   struct ureg eye = get_eye_position(p);
   struct ureg state_size = register_param1(p, STATE_POINT_SIZE);
   struct ureg state_attenuation = register_param1(p, STATE_POINT_ATTENUATION);
   struct ureg out = register_output(p, VERT_RESULT_PSIZ);
   struct ureg ut = get_temp(p);

   /* 1, Z, Z * Z, 1 */      
   emit_op1(p, OPCODE_MOV, ut, WRITEMASK_XW, swizzle1(get_identity_param(p), W));
   emit_op1(p, OPCODE_ABS, ut, WRITEMASK_YZ, swizzle1(eye, Z));
   emit_op2(p, OPCODE_MUL, ut, WRITEMASK_Z, ut, ut);


   /* p1 +  p2 * dist + p3 * dist * dist, 0 */
   emit_op2(p, OPCODE_DP3, ut, WRITEMASK_X, ut, state_attenuation);

   /* 1 / sqrt(factor) */
   emit_op1(p, OPCODE_RSQ, ut, WRITEMASK_X, ut ); 

   /* ut = pointSize / factor */
   emit_op2(p, OPCODE_MUL, ut, WRITEMASK_X, ut, state_size); 

   /* Clamp to min/max - state_size.[yz]
    */
   emit_op2(p, OPCODE_MAX, ut, WRITEMASK_X, ut, swizzle1(state_size, Y)); 
   emit_op2(p, OPCODE_MIN, out, 0, swizzle1(ut, X), swizzle1(state_size, Z)); 
   
   release_temp(p, ut);
}
Exemplo n.º 14
0
int main(void){  
	char* lab9greeting = "Welcome to Lab 9!";
	int temp;
//	int Temperature = 100;
//  DisableInterrupts();
//  PLL_Init(Bus80MHz);
//	//ST7735_InitR(INITR_REDTAB);
//  Output_Init();       // UART0 only used for debugging
//	ST7735_Output_Init(); 
//	ADC0_InitSWTriggerSeq3_Ch9(); //initialize the ADC
//	Timer0A_Init20HzInt(); //initialize the timer
//	ST7735_DrawString(0,0, lab9greeting, ST7735_WHITE);
//	EnableInterrupts();
	
	PLL_Init(Bus80MHz);                   // 80 MHz
  SYSCTL_RCGCGPIO_R |= 0x20;            // activate port F
  ADC0_InitSWTriggerSeq3_Ch9();         // allow time to finish activating
  Timer0A_Init20HzInt();               // set up Timer0A for 100 Hz interrupts
  GPIO_PORTF_DIR_R |= 0x06;             // make PF2, PF1 out (built-in LED)
  GPIO_PORTF_AFSEL_R &= ~0x06;          // disable alt funct on PF2, PF1
  GPIO_PORTF_DEN_R |= 0x06;             // enable digital I/O on PF2, PF1
                                        // configure PF2 as GPIO
  GPIO_PORTF_PCTL_R = (GPIO_PORTF_PCTL_R&0xFFFFF00F)+0x00000000;
  GPIO_PORTF_AMSEL_R = 0;               // disable analog functionality on PF
  PF2 = 0;                      // turn off LED
	ST7735_Output_Init();
	ST7735_DrawString(0,0, lab9greeting, ST7735_WHITE);
	//Init_Plot();
	
	//ST7735_SetCursor(0,0); ST7735_OutString("Lab 9");
 ST7735_PlotClear(1000,4000);  // range from 0 to 4095
 ST7735_SetCursor(0,1); ST7735_OutString("N=");
 ST7735_SetCursor(0,2); ST7735_OutString("T="); //ST7735_DecOut2(2500);
                        ST7735_OutString(" C");
  EnableInterrupts();
	
  while(1){
						ST7735_SetCursor(3,1); ST7735_OutUDec(ADCvalue);            // 0 to 4095

		if(refresh){
				refresh = 0;
				samples++;
		    ST7735_PlotPoint(ADCvalue);  // Measured temperature
				if((samples&(N-1))==0){          // fs sampling, fs/N samples plotted per second
					ST7735_PlotNextErase();  // overwrites N points on same line
				}
				if((samples%fs)==0){    // fs sampling, 1 Hz display of numerical data
				//do conversion here, set it equal to temp.
				temp = get_temp(ADCvalue);
				ST7735_SetCursor(3,1); ST7735_OutUDec(ADCvalue);            // 0 to 4095
				ST7735_SetCursor(3,2);ST7735_DecOut2(temp); // 0.01 C 
			}

		}
	}

  
}
Exemplo n.º 15
0
void print_temc(void){
	print("Current Temperature ");
	get_temp();
	UARTCharPut(UART0_BASE, ui32TempValueC/10 + 48);
	UARTCharPut(UART0_BASE, ui32TempValueC%10 + 48);
	UARTCharPut(UART0_BASE, 96);
	UARTCharPut(UART0_BASE, 'C');
	UARTCharPut(UART0_BASE, ' ');
}
Exemplo n.º 16
0
static void build_fog( struct tnl_program *p )
{
   struct ureg fog = register_output(p, VERT_RESULT_FOGC);
   struct ureg input;
   GLuint useabs = p->state->fog_source_is_depth && p->state->fog_option &&
		   (p->state->fog_option != FOG_EXP2);

   if (p->state->fog_source_is_depth) {
      input = swizzle1(get_eye_position(p), Z);
   }
   else {
      input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X);
   }

   if (p->state->fog_option &&
       p->state->tnl_do_vertex_fog) {
      struct ureg params = register_param2(p, STATE_INTERNAL,
					   STATE_FOG_PARAMS_OPTIMIZED);
      struct ureg tmp = get_temp(p);
      struct ureg id = get_identity_param(p);

      emit_op1(p, OPCODE_MOV, fog, 0, id);

      if (useabs) {
	 emit_op1(p, OPCODE_ABS, tmp, 0, input);
      }

      switch (p->state->fog_option) {
      case FOG_LINEAR: {
	 emit_op3(p, OPCODE_MAD, tmp, 0, useabs ? tmp : input,
			swizzle1(params,X), swizzle1(params,Y));
	 emit_op2(p, OPCODE_MAX, tmp, 0, tmp, swizzle1(id,X)); /* saturate */
	 emit_op2(p, OPCODE_MIN, fog, WRITEMASK_X, tmp, swizzle1(id,W));
	 break;
      }
      case FOG_EXP:
	 emit_op2(p, OPCODE_MUL, tmp, 0, useabs ? tmp : input,
			swizzle1(params,Z));
	 emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, ureg_negate(tmp));
	 break;
      case FOG_EXP2:
	 emit_op2(p, OPCODE_MUL, tmp, 0, input, swizzle1(params,W));
	 emit_op2(p, OPCODE_MUL, tmp, 0, tmp, tmp);
	 emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, ureg_negate(tmp));
	 break;
      }

      release_temp(p, tmp);
   }
   else {
      /* results = incoming fog coords (compute fog per-fragment later) 
       *
       * KW:  Is it really necessary to do anything in this case?
       */
      emit_op1(p, useabs ? OPCODE_ABS : OPCODE_MOV, fog, 0, input);
   }
}
Exemplo n.º 17
0
static void build_fog( struct tnl_program *p )
{
   struct ureg fog = register_output(p, VERT_RESULT_FOGC);
   struct ureg input;

   if (p->state->fog_source_is_depth) {
      input = swizzle1(get_eye_position(p), Z);
   }
   else {
      input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X);
   }

   if (p->state->fog_mode && p->state->tnl_do_vertex_fog) {
      struct ureg params = register_param2(p, STATE_INTERNAL,
					   STATE_FOG_PARAMS_OPTIMIZED);
      struct ureg tmp = get_temp(p);
      GLboolean useabs = (p->state->fog_mode != FOG_EXP2);

      if (useabs) {
	 emit_op1(p, OPCODE_ABS, tmp, 0, input);
      }

      switch (p->state->fog_mode) {
      case FOG_LINEAR: {
	 struct ureg id = get_identity_param(p);
	 emit_op3(p, OPCODE_MAD, tmp, 0, useabs ? tmp : input,
			swizzle1(params,X), swizzle1(params,Y));
	 emit_op2(p, OPCODE_MAX, tmp, 0, tmp, swizzle1(id,X)); /* saturate */
	 emit_op2(p, OPCODE_MIN, fog, WRITEMASK_X, tmp, swizzle1(id,W));
	 break;
      }
      case FOG_EXP:
	 emit_op2(p, OPCODE_MUL, tmp, 0, useabs ? tmp : input,
			swizzle1(params,Z));
	 emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, negate(tmp));
	 break;
      case FOG_EXP2:
	 emit_op2(p, OPCODE_MUL, tmp, 0, input, swizzle1(params,W));
	 emit_op2(p, OPCODE_MUL, tmp, 0, tmp, tmp);
	 emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, negate(tmp));
	 break;
      }

      release_temp(p, tmp);
   }
   else {
      /* results = incoming fog coords (compute fog per-fragment later) 
       *
       * KW:  Is it really necessary to do anything in this case?
       * BP: Yes, we always need to compute the absolute value, unless
       * we want to push that down into the fragment program...
       */
      GLboolean useabs = GL_TRUE;
      emit_op1(p, useabs ? OPCODE_ABS : OPCODE_MOV, fog, WRITEMASK_X, input);
   }
}
Exemplo n.º 18
0
static void emit_normalize_vec3( struct tnl_program *p,
				 struct ureg dest,
				 struct ureg src )
{
   struct ureg tmp = get_temp(p);
   emit_op2(p, OPCODE_DP3, tmp, WRITEMASK_X, src, src);
   emit_op1(p, OPCODE_RSQ, tmp, WRITEMASK_X, tmp);
   emit_op2(p, OPCODE_MUL, dest, 0, src, swizzle1(tmp, X));
   release_temp(p, tmp);
}
Exemplo n.º 19
0
static struct ureg_src
prepare_argument(struct st_translate *t, const unsigned argId,
                 const struct atifragshader_src_register *srcReg)
{
   struct ureg_src src = get_source(t, srcReg->Index);
   struct ureg_dst arg = get_temp(t, MAX_NUM_FRAGMENT_REGISTERS_ATI + argId);

   switch (srcReg->argRep) {
   case GL_NONE:
      break;
   case GL_RED:
      src = ureg_scalar(src, TGSI_SWIZZLE_X);
      break;
   case GL_GREEN:
      src = ureg_scalar(src, TGSI_SWIZZLE_Y);
      break;
   case GL_BLUE:
      src = ureg_scalar(src, TGSI_SWIZZLE_Z);
      break;
   case GL_ALPHA:
      src = ureg_scalar(src, TGSI_SWIZZLE_W);
      break;
   }
   ureg_insn(t->ureg, TGSI_OPCODE_MOV, &arg, 1, &src, 1);

   if (srcReg->argMod & GL_COMP_BIT_ATI) {
      struct ureg_src modsrc[2];
      modsrc[0] = ureg_imm1f(t->ureg, 1.0f);
      modsrc[1] = ureg_src(arg);

      ureg_insn(t->ureg, TGSI_OPCODE_SUB, &arg, 1, modsrc, 2);
   }
   if (srcReg->argMod & GL_BIAS_BIT_ATI) {
      struct ureg_src modsrc[2];
      modsrc[0] = ureg_src(arg);
      modsrc[1] = ureg_imm1f(t->ureg, 0.5f);

      ureg_insn(t->ureg, TGSI_OPCODE_SUB, &arg, 1, modsrc, 2);
   }
   if (srcReg->argMod & GL_2X_BIT_ATI) {
      struct ureg_src modsrc[2];
      modsrc[0] = ureg_src(arg);
      modsrc[1] = ureg_src(arg);

      ureg_insn(t->ureg, TGSI_OPCODE_ADD, &arg, 1, modsrc, 2);
   }
   if (srcReg->argMod & GL_NEGATE_BIT_ATI) {
      struct ureg_src modsrc[2];
      modsrc[0] = ureg_src(arg);
      modsrc[1] = ureg_imm1f(t->ureg, -1.0f);

      ureg_insn(t->ureg, TGSI_OPCODE_MUL, &arg, 1, modsrc, 2);
   }
   return  ureg_src(arg);
}
Exemplo n.º 20
0
static struct ureg make_temp( struct tnl_program *p, struct ureg reg )
{
   if (reg.file == PROGRAM_TEMPORARY &&
       !(p->temp_reserved & (1<<reg.idx)))
      return reg;
   else {
      struct ureg temp = get_temp(p);
      emit_op1(p, OPCODE_MOV, temp, 0, reg);
      return temp;
   }
}
Exemplo n.º 21
0
static char *R(CTX *ctx, struct ir_inst *in, int i)
{
    struct ir_inst *r = inst_getuse(in, i);
    if (type_is_void(r->result_type))
        return VOID_VAL;
    if (r->scratch1_i < 0) {
        return gen_inst_inline(ctx, r);
    } else {
        return get_temp(ctx, r->scratch1_i);
    }
}
Exemplo n.º 22
0
Arquivo: main.c Projeto: monolli/ee109
int main(void){
	
	init_serial();
	init_ISR();				//initialize all functions, ports...
	init_led();
	init_buttons();
	init_temp();
	get_temp();
	ht=temp;
	lt=temp;
	init_lcd();

	while(1){
		get_temp();				//recieve the temp, convert and print
		led_on();				//turn the led functions on
		get_serial();			//recieve the temp through serial
	}
	
	return 0;
}
Exemplo n.º 23
0
static void build_sphere_texgen( struct tnl_program *p,
				 struct ureg dest,
				 GLuint writemask )
{
   struct ureg normal = get_transformed_normal(p);
   struct ureg eye_hat = get_eye_position_normalized(p);
   struct ureg tmp = get_temp(p);
   struct ureg half = register_scalar_const(p, .5);
   struct ureg r = get_temp(p);
   struct ureg inv_m = get_temp(p);
   struct ureg id = get_identity_param(p);

   /* Could share the above calculations, but it would be
    * a fairly odd state for someone to set (both sphere and
    * reflection active for different texture coordinate
    * components.  Of course - if two texture units enable
    * reflect and/or sphere, things start to tilt in favour
    * of seperating this out:
    */

   /* n.u */
   emit_op2(p, OPCODE_DP3, tmp, 0, normal, eye_hat);
   /* 2n.u */
   emit_op2(p, OPCODE_ADD, tmp, 0, tmp, tmp);
   /* (-2n.u)n + u */
   emit_op3(p, OPCODE_MAD, r, 0, negate(tmp), normal, eye_hat);
   /* r + 0,0,1 */
   emit_op2(p, OPCODE_ADD, tmp, 0, r, swizzle(id,X,Y,W,Z));
   /* rx^2 + ry^2 + (rz+1)^2 */
   emit_op2(p, OPCODE_DP3, tmp, 0, tmp, tmp);
   /* 2/m */
   emit_op1(p, OPCODE_RSQ, tmp, 0, tmp);
   /* 1/m */
   emit_op2(p, OPCODE_MUL, inv_m, 0, tmp, half);
   /* r/m + 1/2 */
   emit_op3(p, OPCODE_MAD, dest, writemask, r, inv_m, half);

   release_temp(p, tmp);
   release_temp(p, r);
   release_temp(p, inv_m);
}
Exemplo n.º 24
0
/**
 * Compile one arithmetic operation COLOR&ALPHA pair into TGSI instructions.
 */
static void
compile_instruction(struct st_translate *t,
                    const struct atifs_instruction *inst)
{
   unsigned optype;

   for (optype = 0; optype < 2; optype++) { /* color, alpha */
      const struct instruction_desc *desc;
      struct ureg_dst dst[1];
      struct ureg_src args[3]; /* arguments for the main operation */
      unsigned arg;
      unsigned dstreg = inst->DstReg[optype].Index - GL_REG_0_ATI;

      if (!inst->Opcode[optype])
         continue;

      desc = &inst_desc[inst->Opcode[optype] - GL_MOV_ATI];

      /* prepare the arguments */
      for (arg = 0; arg < desc->arg_count; arg++) {
         if (arg >= inst->ArgCount[optype]) {
            _mesa_warning(0, "Using 0 for missing argument %d of %s\n",
                          arg, desc->name);
            args[arg] = ureg_imm1f(t->ureg, 0.0f);
         } else {
            args[arg] = prepare_argument(t, arg,
                                         &inst->SrcReg[optype][arg]);
         }
      }

      /* prepare dst */
      dst[0] = get_temp(t, dstreg);

      if (optype) {
         dst[0] = ureg_writemask(dst[0], TGSI_WRITEMASK_W);
      } else {
         GLuint dstMask = inst->DstReg[optype].dstMask;
         if (dstMask == GL_NONE) {
            dst[0] = ureg_writemask(dst[0], TGSI_WRITEMASK_XYZ);
         } else {
            dst[0] = ureg_writemask(dst[0], dstMask); /* the enum values match */
         }
      }

      /* emit the main instruction */
      emit_arith_inst(t, desc, dst, args, arg);

      emit_dstmod(t, *dst, inst->DstReg[optype].dstMod);

      t->regs_written[t->current_pass][dstreg] = true;
   }
}
Exemplo n.º 25
0
// Check whether we should be sounding the alarm
void alarm_check() {
	int master_temp1 = get_temp(1);
	int master_temp2 = get_temp(2);
	//APP_LOG(APP_LOG_LEVEL_DEBUG, "check 1 %d < %d < %d", alarm_1_lower_setpoint, master_temp1, alarm_1_upper_setpoint);
	
	bool alarm_temp1_upper = master_temp1 > pass_upper(alarm_1_upper_setpoint);
	bool alarm_temp1_lower = master_temp1 < alarm_1_lower_setpoint;
	bool alarm_temp2_upper = master_temp2 > pass_upper(alarm_2_upper_setpoint);
	bool alarm_temp2_lower = master_temp2 < alarm_2_lower_setpoint;

	set_flash_temp(1, alarm_temp1_upper, alarm_temp1_lower);
	set_flash_temp(2, alarm_temp2_upper, alarm_temp2_lower);
	
	bool alarming = alarm_temp1_upper || alarm_temp1_lower || alarm_temp2_upper || alarm_temp2_lower;
	if (alarming) {
		APP_LOG(APP_LOG_LEVEL_DEBUG, "alarming %p %d %d", alarm_timer, (int) time(NULL), (int) last_alarm_silence);		
		if (!alarm_timer && time(NULL) > (last_alarm_silence + 60)) 
			alarm_buzz(NULL);
	} else {
		alarm_silence();
	}
}
Exemplo n.º 26
0
//{{{ int main(int argc,char** argv)
int main(int argc,char** argv)
{
	//get_config();
	format_msg(0);//初次运行时获取天气
	get_batt();// 初次运行时获取电量
	get_cpu();//cpu
	get_mem();//mem
	get_net();//net
	get_temp();//temperature
	get_mailchk();//2014-4-2添加,邮件检查的显示。
	disp_msg();
	exit(0);
}//}}}
Exemplo n.º 27
0
static void gen_inst(CTX *ctx, struct ir_inst *in)
{
    struct ir_type res_t = in->result_type;
    bool is_void = type_is_void(res_t);
    // Don't write anything not needed. Note that void values are never actually
    // "used" by the generated C code, and instead are replaced with VOID_VAL.
    if (!ir_op_writes_side_effects(in->op) && !ir_op_is_branch(in->op)) {
        if (is_void)
            return;
        if (in->users_count == 0)
            return;
        // If it has 1 use, it can be generated inline.
        if (write_inline && in->users_count == 1) {
            // But if it crosses side effects, it must be generated earlier.
            // NOTE: if there are any not yet generated instructions with read
            //       side-effects, we must generate the code before crossing
            //       write side-effects as well.
            // Consider: t1=read; t2=neg(t1); call a(); call b(t2);
            // Mustn't turn into: call a(); call b(neg(read));
            bool crosses_sideffects = false;
            if (has_outstanding_sideffect_reads(in)) {
                struct ir_inst *user= in->users[0];
                for (struct ir_inst *cur = in; cur; cur = cur->next) {
                    if (cur == user)
                        break;
                    if (ir_op_writes_side_effects(cur->op)) {
                        crosses_sideffects = true;
                        break;
                    }
                }
            }
            if (!crosses_sideffects)
                return;
        }
    }

    set_loc(ctx, in->loc);
    indent(ctx);
    if (!TEST_UNION0(IR_TYPE, any, &res_t) && !is_void && in->users_count > 0)
    {
        if (in->scratch1_i == -1)
            in->scratch1_i = ctx->reg++;
        P(ctx, "%s %s = ", type(ctx, res_t), get_temp(ctx, in->scratch1_i));
    }

    write_inst(ctx, in, false);

    fprintf(ctx->f, ";\n");

    talloc_free_children(ctx->tmp);
}
Exemplo n.º 28
0
static void print_temps(
		const char *name,
		const int tmp432_temp_reg,
		const int tmp432_therm_limit_reg,
		const int tmp432_high_limit_reg,
		const int tmp432_low_limit_reg)
{
	int value;

	ccprintf("%s:\n", name);

	if (get_temp(tmp432_temp_reg, &value) == EC_SUCCESS)
		ccprintf("  Temp       %3dC\n", value);

	if (get_temp(tmp432_therm_limit_reg, &value) == EC_SUCCESS)
		ccprintf("  Therm Trip %3dC\n", value);

	if (get_temp(tmp432_high_limit_reg, &value) == EC_SUCCESS)
		ccprintf("  High Alarm %3dC\n", value);

	if (get_temp(tmp432_low_limit_reg, &value) == EC_SUCCESS)
		ccprintf("  Low Alarm  %3dC\n", value);
}
int CoolingDuct::set_freezer_temp(int new_temp)
{
    while( (new_temp>current_temp)||(new_temp<current_temp))
    {
        diff_temp=current_temp-new_temp;
           // compressor.fridge_valve(open_close_valve +(diff_temp));
        degree_of_valve_opening_freezer=compressor.freezer_valve(diff_temp);
        //TODOdegree_of_valve_opening_freezer=compressor.valve_change(diff_temp);

        for (int i=0;i<FIXED_TIME_DELAY;i++){;}//when temp equalizes back
            temp_after_valve_change=get_temp();

    }
}
expr_rec gen_infix(expr_rec e1, op_rec op, expr_rec e2)
{
	expr_rec e_rec;
	/*An expr_rec with temp variant set.*/
	e_rec.kind = TEMPEXPR;
	/*Generate code for infix operation.
		Get result temp and set up semantic record for result*/
	strcpy(e_rec.name,get_temp());
	char uno[33];
	strcpy(uno,extract2(e2));

    generate(extract(op), extract2(e1),uno, e_rec.name);
	return e_rec;
}