Statistics: Posted by ashoke11 — Mon Sep 11, 2017 11:00 am
Statistics: Posted by ESP_Alfred — Sun Jun 12, 2016 2:19 pm
Code:
#include "esp_common.h"
#include "esp8266/gpio_register.h"
#include "gpio.h"
#include "key.h"
#include "user_config.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
LOCAL struct keys_param keys;
LOCAL struct single_key_param *single_key[KEY_NUM];
LOCAL int state=0;
xTaskHandle switch_set_point;
LOCAL void
key_shortPress(){
state^=1;
//GPIO_OUTPUT_SET(GPIO_ID_PIN(4), state);
printf("Short_press %d\n",state);
return;
}
LOCAL void
key_longPress(){
printf("Long_press\n");
return;
}
void switch_set (void *pvParameters){
//output configuration----------------------------------------------------------------------
GPIO_ConfigTypeDef gpio_out_cfg;
gpio_out_cfg.GPIO_Mode = GPIO_Mode_Output;
gpio_out_cfg.GPIO_Pin = GPIO_Pin_4;
gpio_config(&gpio_out_cfg);
//input configuration----------------------------------------------------------------------
//declaring the input key
single_key[0]=key_init_single(GPIO_ID_PIN(0),PERIPHS_IO_MUX_GPIO0_U,FUNC_GPIO0,key_longPress,key_shortPress);
keys.key_num = KEY_NUM;
keys.single_key = single_key;
key_init(&keys);
printf("set_interrupt and closing task\n");
vTaskDelete(switch_set_point);
}
void ICACHE_FLASH_ATTR
user_init(void)
{
printf("SDK version:%s\n", system_get_sdk_version());
/* need to set opmode before you set config */
wifi_set_opmode(STATION_MODE);
xTaskCreate(switch_set, "switch_set", 256, NULL, (1), &switch_set_point);
}
Statistics: Posted by meaepeppe — Tue May 31, 2016 4:09 pm