Skip to content

Commit

Permalink
Update user_gpio.c
Browse files Browse the repository at this point in the history
  • Loading branch information
linlyv authored May 1, 2019
1 parent 914047e commit 1103097
Showing 1 changed file with 52 additions and 52 deletions.
104 changes: 52 additions & 52 deletions user_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@



#define TIMER1_ID (1) //定时器id
#define TIMER1_ID (1) //定时器id


char ntpserver[]="ntp1.aliyun.com";

uint8_t key_time = 0;
#define BUTTON_LONG_PRESS_TIME 10 //
int hour, min, secnod; //时间
int hour, min, secnod; //时间

int relay[]={SW1,SW2,SW3,SW4,SW5,SW6}; //对应每路继电器GPIO
int relay[]={SW1,SW2,SW3,SW4,SW5,SW6}; //对应每路继电器GPIO

static hftimer_handle_t user_key_timer=NULL;
hfthread_mutex_t keythread_lock=NULL_MUTEX;
Expand Down Expand Up @@ -60,9 +60,9 @@ bool USER_FUNC relay_out( void )
}

/*user_relay_set
* 设置继电器开关
* x:编号 0-5
* y:开关 0:关 1:开
* 设置继电器开关
* x:编号 0-5
* y:开关 0:关 1:开
*/
void USER_FUNC user_relay_set(uint8_t x,uint8_t y )
{
Expand All @@ -82,8 +82,8 @@ void USER_FUNC user_relay_set(uint8_t x,uint8_t y )
}

/*
* 设置所有继电器开关
* y:0:全部关 1:根据记录状态开关所有
* 设置所有继电器开关
* y:0:全部关 1:根据记录状态开关所有
*
*/
void USER_FUNC user_relay_set_all( uint8_t y )
Expand Down Expand Up @@ -147,7 +147,7 @@ void USER_FUNC key_short_press( void )

hour = (hfsys_get_time()/1000)/3600;
min = (hfsys_get_time()/1000 - hour*3600)/60;
//按键扫描程序
//按键扫描程序

uint8_t tmp = (0xfe | hfgpio_fpin_is_high( KEY ));
//key_trigger = tmp & (tmp ^ key_continue);
Expand All @@ -166,63 +166,63 @@ void USER_FUNC key_short_press( void )
{
if ( key_time == 50 )
{
key_long_press( );
printtime();//打印时间
//u_printf("hfuflash_size:%d\n",hfuflash_size());
key_long_press( );
printtime();//打印时间
//u_printf("hfuflash_size:%d\n",hfuflash_size());
}
else if ( key_time == 100 )
{
//key_long_10s_press( );
}
else if ( key_time ==180 ){
user_function_cmd_received(1,"{\"cmd\":\"device report\"}");
user_led_set( 0 );
user_function_cmd_received(1,"{\"cmd\":\"device report\"}");
user_led_set( 0 );
}
else if ( key_time ==190 ){
user_led_set( 1 );
else if ( key_time ==190 ){
user_led_set( 1 );
}
else if ( key_time == 203 )
else if ( key_time == 203 )
{
user_led_set( 0 );
//u_printf("SmartLink_start > >>");
user_function_cmd_received(1,"{\"cmd\":\"device report\"}");
hfsmtlk_start();
user_led_set( 0 );
//u_printf("SmartLink_start > >>");
user_function_cmd_received(1,"{\"cmd\":\"device report\"}");
hfsmtlk_start();
//key_time = 201;
}
}
if(key_time>204){
key_time=189;
}
if(key_time>204){
key_time=189;
}

}else{
if(!relay_out()){ user_led_set( 0 ); }
}else{
if(!relay_out()){ user_led_set( 0 ); }
}
}




void USER_FUNC key_rising_irq_handler ( uint32_t arg1,uint32_t arg2 ){
if(key_time<2){
}
else if(key_time<20){
if(hfgpio_fpin_is_high( KEY )){
HF_Debug(DEBUG_WARN,"short press\n");
key_short_press();
//hfconfig_file_data_read(2,config_data,100);

}
} else if(key_time<80){
HF_Debug(DEBUG_WARN,"4s press\n");
}
else if(key_time<150){
HF_Debug(DEBUG_WARN,"5s press\n");
}
else if (key_time<204){
HF_Debug(DEBUG_WARN,"10s press\n");
if(key_time<2){
}
else if(key_time<20){
if(hfgpio_fpin_is_high( KEY )){
HF_Debug(DEBUG_WARN,"short press\n");
key_short_press();
//hfconfig_file_data_read(2,config_data,100);

}
} else if(key_time<80){
HF_Debug(DEBUG_WARN,"4s press\n");
}
else if(key_time<150){
HF_Debug(DEBUG_WARN,"5s press\n");
}
else if (key_time<204){
HF_Debug(DEBUG_WARN,"10s press\n");
}

key_time=0;
key_time=0;
}

USER_FUNC void keyscan_thread_func(void * arg){
Expand Down Expand Up @@ -250,13 +250,13 @@ void USER_FUNC key_init( )
HF_Debug(DEBUG_LEVEL,"create mutex fail\n");
return;
}
///hfthread_create(keyscan_thread_func,"keycontrol",256,(void*)1,1,NULL,NULL); //线程初始化
///hfthread_create(keyscan_thread_func,"keycontrol",256,(void*)1,1,NULL,NULL); //线程初始化


if(hfgpio_configure_fpin_interrupt(KEY,HFPIO_IT_EDGE,key_rising_irq_handler,1)!=HF_SUCCESS)
{
u_printf("configure HFGPIO_F_USER_RELOAD fail\n");
HF_Debug(DEBUG_WARN,"configure KEY fail\n");
HF_Debug(DEBUG_WARN,"configure KEY fail\n");
return;
}else
HF_Debug(DEBUG_WARN,"configure KEY process success\n");
Expand Down Expand Up @@ -316,14 +316,14 @@ void printTask(){
u_printf("u_config.plug[i].name:%s\n",u_config.plug[i].name);
for ( j = 0; j < 3; j++ )
{
u_printf("u_config.plug[%d].task[%d].hour: %d\n",i,j,u_config.plug[i].task[j].hour);
u_printf("u_config.plug[%d].task[%d].minute: %d\n",i,j,u_config.plug[i].task[j].minute);
u_printf("u_config.plug[%d].task[%d].repeat: %d\n",i,j,u_config.plug[i].task[j].repeat);
u_printf("u_config.plug[%d].task[%d].on: %d\n",i,j,u_config.plug[i].task[j].on);
u_printf("u_config.plug[%d].task[%d].action: %d\n",i,j,u_config.plug[i].task[j].action);
u_printf("u_config.plug[%d].task[%d].hour: %d\n",i,j,u_config.plug[i].task[j].hour);
u_printf("u_config.plug[%d].task[%d].minute: %d\n",i,j,u_config.plug[i].task[j].minute);
u_printf("u_config.plug[%d].task[%d].repeat: %d\n",i,j,u_config.plug[i].task[j].repeat);
u_printf("u_config.plug[%d].task[%d].on: %d\n",i,j,u_config.plug[i].task[j].on);
u_printf("u_config.plug[%d].task[%d].action: %d\n",i,j,u_config.plug[i].task[j].action);

}
}


}
}

0 comments on commit 1103097

Please sign in to comment.