• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ LED_On函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main

/** \brief Proximity sensor threshold calibration application
 *
 * This application illustrates the use of the sensor_calibrate() function
 * to set the proximity detection thresholds in a 3-channel proximity sensor.
 * This threshold is the level at which the sensor will report that an object
 * is near the device.
 *
 * The calibration sequence requires three steps, one for each channel.  During
 * each step, an object is placed at the desired distance in front of the
 * sensor, and the user presses the button on the board to trigger a proximity
 * reading.
 *
 * After Step 3 is completed, the threshold values for the sensor are
 * calculated and are written to non-volatile (flash) memory on the
 * microcontroller.  These values will continue to be used for future
 * proximity readings, unless they are overwritten by an application
 * calling the sensor_set_threshold function for the proximity sensor
 * channel(s).
 */
int main(void)
{
	sensor_t prox_dev;           /* Proximity sensor device */
	sensor_data_t prox_data;     /* Proximity data */
	int led_num = 0;

	/* Initialize the board (Xplained UC3 or XMEGA & Xplained Sensor boards)
	 * I/O pin mappings and any other configurable resources selected in
	 * the build configuration.
	 */
	sensor_platform_init();

	LED_On(ALL_LEDS);

	/* Wait for user to press button to start */
	prompt_user("Press button to start");
	
	/* Attach descriptor and initialize the proximity sensor */
	sensor_attach(&prox_dev, SENSOR_TYPE_PROXIMITY, 0, 0);

#if (SET_PROX_CURRENT == true)
	/* Manually set LED current value for each channel */
	/* Otherwise, sensor will use default values */
	sensor_set_channel(&prox_dev, SENSOR_CHANNEL_ALL);
	sensor_set_current(&prox_dev, PROX_CURRENT_mA);
#endif

	/* Set sensor data output formats (for display after calibration
	 * complete) */
	prox_data.scaled = true;
	
	/* Perform calibration sequence */

	/* Step 1 */
	printf("Setting channel 1: ");
	prompt_user("Place object at desired distance and press button");
	(void)sensor_calibrate(&prox_dev, MANUAL_CALIBRATE, 1, NULL);

	/* Step 2 */
	printf("Setting channel 2: ");
	prompt_user("Place object at desired distance and press button");
	(void)sensor_calibrate(&prox_dev, MANUAL_CALIBRATE, 2, NULL);

	/* Step 3 */
	printf("Setting channel 3: ");
	prompt_user("Place object at desired distance and press button");
	if (sensor_calibrate(&prox_dev, MANUAL_CALIBRATE, 3, NULL) != true) {
		if (prox_dev.err == SENSOR_ERR_IO) {
			printf("Calibration failure: write error\n\r");
		} else {
			printf("Unknown error while calibrating device\n\r");
		}

		while (true) {
			/* Error occurred, loop forever */
		}
	}

	int16_t value;

	/* Display threshold values */
	sensor_set_channel(&prox_dev, 1);
	sensor_get_threshold(&prox_dev, SENSOR_THRESHOLD_NEAR_PROXIMITY,
			&value);
	printf("Channel 1 threshold = %d\r\n", value);

	sensor_set_channel(&prox_dev, 2);
	sensor_get_threshold(&prox_dev, SENSOR_THRESHOLD_NEAR_PROXIMITY,
			&value);
	printf("Channel 2 threshold = %d\r\n", value);

	sensor_set_channel(&prox_dev, 3);
	sensor_get_threshold(&prox_dev, SENSOR_THRESHOLD_NEAR_PROXIMITY,
			&value);
	printf("Channel 3 threshold = %d\r\n", value);

	/* Once the calibration is complete, the proximity status is
	 * continuously captured and displayed.
	 */

	while (true) {
//.........这里部分代码省略.........
开发者ID:ThucVD2704,项目名称:femto-usb-blink-example,代码行数:101,代码来源:main.c


示例2: ui_start_read

void ui_start_read(void)
{
	LED_On(LED1_GPIO);
}
开发者ID:Timvrakas,项目名称:samd21_gcc,代码行数:4,代码来源:ui.c


示例3: ui_init

void ui_init(void)
{
	LED_On(LED0_GPIO);
	LED_Off(LED1_GPIO);
	LED_Off(LED2_GPIO);
}
开发者ID:InSoonPark,项目名称:asf,代码行数:6,代码来源:ui.c


示例4: ui_init

void ui_init(void)
{
	LED_On(LED0);
	LED_Off(LED1);
}
开发者ID:jrsmile,项目名称:usbcdemu,代码行数:5,代码来源:ui.c


示例5: ui_start_write

void ui_start_write(void)
{
	LED_On(LED2);
}
开发者ID:jrsmile,项目名称:usbcdemu,代码行数:4,代码来源:ui.c


示例6: ui_wakeup

void ui_wakeup(void)
{
	LED_On(LED_0_PIN);
}
开发者ID:AndreyMostovov,项目名称:asf,代码行数:4,代码来源:ui.c


示例7: ui_com_tx_start

void ui_com_tx_start(void)
{
	LED_On(LED2_GPIO);
}
开发者ID:Gr3yR0n1n,项目名称:SAINTCON-2015-Badge,代码行数:4,代码来源:ui.c


示例8: ui_wakeup

void ui_wakeup(void)
{
	LED_On();
}
开发者ID:Dewb,项目名称:mod,代码行数:4,代码来源:ui.c


示例9: ui_com_overflow

void ui_com_overflow(void)
{
	LED_On(LED_BI1_RED);
}
开发者ID:kerichsen,项目名称:asf,代码行数:4,代码来源:ui.c


示例10: ui_com_open

void ui_com_open(uint8_t port)
{
	UNUSED(port);
	LED_On(LED1_GPIO);
}
开发者ID:Gr3yR0n1n,项目名称:SAINTCON-2015-Badge,代码行数:5,代码来源:ui.c


示例11: ui_com_error

void ui_com_error(void)
{
	LED_On(LED_BI0_RED);
}
开发者ID:kerichsen,项目名称:asf,代码行数:4,代码来源:ui.c


示例12: ui_com_tx_start

void ui_com_tx_start(void)
{
	LED_On(LED_BI1_GREEN);
}
开发者ID:kerichsen,项目名称:asf,代码行数:4,代码来源:ui.c


示例13: ui_com_rx_start

void ui_com_rx_start(void)
{
	LED_On(LED_BI0_GREEN);
}
开发者ID:kerichsen,项目名称:asf,代码行数:4,代码来源:ui.c


示例14: ui_wakeup

void ui_wakeup(void)
{
	LED_On(LED0);
}
开发者ID:Manchen08,项目名称:SAINTCON-2015-Badge,代码行数:4,代码来源:ui.c


示例15: main


//.........这里部分代码省略.........
			wdt_set_timeout_period(WDT_TIMEOUT_PERIOD_64KCLK);
			wdt_enable(SYSTEM_RESET_MODE);
			if (wdt_get_timeout_period() !=
					WDT_TIMEOUT_PERIOD_64KCLK) {
				state_flag = ERROR_STATE;
				break;
			}

			for (delay_counter = 0; delay_counter < 8;
					delay_counter++) {
				/* Wait for 8x 250 ms = 2 s. */
				delay = 250;
				delay_ms(delay);
				wdt_reset();
			}
			wdt_disable();
			state_flag = WDT_RST;
			break;

		case WDT_RST:
			state_flag = WDT_INTERRUPT;
			/* Enable WDT 2 s. */
			wdt_set_timeout_period(WDT_TIMEOUT_PERIOD_256KCLK);
			wdt_enable(SYSTEM_RESET_MODE);
			if (wdt_get_timeout_period() !=
					WDT_TIMEOUT_PERIOD_256KCLK) {
				state_flag = ERROR_STATE;
				break;
			}

			while (true) {
				/* Wait for Watchdog reset. */
			}
		/* No break is needed */

		case WDT_INTERRUPT:
			/* Enable WDT 250 ms. */
			wdt_set_timeout_period(WDT_TIMEOUT_PERIOD_32KCLK);
			wdt_set_interrupt_callback(wdt_timer_callback);
			wdt_enable(INTERRUPT_MODE);
			if (wdt_get_timeout_period() !=
					WDT_TIMEOUT_PERIOD_32KCLK) {
				state_flag = ERROR_STATE;
				break;
			}

			cpu_irq_enable();
			/* Wait for interrupt to get triggered */
			delay = 400;
			delay_ms(delay);
			wdt_disable();
			break;

		case WDT_RST_INTERRUPT:

			/* Enable WDT 125 ms. */
			wdt_set_timeout_period(WDT_TIMEOUT_PERIOD_16KCLK);
			wdt_set_interrupt_callback(wdt_timer_callback);
			wdt_enable(INTERRUPT_SYSTEM_RESET_MODE);
			if (wdt_get_timeout_period() !=
					WDT_TIMEOUT_PERIOD_16KCLK) {
				state_flag = ERROR_STATE;
				break;
			}

			/* Wait for 200 ms. */
			delay = 200;
			delay_ms(delay);
			wdt_reset();
			while (true) {
				/* Wait for Watchdog reset. */
			}
		/* No break is needed */

		case ERROR_STATE:

			wdt_disable();

			while (true) {
				LED_On(LED_PIN);
				/* Wait for 500 ms. */
				delay = 500;
				delay_ms(delay);
				/* Blinking. */
				LED_Off(LED_PIN);
				/* Wait for 500 ms. */
				delay = 500;
				delay_ms(delay);
			}
		/* No break is needed */

		case END_OF_PROG:
		default:
			LED_On(LED_PIN);
			while (true) {
			}
			/* No break is needed */
		}
	}
}
开发者ID:thegeek82000,项目名称:asf,代码行数:101,代码来源:wdt_example.c


