|
@@ -34,25 +34,18 @@ extern int duer_recorder_test_start(int channel);
|
|
|
|
|
|
static void button_polling_thread()
|
|
static void button_polling_thread()
|
|
{
|
|
{
|
|
- int old_state=0;
|
|
|
|
- int now_state=0;
|
|
|
|
uint32_t btn_press_time = duer_timestamp();
|
|
uint32_t btn_press_time = duer_timestamp();
|
|
uint32_t btn_release_time = duer_timestamp();
|
|
uint32_t btn_release_time = duer_timestamp();
|
|
int channel_id=1;
|
|
int channel_id=1;
|
|
|
|
|
|
while(1)
|
|
while(1)
|
|
{
|
|
{
|
|
- waitForInterrupt(BUTTON_GPIO, 200);
|
|
|
|
- //DUER_LOGI("button_polling_thread %d\n",digitalRead(BUTTON_GPIO));
|
|
|
|
- if((now_state=digitalRead(BUTTON_GPIO))!=old_state)
|
|
|
|
|
|
+ waitForInterrupt(BUTTON_GPIO, -1);
|
|
|
|
+ DUER_LOGI("button_polling_thread %d\n", digitalRead(BUTTON_GPIO));
|
|
|
|
+ delay(100);
|
|
|
|
+ if(digitalRead(BUTTON_GPIO)==0)
|
|
{
|
|
{
|
|
- DUER_LOGI("%d %d\n",now_state,old_state);
|
|
|
|
- if(now_state==1) //release
|
|
|
|
- {
|
|
|
|
- btn_release_time = duer_timestamp(NULL);
|
|
|
|
- if(btn_release_time>btn_press_time+100)
|
|
|
|
- {
|
|
|
|
- if(duer_app_is_test_mode())
|
|
|
|
|
|
+ if(duer_app_is_test_mode())
|
|
{
|
|
{
|
|
duer_recorder_test_start(channel_id);
|
|
duer_recorder_test_start(channel_id);
|
|
duer_dcs_dialog_cancel();
|
|
duer_dcs_dialog_cancel();
|
|
@@ -73,14 +66,6 @@ static void button_polling_thread()
|
|
duer_media_tone_play("./resources/16.wav");
|
|
duer_media_tone_play("./resources/16.wav");
|
|
event_record_start();
|
|
event_record_start();
|
|
}
|
|
}
|
|
- }
|
|
|
|
- }
|
|
|
|
- else //press
|
|
|
|
- {
|
|
|
|
- btn_press_time = duer_timestamp();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- old_state = now_state;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -93,6 +78,8 @@ int button_init(void)
|
|
DUER_LOGE("wiringPiSetup fail\n");
|
|
DUER_LOGE("wiringPiSetup fail\n");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
+ pinMode(BUTTON_GPIO, INPUT);
|
|
|
|
+ pullUpDnControl(BUTTON_GPIO, PUD_UP);
|
|
|
|
|
|
if(pthread_create(&s_button_threadID, NULL, (void *)button_polling_thread, NULL)!=0)
|
|
if(pthread_create(&s_button_threadID, NULL, (void *)button_polling_thread, NULL)!=0)
|
|
{
|
|
{
|