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


C++ GPIO_INPUT_GET函数代码示例

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


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

示例1: onewire_reset

// Perform the onewire reset function.  We will wait up to 250uS for
// the bus to come high, if it doesn't then it is broken or shorted
// and we return a 0;
// Returns 1 if a device asserted a presence pulse, 0 otherwise.
uint32 ICACHE_FLASH_ATTR onewire_reset() {
	uint32 result;
	uint8 retries = 125;

	// Disable output on the pin.
	GPIO_DIS_OUTPUT(ONEWIRE_PIN);

	// Wait for the bus to get high (which it should because of the pull-up resistor).
	do {
		if (--retries == 0) {
			return 0;
		}
		os_delay_us(2);
	} while (!GPIO_INPUT_GET(ONEWIRE_PIN));

	// Transmit the reset pulse by pulling the bus low for at least 480 us.
	GPIO_OUTPUT_SET(ONEWIRE_PIN, 0);
	os_delay_us(500);

	// Release the bus, and wait, then check for a presence pulse, which should start 15-60 us after the reset, and will last 60-240 us.
	// So 65us after the reset the bus must be high.
	GPIO_DIS_OUTPUT(ONEWIRE_PIN);
	os_delay_us(65);
	result = !GPIO_INPUT_GET(ONEWIRE_PIN);

	// After sending the reset pulse, the master (we) must wait at least another 480 us.
	os_delay_us(490);
	return result;
}
开发者ID:cranphin,项目名称:esp8266-dev,代码行数:33,代码来源:1wire.c

示例2: restoreFactorySettings

void restoreFactorySettings() {
	wifi_station_disconnect();
	wifi_set_opmode(0x3); //reset to STA+AP mode

	struct softap_config apConfig;
	wifi_softap_get_config(&apConfig);
	os_strncpy((char*)apConfig.ssid, "smartswitch", 18);
	apConfig.authmode = 0; //Disable security
	wifi_softap_set_config(&apConfig);

	struct station_config stconf;
	os_strncpy((char*)stconf.ssid, "", 2);
	os_strncpy((char*)stconf.password, "", 2);
	wifi_station_set_config(&stconf);

	OLED_CLS();
	OLED_Print(2, 0, "RESET", 1);
	os_printf("Reset completed. Restarting system...\n");

	ioOutput(0, GPIO_OUTPUT1);
	ioOutput(0, GPIO_OUTPUT2);

	while (!GPIO_INPUT_GET(GPIO_BUTTON1)) { os_printf("."); };
	while (!GPIO_INPUT_GET(GPIO_BUTTON2)) { os_printf("."); };

	system_restart();
}
开发者ID:MbedTinkerer,项目名称:ESP8266-relay-board-firmware,代码行数:27,代码来源:io.c

示例3: handle_pin_press