示例16: ui_process

void ui_process(uint16_t framenumber)
{
	bool b_btn_state, sucess;
	static bool btn_last_state = false;
	static bool sequence_running = false;
	static uint8_t u8_sequence_pos = 0;
	uint8_t u8_value;
	static uint16_t cpt_sof = 0;

	if ((framenumber % 1000) == 0) {
		LED_On(LED0_GPIO);
	}
	if ((framenumber % 1000) == 500) {
		LED_Off(LED0_GPIO);
	}
	// Scan process running each 2ms
	cpt_sof++;
	if ((cpt_sof % 2) == 0) {
		return;
	}

	// Scan buttons on switch 0 to send keys sequence
	b_btn_state = (!gpio_pin_is_high(GPIO_PUSH_BUTTON_1)) ? true : false;
	if (b_btn_state != btn_last_state) {
		btn_last_state = b_btn_state;
		sequence_running = true;
	}

	// Sequence process running each period
	if (SEQUENCE_PERIOD > cpt_sof) {
		return;
	}
	cpt_sof = 0;

	if (sequence_running) {
		// Send next key
		u8_value = ui_sequence[u8_sequence_pos].u8_value;
		if (u8_value!=0) {
			if (ui_sequence[u8_sequence_pos].b_modifier) {
				if (ui_sequence[u8_sequence_pos].b_down) {
					sucess = udi_hid_kbd_modifier_down(u8_value);
				} else {
					sucess = udi_hid_kbd_modifier_up(u8_value);
				}
			} else {
				if (ui_sequence[u8_sequence_pos].b_down) {
					sucess = udi_hid_kbd_down(u8_value);
				} else {
					sucess = udi_hid_kbd_up(u8_value);
				}
			}
			if (!sucess) {
				return; // Retry it on next schedule
			}
		}
		// Valid sequence position
		u8_sequence_pos++;
		if (u8_sequence_pos >=
			sizeof(ui_sequence) / sizeof(ui_sequence[0])) {
			u8_sequence_pos = 0;
			sequence_running = false;
		}
	}
}
开发者ID:marekr,项目名称:asf,代码行数:64,代码来源:ui.c


