当前位置: 首页>>代码示例>>C++>>正文


C++ SENSORS_ACTIVATE函数代码示例

本文整理汇总了C++中SENSORS_ACTIVATE函数的典型用法代码示例。如果您正苦于以下问题:C++ SENSORS_ACTIVATE函数的具体用法?C++ SENSORS_ACTIVATE怎么用?C++ SENSORS_ACTIVATE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SENSORS_ACTIVATE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PROCESS_THREAD

PROCESS_THREAD(flexibity_buzzer, ev, data)
{
  PROCESS_BEGIN();
  SENSORS_ACTIVATE(button_sensor);
  SENSORS_ACTIVATE(battery_sensor);

  /* PWM for buzzer */
  pwm_init_stopped(TMR3, 1500, 10000);

#ifdef WITH_COAP
  PRINTF("COAP Server\n");
#else
  PRINTF("HTTP Server\n");
#endif

  rest_init();

#if DEBUG
  rest_activate_resource(&resource_mem);
#endif
  rest_activate_resource(&resource_buzzer);
  rest_activate_resource(&resource_pwr);
  rest_activate_resource(&resource_led);
  rest_activate_resource(&resource_button);
  rest_activate_resource(&resource_id);
  rest_activate_resource(&resource_discover);

  PROCESS_END();
}
开发者ID:Flexibity,项目名称:contiki,代码行数:29,代码来源:buzzer.c

示例2: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(shell_sense_process, ev, data)
{
    struct sense_msg msg;
    PROCESS_BEGIN();

    SENSORS_ACTIVATE(light_sensor);
    SENSORS_ACTIVATE(battery_sensor);
    SENSORS_ACTIVATE(sht11_sensor);

    msg.len = 7;
    msg.clock = clock_time();
#if TIMESYNCH_CONF_ENABLED
    msg.timesynch_time = timesynch_time();
#else /* TIMESYNCH_CONF_ENABLED */
    msg.timesynch_time = 0;
#endif /* TIMESYNCH_CONF_ENABLED */
    msg.light1 = light_sensor.value(LIGHT_SENSOR_PHOTOSYNTHETIC);
    msg.light2 = light_sensor.value(LIGHT_SENSOR_TOTAL_SOLAR);
    msg.temp = sht11_sensor.value(SHT11_SENSOR_TEMP);
    msg.humidity = sht11_sensor.value(SHT11_SENSOR_HUMIDITY);
    msg.rssi = do_rssi();
    msg.voltage = battery_sensor.value(0);

    msg.rssi = do_rssi();

    SENSORS_DEACTIVATE(light_sensor);
    SENSORS_DEACTIVATE(battery_sensor);
    SENSORS_DEACTIVATE(sht11_sensor);

    shell_output(&sense_command, &msg, sizeof(msg), "", 0);
    PROCESS_END();
}
开发者ID:Veldmonster,项目名称:contiki-mirror,代码行数:33,代码来源:shell-sky.c

示例3: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
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();
}
开发者ID:Ayesha-N,项目名称:6lbr,代码行数:27,代码来源:sky-websense.c

示例4: PROCESS_THREAD

PROCESS_THREAD(default_app_process, ev, data)
{
  PROCESS_BEGIN();

  SENSORS_ACTIVATE(acc_sensor);
  SENSORS_ACTIVATE(gyro_sensor);
  SENSORS_ACTIVATE(pressure_sensor);

  etimer_set(&timer, CLOCK_SECOND * 0.05);
  while (1) {

    PROCESS_YIELD();
    etimer_set(&timer, CLOCK_SECOND);
    printf("X_ACC=%d, Y_ACC=%d, Z_ACC=%d\n",
            acc_sensor.value(ACC_X),
            acc_sensor.value(ACC_Y),
            acc_sensor.value(ACC_Z));
    printf("X_AS=%d, Y_AS=%d, Z_AS=%d\n",
            gyro_sensor.value(X_AS),
            gyro_sensor.value(Y_AS),
            gyro_sensor.value(Z_AS));
//    printf("PRESS=%u, TEMP=%d\n\n", pressure_sensor.value(PRESS), pressure_sensor.value(TEMP));

  }

  PROCESS_END();
}
开发者ID:DrMcCoy,项目名称:contiki-inga,代码行数:27,代码来源:sensor_demo.c

示例5: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(test_button_process, ev, data)
{
  /* static struct etimer et; */
  PROCESS_BEGIN();
  SENSORS_ACTIVATE(phidgets);
  SENSORS_ACTIVATE(button_sensor);

  while(1) {
    printf("Please press the User Button\n");

    PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event &&
                             data == &button_sensor);

    leds_toggle(LEDS_GREEN);

    printf("Phidget 5V 1:%d\n", phidgets.value(PHIDGET5V_1));
    printf("Phidget 5V 2:%d\n", phidgets.value(PHIDGET5V_2));
    printf("Phidget 3V 1:%d\n", phidgets.value(PHIDGET3V_1));
    printf("Phidget 3V 2:%d\n", phidgets.value(PHIDGET3V_2));

    if(phidgets.value(PHIDGET3V_1) < 100) {
      leds_on(LEDS_RED);
    } else {
      leds_off(LEDS_RED);
    }
  }
  PROCESS_END();
}
开发者ID:13416795,项目名称:contiki,代码行数:29,代码来源:test-phidgets.c

示例6: PROCESS_THREAD

PROCESS_THREAD(udp_plug_process, ev, data)
{
	static struct etimer et;
	PROCESS_BEGIN();

	
  
	PRINTF("UDP server started\r\n");
	
#if DEV_BOARD  
	leds_on(LEDS_RED | LEDS_GREEN);
	SENSORS_ACTIVATE(button_sensor);
#else
	leds_on(LEDS_GREEN);
	#ifdef HAS_PIR_SENSOR
		pir_state = PIR_DISPATCH;
		etimer_set(&pir_timer, PIR_INIT_TIME);
	#endif
#endif

#if HAS_TEMP_SENSOR
	start_temp_conv();
#endif

#if HAS_LIGHT_SENSOR
	light_sensor_init();
#endif

	udp_conn = udp_new(NULL, UIP_HTONS(0), NULL);
	udp_bind(udp_conn, UIP_HTONS(PLUG_PORT));
	PRINTF("listening on udp port %u\r\n",UIP_HTONS(udp_conn->lport));
	etimer_set(&et, SEND_INTERVAL);
	while(1) {
		PROCESS_YIELD();
		if(etimer_expired(&et)) {
			timeout_handler();
			etimer_restart(&et);

		}
#ifdef HAS_PIR_SENSOR		
		if((pir_state == PIR_DISPATCH)&&(etimer_expired(&pir_timer))) {
			SENSORS_ACTIVATE(button_sensor);
			pir_state = PIR_READY;
		}
#endif		
		if(ev == tcpip_event) {
			PRINTF("Calling tcpip_Handler\r\n");
			tcpip_handler();
		}
		
		if (ev == sensors_event && data == &button_sensor) {
#ifndef DEV_BOARD  
			handle_pir_event();
#endif
			PRINTF("Button Pressed\r\n");
		}
	}

  PROCESS_END();
}
开发者ID:bearxiong99,项目名称:tdma_demo,代码行数:60,代码来源:udpPlug.c

示例7: PT_THREAD