LOCAL void ICACHE_FLASH_ATTR handle_pin_press() {
console_printf("TIMER EXECUTED\n");
if(button_counter==1){
	if(!GPIO_INPUT_GET(PIN_GPIO13)){  // button is pressed once and is still pressed after the timeout
		MQTT_Publish(&mqttClient,BR_MODE,"2",1,0,0); // Set overall MODE to OFF
		GPIO_OUTPUT_SET(PIN_GPIO5, 0);
		MQTT_Publish(&mqttClient,PIN_GPIO5_TOPIC,"OFF",3,0,0);
		GPIO_OUTPUT_SET(PIN_GPIO12, 0);
		MQTT_Publish(&mqttClient,PIN_GPIO12_TOPIC,"OFF",3,0,0);
		GPIO_OUTPUT_SET(PIN_GPIO14, 0);
		MQTT_Publish(&mqttClient,PIN_GPIO14_TOPIC,"OFF",3,0,0);
		button_counter=0;
	}
}
	switch(button_counter){
	case 1:
		if(!GPIO_INPUT_GET(PIN_GPIO5)){
			console_printf("FAN STARTED BY BUTTON. Only 1 press detected\n");
			GPIO_OUTPUT_SET(PIN_GPIO5, 1);
			MQTT_Publish(&mqttClient,PIN_GPIO5_TOPIC,"ON",2,0,0);
			MQTT_Publish(&mqttClient,BR_MODE,"4",1,0,0);
		} else {
			console_printf("FAN STOPPED BY BUTTON. Only 1 press detected\n");
			GPIO_OUTPUT_SET(PIN_GPIO5, 0);
			MQTT_Publish(&mqttClient,PIN_GPIO5_TOPIC,"OFF",3,0,0);
		}
		break;
/*		GPIO_OUTPUT_SET(PIN_GPIO5, curr_input_pin_state);
		MQTT_Publish(&mqttClient,PIN_GPIO13_TOPIC,"ON",2,0,0);
		MQTT_Publish(&mqttClient,PIN_GPIO5_TOPIC,"ON",2,0,0);/**/
	case 2:
		if(!GPIO_INPUT_GET(PIN_GPIO14)){
			console_printf("BOILER STARTED BY BUTTON. 2 presses detected\n");
			GPIO_OUTPUT_SET(PIN_GPIO14, 1);
			MQTT_Publish(&mqttClient,PIN_GPIO14_TOPIC,"ON",2,0,0);
		} else {
			console_printf("BOILER STOPPED BY BUTTON. 2 presses detected\n");
			GPIO_OUTPUT_SET(PIN_GPIO14, 0);
			MQTT_Publish(&mqttClient,PIN_GPIO14_TOPIC,"OFF",3,0,0);
			MQTT_Publish(&mqttClient,BR_MODE,"2",1,0,0);
		}
		break;
/*	case 3:
		if(!GPIO_INPUT_GET(PIN_GPIO12)){
			console_printf("HEATING STARTED BY BUTTON. 3 presses detected\n");
			GPIO_OUTPUT_SET(PIN_GPIO12, 1);
			MQTT_Publish(&mqttClient,PIN_GPIO12_TOPIC,"OFF",3,0,0);
		} else {
			console_printf("HEATING STOPPED BY BUTTON. 3 presses detected\n");
			GPIO_OUTPUT_SET(PIN_GPIO12, 0);
			MQTT_Publish(&mqttClient,PIN_GPIO12_TOPIC,"OFF",3,0,0);
		}
		break;/**/
	}
	button_counter=0; // zero the counter
	os_timer_disarm(&input_pin_timer); // Disarm input pin timer
}
开发者ID:theater,项目名称:ESP8266,代码行数:57,代码来源:user_main.c

示例4: supla_esp_gpio_check_switch_cfgbtn

void
supla_esp_gpio_check_switch_cfgbtn(void *timer_arg) {

	char v = GPIO_INPUT_GET(GPIO_ID_PIN((int)timer_arg));

	if ( v != switch_cfgbtn_last_state ) {

		if ( switch_cfgbtn_counter == 0 ) {

			os_timer_disarm(&supla_gpio_timer5);
			os_timer_setfn(&supla_gpio_timer5, supla_esp_gpio_reset_cfg_counter, NULL);
			os_timer_arm (&supla_gpio_timer5, 10000, false);

		}

		switch_cfgbtn_counter++;

		supla_log(LOG_DEBUG, "Switch counter: %i", switch_cfgbtn_counter);

		if ( switch_cfgbtn_counter >= 10 ) {
			supla_esg_gpio_cfg_pressed();
		} else {
			supla_esg_gpio_manual_pressed();
		}

		switch_cfgbtn_last_state = v;
	}

	switch_cfgbtn_state_check = 0;

}
开发者ID:SUPLA,项目名称:supla-core,代码行数:31,代码来源:supla_esp_gpio.c

示例5: user_sensor_init

/******************************************************************************
 * FunctionName : user_sensor_init
 * Description  : init sensor function, include key and mvh3004
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void ICACHE_FLASH_ATTR user_sensor_init(uint8 active) {
    user_link_led_init();
    wifi_status_led_install(SENSOR_WIFI_LED_IO_NUM, SENSOR_WIFI_LED_IO_MUX, SENSOR_WIFI_LED_IO_FUNC);

    if (wifi_get_opmode() != SOFTAP_MODE) {
        single_key[0] = key_init_single(SENSOR_KEY_IO_NUM, SENSOR_KEY_IO_MUX, SENSOR_KEY_IO_FUNC,
                                        user_sensor_long_press, NULL);

        keys.key_num = SENSOR_KEY_NUM;
        keys.single_key = single_key;
        key_init(&keys);

        if (GPIO_INPUT_GET(GPIO_ID_PIN(SENSOR_KEY_IO_NUM)) == 0) {
            user_sensor_long_press();
        }
    }

    if (wifi_get_opmode() != STATIONAP_MODE) {
        if (active == 1) {
            user_sensor_deep_sleep_init(SENSOR_CONNECT_TIME / 1000);//exceed SENSOR_CONNECT_TIME,sleep directly
        } else {
        user_sensor_deep_sleep_init(SENSOR_CONNECT_TIME / 1000);//exceed SENSOR_CONNECT_TIME,sleep directly
        }
    }
}
开发者ID:ClarePhang,项目名称:low_power_voltage_measurement,代码行数:31,代码来源:user_sensor.c

示例6: platform_gpio_intr_dispatcher

static void ICACHE_RAM_ATTR platform_gpio_intr_dispatcher (void *dummy){
  uint32 j=0;
  uint32 gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);
  uint32 now = system_get_time();
  UNUSED(dummy);

#ifdef GPIO_INTERRUPT_HOOK_ENABLE
  if (gpio_status & platform_gpio_hook.all_bits) {
    for (j = 0; j < platform_gpio_hook.count; j++) {
       if (gpio_status & platform_gpio_hook.entry[j].bits)
         gpio_status = (platform_gpio_hook.entry[j].func)(gpio_status);
    }
  }
#endif
  /*
   * gpio_status is a bit map where bit 0 is set if unmapped gpio pin 0 (pin3) has
   * triggered the ISR. bit 1 if unmapped gpio pin 1 (pin10=U0TXD), etc.  Since this
   * is the ISR, it makes sense to optimize this by doing a fast scan of the status
   * and reverse mapping any set bits.
   */
   for (j = 0; gpio_status>0; j++, gpio_status >>= 1) {
    if (gpio_status&1) {
      int i = pin_num_inv[j];
      if (pin_int_type[i]) {
        //disable interrupt
        gpio_pin_intr_state_set(GPIO_ID_PIN(j), GPIO_PIN_INTR_DISABLE);
        //clear interrupt status
        GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, BIT(j));
        uint32 level = 0x1 & GPIO_INPUT_GET(GPIO_ID_PIN(j));
	task_post_high (gpio_task_handle, (now << 8) + (i<<1) + level);
	// We re-enable the interrupt when we execute the callback
      }
    }
  }
}
开发者ID:dnc40085,项目名称:nodemcu-firmware,代码行数:35,代码来源:platform.c

示例7: resetButtonTimerCallback

static void ICACHE_FLASH_ATTR resetButtonTimerCallback(void *data)
{
    static int previousState = 1;
    static int matchingSampleCount = 0;
    static int buttonPressCount = 0;
    static uint32_t lastButtonTime;
    int newState = GPIO_INPUT_GET(RESET_BUTTON_PIN);
    if (newState != previousState)
        matchingSampleCount = 0;
    else if (matchingSampleCount < RESET_BUTTON_THRESHOLD) {
        if (++matchingSampleCount == RESET_BUTTON_THRESHOLD) {
            if (newState != resetButtonState) {
                resetButtonState = newState;
                if (resetButtonState == 0) {
                    uint32_t buttonTime = system_get_time() / 1000;
                    //os_printf("Reset button press: count %d, last %u, this %u\n", buttonPressCount, (unsigned)lastButtonTime, (unsigned)buttonTime);
                    if (buttonPressCount == 0 || buttonTime - lastButtonTime > RESET_BUTTON_PRESS_DELTA)
                        buttonPressCount = 1;
                    else if (++buttonPressCount == RESET_BUTTON_PRESS_COUNT) {
                        os_printf("Entering STA+AP mode\n");
                        wifi_set_opmode(STATIONAP_MODE);
                        buttonPressCount = 0;
                    }
                    lastButtonTime = buttonTime;
                }
            }
        }
    }
    previousState = newState;
}
开发者ID:ParaBump,项目名称:Parallax-ESP,代码行数:30,代码来源:cgiprop.c

示例8: on_timeout