示例17: ui_device_sof_action

void ui_device_sof_action(void)
{
	uint16_t framenumber;
	static uint8_t cpt_sof = 0;
	static int32_t move_count = MOUSE_MOVE_COUNT;
	static uint8_t move_dir = MOVE_UP;

	if (!ui_device_b_mouse_enable) {
		return;
	}

	framenumber = udd_get_frame_number();
	if ((framenumber % 1000) == 0) {
		LED_On(LED0);
	}

	if ((framenumber % 1000) == 500) {
		LED_Off(LED0);
	}

	/* Scan process running each 2ms */
	cpt_sof++;
	if (2 > cpt_sof) {
		return;
	}

	cpt_sof = 0;

	/* Uses buttons to move mouse */
	if (!ioport_get_pin_level(GPIO_PUSH_BUTTON_0)) {
		move_count--;
		switch (move_dir) {
		case MOVE_UP:
			udi_hid_mouse_moveY(-MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_RIGHT;
				move_count = MOUSE_MOVE_COUNT;
			}

			break;

		case MOVE_RIGHT:
			udi_hid_mouse_moveX(+MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_DOWN;
				move_count = MOUSE_MOVE_COUNT;
			}

			break;

		case MOVE_DOWN:
			udi_hid_mouse_moveY(+MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_LEFT;
				move_count = MOUSE_MOVE_COUNT;
			}

			break;

		case MOVE_LEFT:
			udi_hid_mouse_moveX(-MOUSE_MOVE_RANGE);
			if (move_count < 0) {
				move_dir = MOVE_UP;
				move_count = MOUSE_MOVE_COUNT;
			}

			break;
		}
	}
}
开发者ID:AndreyMostovov,项目名称:asf,代码行数:70,代码来源:ui.c