static
PT_THREAD(sensorscall(struct httpd_state *s, char *ptr))
{
  static struct timer t;
  static int i;
  static char buf[100];
  static unsigned long last_cpu, last_lpm, last_listen, last_transmit;
  
  PSOCK_BEGIN(&s->sout);

  timer_set(&t, CLOCK_SECOND);
  i = 0;
  /*  while(1)*/ {
    /*    timer_restart(&t);
	  PSOCK_WAIT_UNTIL(&s->sout, timer_expired(&t));*/

#if CONTIKI_TARGET_SKY
    SENSORS_ACTIVATE(sht11_sensor);
    SENSORS_ACTIVATE(light_sensor);
    snprintf(buf, sizeof(buf),
	     "t(%d);h(%d);l1(%d);l2(%d);",
	     sht11_sensor.value(SHT11_SENSOR_TEMP),
	     sht11_sensor.value(SHT11_SENSOR_HUMIDITY),
             light_sensor.value(LIGHT_SENSOR_PHOTOSYNTHETIC),
             light_sensor.value(LIGHT_SENSOR_TOTAL_SOLAR));
    SENSORS_DEACTIVATE(sht11_sensor);
    SENSORS_DEACTIVATE(light_sensor);
#else /* CONTIKI_TARGET_SKY */
    snprintf(buf, sizeof(buf),
	     "t(%d);h(%d);l1(%d);l2(%d);",
	     0,
	     0,
	     0,
	     0);
#endif /* CONTIKI_TARGET_SKY */
    PSOCK_SEND_STR(&s->sout, buf);


    /*    timer_restart(&t);
	  PSOCK_WAIT_UNTIL(&s->sout, timer_expired(&t));*/
    snprintf(buf, sizeof(buf),
	     "p(%lu,%lu,%lu,%lu);i(%d);",
	     energest_type_time(ENERGEST_TYPE_CPU) - last_cpu,
	     energest_type_time(ENERGEST_TYPE_LPM) - last_lpm,
	     energest_type_time(ENERGEST_TYPE_TRANSMIT) - last_transmit,
	     energest_type_time(ENERGEST_TYPE_LISTEN) - last_listen,
	     i++);
    last_cpu = energest_type_time(ENERGEST_TYPE_CPU);
    last_lpm = energest_type_time(ENERGEST_TYPE_LPM);
    last_transmit = energest_type_time(ENERGEST_TYPE_TRANSMIT);
    last_listen = energest_type_time(ENERGEST_TYPE_LISTEN);
    PSOCK_SEND_STR(&s->sout, buf);

}
  PSOCK_END(&s->sout);
}
开发者ID:13416795,项目名称:contiki,代码行数:56,代码来源:ajax-cgi.c

示例8: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(http_example_process, ev, data)
{
  static struct etimer et;

  PROCESS_BEGIN();

  SENSORS_ACTIVATE(sht25);

  ubidots_init(&http_example_process, headers);

  while(1) {

    PROCESS_YIELD();

    if(ev == ubidots_event_established ||
       (ev == PROCESS_EVENT_TIMER && data == &et)) {
      leds_on(LEDS_GREEN);

      post_collection();

    } else if(ev == ubidots_event_post_sent) {
      leds_off(LEDS_GREEN);
      etimer_set(&et, POST_PERIOD);

    } // else if(ev == ubidots_event_post_reply_received) {
      // print_reply((ubidots_reply_part_t *)data);
    // }
  }

  PROCESS_END();
}
开发者ID:Ayesha-N,项目名称:6lbr,代码行数:32,代码来源:ubidots-client.c

示例9: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(acc_process, ev, data)
{
  static struct etimer etimer;
  
  PROCESS_BEGIN();
  
  printf("Starting measuring acceleration\r\n");
  boardPrintStringDescription();
  SENSORS_ACTIVATE(acc_sensor);
  
  // Enable High Range.
  //acc_sensor.configure(ACC_RANGE, ACC_HIGH_RANGE);
  
  // Enable High Pass Filter.
  //acc_sensor.configure(ACC_HPF, ACC_1HZ);


  while(1) {
    etimer_set(&etimer, CLOCK_SECOND/2);
    
    PROCESS_WAIT_UNTIL(etimer_expired(&etimer));
    
    printf("(X,Y,Z): (%d,%d,%d) mg      \r",acc_sensor.value(ACC_X_AXIS),acc_sensor.value(ACC_Y_AXIS),acc_sensor.value(ACC_Z_AXIS));
    
  }
  
  
  PROCESS_END();
}
开发者ID:13416795,项目名称:contiki,代码行数:30,代码来源:acc-example.c

示例10: PROCESS_THREAD

/*---------------------------------------------------------------------------*/
PROCESS_THREAD(udp_server_process, ev, data)
{

//  uint16_t ipaddr=(uint16_t) IP_TRANS128;
//#if UIP_CONF_ROUTER
  uip_ipaddr_t ipaddr;//=IP_TRANS128;
  uip_ip6addr(&ipaddr,0xfe80,0,0,0,0x2001,0x22ff,0xfe33,0x4455);
//#endif /* UIP_CONF_ROUTER */

  PROCESS_BEGIN();



  SENSORS_ACTIVATE(button_sensor);//activate button
  leds_init();
  leds_off(LEDS_ALL);
  simple_udp_register(&udp_connection, UDP_PORT, NULL, UDP_PORT, receiver);


  while(1) {
//	  printf("bla1");
   PROCESS_WAIT_EVENT_UNTIL(ev == sensors_event && data == &button_sensor);
  // PROCESS_YIELD();
   send_data(&ipaddr);
    
  }

  PROCESS_END();
}
开发者ID:johannesst,项目名称:aio-wsn,代码行数:30,代码来源:trans128.c