static void ICACHE_FLASH_ATTR on_timeout(void *arg)
{
	static uint8_t lastPin0 = 0xFF, lastPin1 = 0xFF;
	uint8_t pin0 = GPIO_INPUT_GET(PIN0);
	uint8_t pin1 = GPIO_INPUT_GET(PIN1);

	if ((pin0 != lastPin0 || pin1 != lastPin1) && client != NULL) {
		uint8_t data[2];
		data[0] = pin0 ? '1' : '0';
		data[1] = pin1 ? '1' : '0';

		MQTT_Publish(client, settings.mqttTopic, data, 2, 0, 1);
		lastPin0 = pin0;
		lastPin1 = pin1;
	}
}
开发者ID:andrei-tatar,项目名称:HAP.esp,代码行数:16,代码来源:user_main.c

示例9: i2c_master_getDC

/******************************************************************************
 * FunctionName : i2c_master_getDC
 * Description  : Internal used function -
 *                    get i2c SDA bit value
 * Parameters   : NONE
 * Returns      : uint8 - SDA bit value
*******************************************************************************/
LOCAL uint8 ICACHE_FLASH_ATTR
i2c_master_getDC(void)
{
    uint8 sda_out;
    sda_out = GPIO_INPUT_GET(GPIO_ID_PIN(I2C_MASTER_SDA_GPIO));
    return sda_out;
}
开发者ID:Daven005,项目名称:ESP8266,代码行数:14,代码来源:i2c_master.c

示例10: at_setupReadPinCmd

// digitalRead([pin])
void ICACHE_FLASH_ATTR
at_setupReadPinCmd(uint8_t id, char *pPara)
{
    int result = 0, err = 0, flag = 0;
    uint8 buffer[32] = {0};
    pPara++; // skip '='

    //get the first parameter (uint8_t)
    // digit
    flag = at_get_next_int_dec(&pPara, &result, &err);

    // flag must be true because there are more parameters
    //if ((flag == FALSE) && (result > 0) )
	if (err > 0)
	{
		at_port_print("Bad input");
        at_response_error();
        return;
    }
	
	uint8_t pin = result;
	
	// Don't go any further if the pin is un-usable or non-existant
	if (!pinValid(pin))
	{
		at_response_error();
		return;
	}
	
	uint8_t value = GPIO_INPUT_GET(pin);
	os_sprintf(buffer, "%d\r\n", value);
	
	at_port_print(buffer);
	at_response_ok();
}
开发者ID:jdavis1106,项目名称:ESP8266_WiFi_Shield,代码行数:36,代码来源:at_ArduinoShield.c

示例11: dht22_cb

LOCAL void ICACHE_FLASH_ATTR dht22_cb(void *arg)
{
	struct dht_sensor_data* r = DHTRead();
	int tempLength=0;
	int humLength=0;
	float lastTemp = r->temperature;
	float lastHum = r->humidity;
	if(r->success&&lastTemp>-30&&lastHum>0)
	{
		//TRANSFORMATION HERE
		console_printf("DHT22/Temperature: %d.%d *C, Humidity: %d.%d %%\r\n", (int)(lastTemp),(int)((lastTemp - (int)lastTemp)*100), (int)(lastHum),(int)((lastHum - (int)lastHum)*100));
		os_sprintf(DHT22_Temperature,"%d.%d", (int)(lastTemp),(int)((lastTemp - (int)lastTemp)*100));
		os_sprintf(DHT22_Humidity,"%d.%d", (int)(lastHum),(int)((lastHum - (int)lastHum)*100));
		if(lastTemp>=0) {
			if(lastTemp>9)
				tempLength=4;
			 else
				tempLength=3;
		} else tempLength=5; // assumption - bathroom temperature should not fall under -9 :P
		if(lastHum>9) humLength=2;
			else if (lastHum==100) humLength=3;
				else humLength=1;
		// MQTT PUBLISH HERE
		MQTT_Publish(&mqttClient,DHT22_MQTT_Temperature,DHT22_Temperature,tempLength,0,0);
		MQTT_Publish(&mqttClient,DHT22_MQTT_Humidity,DHT22_Humidity,humLength,0,0);
		// MANUAL MODE LOGICS HERE
		if (dDEVICE_MODE){
			// maintain currently set humidity
			if(lastHum<dBR_HUMIDITY_SET&&GPIO_INPUT_GET(PIN_GPIO5)&&!GPIO_INPUT_GET(PIN_GPIO13)) {
				GPIO_OUTPUT_SET(PIN_GPIO5, 0);
			} else if ((lastHum>dBR_HUMIDITY_SET+7)&&!GPIO_INPUT_GET(PIN_GPIO5)) {
				GPIO_OUTPUT_SET(PIN_GPIO5,1);
			}
			// maintain currently set bathroom temperature
			if(lastTemp>=dBR_TEMP_ROOM_SET&&GPIO_INPUT_GET(PIN_GPIO12)){
				GPIO_OUTPUT_SET(PIN_GPIO12,0);
			} else if ((lastTemp<dBR_TEMP_ROOM_SET-1)&&!GPIO_INPUT_GET(PIN_GPIO12)) {
				GPIO_OUTPUT_SET(PIN_GPIO12,1);
			}
		}
	}
	else
	{
		console_printf("Error reading temperature and humidity\r\n");
	}
}
开发者ID:theater,项目名称:ESP8266,代码行数:46,代码来源:user_main.c