示例18: ui_init

void ui_init(void)
{
	/* Initialize LEDs */
	LED_On(LED_0_PIN);
}
开发者ID:AndreyMostovov,项目名称:asf,代码行数:5,代码来源:ui.c


示例19: ui_com_tx_start

void ui_com_tx_start(void)
{
    ui_data_transfer = true;
    LED_On(LED_0_PIN);
}
开发者ID:ThucVD2704,项目名称:femto-usb-blink-example,代码行数:5,代码来源:ui.c


示例20: main

/**
 * \brief Example application entry routine
 */
int main(void)
{
	/* The sensor_platform_init() function will initialize the system
	 * clock and sensor bus support in addition to configuring the
	 * XMEGA-A3BU and Sensor Xplained boards.
	 *
	 * Use gfx_mono_init() to initialize the monochrome graphical system
	 * API then write a splash screen after enabling the LCD display
	 * backlight and setting the contrast.
	 *
	 * The MCU is going to be put in a sleep mode, so initialize the
	 * sleep manager API with a call to the sleepmgr_init() routine.
	 */
	sensor_platform_init();
	gfx_mono_init();
	sleepmgr_init();

	gpio_set_pin_high(NHD_C12832A1Z_BACKLIGHT);
	st7565r_set_contrast(ST7565R_DISPLAY_CONTRAST_MIN);

	/* Attach an accelerometer on a Sensors Xplained board. */
	sensor_t accelerometer;
	sensor_attach(&accelerometer, SENSOR_TYPE_ACCELEROMETER, 0, 0);

	/* Enable the accelerometer low-g (free fall) event. */
	sensor_enable_event(&accelerometer, SENSOR_EVENT_LOW_G);

	/* Set the free fall threshold (low-g event), bandwidth and range. */
	sensor_set_threshold(&accelerometer, SENSOR_THRESHOLD_LOW_G,
			LOW_G_THRESHOLD);
	sensor_set_bandwidth(&accelerometer, BANDWIDTH);
	sensor_set_range(&accelerometer, RANGE);

	while (true) {
		/* Put the accelerometer into a low-power mode (if available). */
		sensor_set_state(&accelerometer, SENSOR_STATE_LOW_POWER);

		LED_Off(ACCEL_LED);

		clear_screen();

		/* Display the "armed" message and put the MCU in sleep mode. */
		gfx_mono_draw_string("ATMEL Drop Demo\r\nXMEGA Powered Down\r\n"
				"g Sensor Armed", 1, 5, &sysfont);

		sleepmgr_lock_mode(SLEEP_MODE);
		sleepmgr_enter_sleep();

		/* The following runs after the MCU has been woken by an
		 * external low-g interrupt from the accelerometer.
		 *
		 * Turn on the red LED while falling and put the accelerometer
		 * into a high-power mode (if available) to sample date points.
		 */
		LED_On(ACCEL_LED);

		sensor_set_state(&accelerometer, SENSOR_STATE_HIGHEST_POWER);

		static scalar_t acceleration_waveform[DATA_SAMPLE_COUNT];
		scalar_t acceleration_max = 0;

		for (int data_count = 0; data_count < DATA_SAMPLE_COUNT;
				++data_count) {
			acceleration_waveform[data_count] = 0;

			for (int i = 0; i < SAMPLE_AVG_COUNT; ++i) {
				/* Calculate the gravity vector magnitude. */
				vector3_t gvec;
				sensor_get_vector(&accelerometer, &gvec);

				scalar_t const acceleration_magnitude
					= vector3_magnitude(&gvec);

				/* Store the maximum g magnitude for this
				 * sub-group. */
				if (acceleration_magnitude >
						acceleration_waveform[data_count]) {
					acceleration_waveform[data_count]
						= acceleration_magnitude;
				}

				/* Store the maximum g magnitude for the whole
				 * data set. */
				if (acceleration_magnitude > acceleration_max) {
					acceleration_max = acceleration_magnitude;
				}
			}
		}

		clear_screen();

		/* Turn the max acceleration into a string and convert to g. */
		static char max_g_string[20];

		if (acceleration_max > LOW_G_SATURATION) {
			sprintf(max_g_string, "g Sensor Saturated");
		} else {
//.........这里部分代码省略.........
开发者ID:InSoonPark,项目名称:asf,代码行数:101,代码来源:drop_detector.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ LED_TOGGLE函数代码示例发布时间:2022-05-30
下一篇:
C++ LED_Off函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap