3030#include "core/elrs.h"
3131#include "core/settings.h"
3232#include "core/sleep_mode.h"
33+ #include "driver/beep.h"
3334#include "driver/dm6302.h"
3435#include "driver/hardware.h"
3536#include "driver/i2c.h"
@@ -62,6 +63,8 @@ static uint16_t tune_timer = 0;
6263static int epfd ;
6364static pthread_t input_device_pid ;
6465
66+ static int btn_value = 0 ;
67+
6568// action: 1 = tune up, 2 = tune down, 3 = confirm
6669void exit_tune_channel () {
6770 tune_state = 0 ;
@@ -216,6 +219,14 @@ void tune_channel_timer() {
216219static int roller_up_acc = 0 ;
217220static int roller_down_acc = 0 ;
218221
222+ static bool scroll_sim_mode = false;
223+ static bool scroll_sim_mode_pending = false;
224+
225+ #define SCROLL_REPEAT_NONE 0
226+ #define SCROLL_REPEAT_UP 1
227+ #define SCROLL_REPEAT_DOWN 2
228+ static int scroll_sim_mode_repeat = SCROLL_REPEAT_NONE ;
229+
219230void (* btn_click_callback )() = & osd_toggle ;
220231void (* btn_press_callback )() = & app_switch_to_menu ;
221232
@@ -225,6 +236,9 @@ void (*rbtn_double_click_callback)() = &ht_set_center_position;
225236
226237void (* roller_callback )(uint8_t key ) = & tune_channel ;
227238
239+ static void roller_up (void );
240+ static void roller_down (void );
241+
228242static void btn_press (void ) // long press left key
229243{
230244 LOGI ("btn_press (%d)" , g_app_state );
@@ -350,31 +364,68 @@ void rbtn_click(right_button_t click_type) {
350364 if (g_app_state == APP_STATE_USER_INPUT_DISABLED )
351365 return ;
352366
353- pthread_mutex_lock (& lvgl_mutex );
367+ if (scroll_sim_mode ) {
368+ switch (click_type ) {
369+ case RIGHT_LONG_PRESS :
370+ if (btn_value ) {
371+ scroll_sim_mode = false;
372+ scroll_sim_mode_pending = true;
373+ beep ();
374+ }
375+ break ;
376+ case RIGHT_CLICK :
377+ if (scroll_sim_mode_repeat == SCROLL_REPEAT_NONE ) {
378+ roller_up ();
379+ }
380+ if (btn_value )
381+ scroll_sim_mode_repeat = SCROLL_REPEAT_UP ;
382+ else
383+ scroll_sim_mode_repeat = SCROLL_REPEAT_NONE ;
384+ break ;
385+ case RIGHT_DOUBLE_CLICK :
386+ if (scroll_sim_mode_repeat == SCROLL_REPEAT_NONE ) {
387+ roller_down ();
388+ }
389+ if (btn_value )
390+ scroll_sim_mode_repeat = SCROLL_REPEAT_DOWN ;
391+ else
392+ scroll_sim_mode_repeat = SCROLL_REPEAT_NONE ;
393+ break ;
394+ default :
395+ break ;
396+ }
397+ } else if (g_setting .ease .no_dial && btn_value ) {
398+ scroll_sim_mode = true;
399+ scroll_sim_mode_pending = true;
400+ beep ();
401+ } else {
354402
355- switch (g_app_state ) {
356- case APP_STATE_SUBMENU :
357- case APP_STATE_WIFI :
358- if (click_type == RIGHT_CLICK )
359- submenu_right_button (true);
360- else if (click_type == RIGHT_LONG_PRESS )
361- submenu_right_button (false);
362- break ;
363- case APP_STATE_VIDEO :
364- if (click_type == RIGHT_CLICK ) {
365- (* rbtn_click_callback )();
366- } else if (click_type == RIGHT_LONG_PRESS ) {
367- (* rbtn_press_callback )();
368- } else if (click_type == RIGHT_DOUBLE_CLICK ) {
369- (* rbtn_double_click_callback )();
403+ pthread_mutex_lock (& lvgl_mutex );
404+
405+ switch (g_app_state ) {
406+ case APP_STATE_SUBMENU :
407+ case APP_STATE_WIFI :
408+ if (click_type == RIGHT_CLICK )
409+ submenu_right_button (true);
410+ else if (click_type == RIGHT_LONG_PRESS )
411+ submenu_right_button (false);
412+ break ;
413+ case APP_STATE_VIDEO :
414+ if (click_type == RIGHT_CLICK ) {
415+ (* rbtn_click_callback )();
416+ } else if (click_type == RIGHT_LONG_PRESS ) {
417+ (* rbtn_press_callback )();
418+ } else if (click_type == RIGHT_DOUBLE_CLICK ) {
419+ (* rbtn_double_click_callback )();
420+ }
421+ break ;
422+ case APP_STATE_SLEEP :
423+ wake_up ();
424+ break ;
370425 }
371- break ;
372- case APP_STATE_SLEEP :
373- wake_up ();
374- break ;
375- }
376426
377- pthread_mutex_unlock (& lvgl_mutex );
427+ pthread_mutex_unlock (& lvgl_mutex );
428+ }
378429}
379430
380431static void roller_up (void ) {
@@ -449,7 +500,6 @@ static void roller_down(void) {
449500static void get_event (int fd ) {
450501 struct input_event event ;
451502 static int event_type_last = 0 ;
452- static int btn_value = 0 ;
453503 static int btn_press_time = 0 ;
454504
455505 static int roller_value = 0 ;
@@ -471,6 +521,9 @@ static void get_event(int fd) {
471521 case EV_SYN :
472522 if (event .code == SYN_REPORT ) {
473523 if (event_type_last == EV_REL ) {
524+ if (g_setting .ease .no_dial )
525+ break ;
526+
474527 if (!discard_scroll && timercmp (& event .time , & next_scroll , > )) {
475528 timeradd (& event .time , & scroll_time_diff , & next_scroll );
476529 if (roller_value == 1 ) {
@@ -495,20 +548,42 @@ static void get_event(int fd) {
495548 }
496549 } else if (event_type_last == EV_KEY ) {
497550 if (btn_value ) {
498- if (btn_press_time == 10 ) {
499- btn_press ();
500- g_key = DIAL_KEY_PRESS ;
551+ if (!g_setting .ease .no_dial ) {
552+ if (btn_press_time == 10 ) {
553+ btn_press ();
554+ g_key = DIAL_KEY_PRESS ;
555+ }
556+ } else {
557+ if (scroll_sim_mode_repeat == SCROLL_REPEAT_DOWN ) {
558+ roller_down ();
559+ } else if (scroll_sim_mode_repeat == SCROLL_REPEAT_UP ) {
560+ roller_up ();
561+ }
501562 }
502- btn_press_time ++ ;
563+ if (scroll_sim_mode_pending )
564+ btn_press_time = 0 ;
565+ else
566+ btn_press_time ++ ;
503567 // LOGI("btn down");
504568 } else {
505- if (btn_press_time < 10 ) {
506- btn_click ();
507- g_key = DIAL_KEY_CLICK ;
569+ if (scroll_sim_mode_pending ) {
570+ scroll_sim_mode_pending = false;
571+ } else {
572+ if (scroll_sim_mode_repeat == SCROLL_REPEAT_NONE ) {
573+ if (btn_press_time < 10 ) {
574+ btn_click ();
575+ g_key = DIAL_KEY_CLICK ;
576+ } else if (g_setting .ease .no_dial ) {
577+ if (btn_press_time < 50 ) {
578+ btn_press ();
579+ g_key = DIAL_KEY_PRESS ;
580+ }
581+ // else if(btn_press_time > 200){
582+ // btn_super_press();
583+ // }
584+ }
585+ }
508586 }
509- // else if(btn_press_time > 200){
510- // btn_super_press();
511- // }
512587 btn_press_time = 0 ;
513588 }
514589 }
@@ -590,6 +665,8 @@ static void *thread_input_device(void *ptr) {
590665 } else {
591666 roller_up_acc = 0 ;
592667 roller_down_acc = 0 ;
668+ if (scroll_sim_mode_repeat != SCROLL_REPEAT_NONE )
669+ beep ();
593670 }
594671 }
595672 return NULL ;
0 commit comments