示例12: user_btn_short_press

void ICACHE_FLASH_ATTR user_btn_short_press()
{
	os_printf("ON SHORT PRESS\n");
	uint32 iRet = 100;

	iRet = GPIO_INPUT_GET(14);
	os_printf("OUT: [%d]\n", iRet);
}
开发者ID:alexsunday,项目名称:esp_iot_sdk_1.0.1,代码行数:8,代码来源:user_main.c

示例13: bootloader_common_check_long_hold_gpio

esp_comm_gpio_hold_t bootloader_common_check_long_hold_gpio(uint32_t num_pin, uint32_t delay_sec)
{
    gpio_pad_select_gpio(num_pin);
    if (GPIO_PIN_MUX_REG[num_pin]) {
        PIN_INPUT_ENABLE(GPIO_PIN_MUX_REG[num_pin]);
    }
    gpio_pad_pullup(num_pin);
    uint32_t tm_start = esp_log_early_timestamp();
    if (GPIO_INPUT_GET(num_pin) == 1) {
        return GPIO_NOT_HOLD;
    }
    do {
        if (GPIO_INPUT_GET(num_pin) != 0) {
            return GPIO_SHORT_HOLD;
        }
    } while (delay_sec > ((esp_log_early_timestamp() - tm_start) / 1000L));
    return GPIO_LONG_HOLD;
}
开发者ID:tve,项目名称:esp-idf,代码行数:18,代码来源:bootloader_common.c

示例14: supla_esp_gpio_check_inputs

void
supla_esp_gpio_check_inputs(void *timer_arg) {

    #ifdef INPUT_PORT1
		char i1 = GPIO_INPUT_GET(GPIO_ID_PIN(INPUT_PORT1));

		if ( i1 != input1_last_state ) {

			char _input1_last_state = input1_last_state;
			input1_last_state = i1;

			#ifdef RELAY1_ELLOCK_MEM

			    if (  i1 == 1 && _input1_last_state == 0 ) {
			    	ellock_input1_state = 1;
				}

			    if ( i1 == 1 ) {
			    	i1 = ellock_input1_state;
			    };

			#endif

			#if defined(__BOARD_rs_module) || defined(__BOARD_rs_module_wroom) || defined(__BOARD_jangoe_rs)
			supla_esp_channel_value_changed(1, i1 == 1 ? 1 : 0);
			#else
			supla_esp_channel_value_changed(2, i1 == 1 ? 1 : 0);
			#endif

		}

    #endif

	#ifdef INPUT_PORT2
		char i2 = GPIO_INPUT_GET(GPIO_ID_PIN(INPUT_PORT2));

		if ( i2 != input2_last_state ) {
			input2_last_state = i2;

			supla_esp_channel_value_changed(3, i2 == 1 ? 1 : 0);
		}
	#endif
}
开发者ID:SUPLA,项目名称:supla-core,代码行数:43,代码来源:supla_esp_gpio.c

示例15: pb1Transmit

void pb1Transmit(){
	char tempreg[200];
	os_sprintf(tempreg, MQTT_TOPICIN, system_get_chip_id());

	if(GPIO_INPUT_GET(4)){
		MQTT_Publish(&mqttClient, tempreg, "1-1", strlen("1-1"), 0, 0);
	} else {
		MQTT_Publish(&mqttClient, tempreg, "1-0", strlen("1-0"), 0, 0);
	}
}
开发者ID:Ribster,项目名称:NoWire,代码行数:10,代码来源:user_main.c


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