本文整理汇总了C++中LED_On函数的典型用法代码示例。如果您正苦于以下问题:C++ LED_On函数的具体用法?C++ LED_On怎么用?C++ LED_On使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LED_On函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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) {
//.........这里部分代码省略.........
示例2: ui_start_read
void ui_start_read(void)
{
LED_On(LED1_GPIO);
}
示例3: ui_init
void ui_init(void)
{
LED_On(LED0_GPIO);
LED_Off(LED1_GPIO);
LED_Off(LED2_GPIO);
}
示例4: ui_init
void ui_init(void)
{
LED_On(LED0);
LED_Off(LED1);
}
示例5: ui_start_write
void ui_start_write(void)
{
LED_On(LED2);
}
示例6: ui_wakeup
void ui_wakeup(void)
{
LED_On(LED_0_PIN);
}
示例7: ui_com_tx_start
void ui_com_tx_start(void)
{
LED_On(LED2_GPIO);
}
示例9: ui_com_overflow
void ui_com_overflow(void)
{
LED_On(LED_BI1_RED);
}
示例10: ui_com_open
void ui_com_open(uint8_t port)
{
UNUSED(port);
LED_On(LED1_GPIO);
}
示例11: ui_com_error
void ui_com_error(void)
{
LED_On(LED_BI0_RED);
}
示例12: ui_com_tx_start
void ui_com_tx_start(void)
{
LED_On(LED_BI1_GREEN);
}
示例13: ui_com_rx_start
void ui_com_rx_start(void)
{
LED_On(LED_BI0_GREEN);
}
示例14: ui_wakeup
void ui_wakeup(void)
{
LED_On(LED0);
}
示例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 */
}
}
}