Exemplo n.º 1
0
LOCAL void user_switch1_off(void *arg) {
    switch1_config *config = arg;

    config->timer = 0;
    user_switch1_set(config->id, 0);

    user_switch1_event();
}
Exemplo n.º 2
0
LOCAL void ICACHE_FLASH_ATTR switch1_toggle(void *arg) {
	switch1_config *config = arg;
	
	bool event = false;
	if (1 == GPIO_INPUT_GET(GPIO_ID_PIN(config->gpio.gpio_id))) {
		if (config->state_buf < SWITCH_STATE_FILTER) {
			config->state_buf++;
			event = (config->state_buf == SWITCH_STATE_FILTER);
		}
	} else {
		if (config->state_buf > 0) {
			config->state_buf--;
			event = (config->state_buf == 0);
		}
	}
	
	if (event) {
		config->state = (config->state_buf == SWITCH_STATE_FILTER);
		user_switch1_set(config->id - 1, 2);
		user_switch1_event();
	}
}