示例11: PROCESS_THREAD

PROCESS_THREAD(knot_controller_process, ev, data)
{
	static struct etimer clean;

	PROCESS_BEGIN();
	SENSORS_ACTIVATE(button_sensor);

	etimer_set(&clean,TIMER_INTERVAL);

	while (1){
    	PROCESS_WAIT_EVENT();
		if (ev == tcpip_event && uip_newdata()) {
			network_handler(ev, data);
		} else if ((ev == PROCESS_EVENT_TIMER)){
			if (data == &clean) {
				cleaner();
				etimer_set(&clean,TIMER_INTERVAL);
			}
		} 
		else if (ev == KNOT_EVENT_CONNECT){
			create_channel((ServiceRecord *)data);
		}
		else if(ev == KNOT_EVENT_COMMAND){
			send_actuator_command(*((int *)data));
		}
		
	}

	PROCESS_END();

}
开发者ID:fergul,项目名称:KNoT,代码行数:31,代码来源:knot-controller.c

示例12: config_light

/* Light sensor */
static void config_light()
{
  light_sensor.configure(LIGHT_SENSOR_SOURCE, ISL29020_LIGHT__AMBIENT);
  light_sensor.configure(LIGHT_SENSOR_RESOLUTION, ISL29020_RESOLUTION__16bit);
  light_sensor.configure(LIGHT_SENSOR_RANGE, ISL29020_RANGE__1000lux);
  SENSORS_ACTIVATE(light_sensor);
}
开发者ID:Mariuspy,项目名称:contiki,代码行数:8,代码来源:sensors-collecting.c

示例13: config_gyr

static void config_gyr()
{
  gyr_sensor.configure(GYR_SENSOR_DATARATE, L3G4200D_800HZ);
  gyr_freq = 800;
  gyr_sensor.configure(GYR_SENSOR_SCALE, L3G4200D_250DPS);
  SENSORS_ACTIVATE(gyr_sensor);
}
开发者ID:Mariuspy,项目名称:contiki,代码行数:7,代码来源:sensors-collecting.c

示例14: PROCESS_THREAD

PROCESS_THREAD(rest_server_example, ev, data)
{
  PROCESS_BEGIN();
  PRINTF("Starting Erbium Example Server\n");
  PRINTF("uIP buffer: %u\n", UIP_BUFSIZE);
  PRINTF("LL header: %u\n", UIP_LLH_LEN);
  PRINTF("IP+UDP header: %u\n", UIP_IPUDPH_LEN);
  PRINTF("REST max chunk: %u\n", REST_MAX_CHUNK_SIZE);

/* if static routes are used rather than RPL */
#if !UIP_CONF_IPV6_RPL && !defined (CONTIKI_TARGET_MINIMAL_NET) && !defined (CONTIKI_TARGET_NATIVE)
  set_global_address();
  configure_routing();
#endif

  /* Initialize the OSD Hardware. */
  hw_init();
  /* Initialize the REST engine. */
  rest_init_engine();

  /* Activate the application-specific resources. */
  rest_activate_resource(&resource_info);

  SENSORS_ACTIVATE(t4_servo_sensor);
  rest_activate_resource(&resource_t4_servo);

  /* Define application-specific events here. */
  while(1) {
    PROCESS_WAIT_EVENT();
  }

  PROCESS_END();
}
开发者ID:osdomotics,项目名称:osd-contiki,代码行数:33,代码来源:er-example-server.c

示例15: PROCESS_THREAD

PROCESS_THREAD(temp_sensor_process, ev, data)
{

PROCESS_BEGIN();

static struct etimer et;
static uint64_t temperature;
static uint64_t val;
printf("starting Sensor Example\n");

while(1)
{
	etimer_set(&et,CLOCK_SECOND*3);
     	SENSORS_ACTIVATE(temp_sensor);

	PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));

temperature = (temp_sensor.value(TEMP_SENSOR));
printf("temperature is %lu\n",temperature);

etimer_reset(&et);
SENSORS_DEACTIVATE(temp_sensor);
}
PROCESS_END();

}
开发者ID:Ponnezhildass,项目名称:iot-school,代码行数:26,代码来源:test-temp.c


注:本文中的SENSORS_ACTIVATE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。