diff options
author | Mike <mjc@avtechpulse.com> | 2000-01-01 01:22:29 +0900 |
---|---|---|
committer | Mike <mjc@avtechpulse.com> | 2000-01-01 01:22:29 +0900 |
commit | e10a022ea1bf954958f7d4a4e968b95dbcd51272 (patch) | |
tree | 3a1ded20656a44d07e4195d0333453638f3b752a /menus.c | |
parent | 7ae73525639e35d5cf3f95695ec8ceaffb12eac6 (diff) |
Test encoder against min change and min speed, for free-rolling defective encoders
Diffstat (limited to 'menus.c')
-rw-r--r-- | menus.c | 27 |
1 files changed, 21 insertions, 6 deletions
@@ -23,6 +23,8 @@ #define Plus_Minus_Button 16 /* mask for +/- button */ #define Extra_Fine_Button 32 /* mask for extra-fine button */ +#define MIN_ENCODER_CHANGE 3 +#define MAX_MS_PER_STEP 2000 /* ----- HOW THE MENU SYSTEM WORKS -------------------------------------------------------------------------*/ @@ -2315,17 +2317,19 @@ static void Submenu_Service_Encoder(int encoder_change) int new_int_value; int channel; - // need an encoder change of at least 2 to do anything - if (abs(encoder_change) <= 1) { + + // ignore small changes + if (abs(encoder_change) <= MIN_ENCODER_CHANGE) { Menu_Clear_Buttons(FALSE); + //g_print_debug("ignoring small change, for now\n"); return; } else if (encoder_change > 0) { - --encoder_change; + encoder_change -= MIN_ENCODER_CHANGE; } else { - ++encoder_change; + encoder_change += MIN_ENCODER_CHANGE; } - + g_print_debug("encoder change: %d\n",encoder_change); /* quit if RWLS mode */ update_remote_mode (); @@ -2353,6 +2357,17 @@ static void Submenu_Service_Encoder(int encoder_change) if (encoder_timer_change[0]<0) { encoder_timer_change[0]=1000; } + if (encoder_timer_change[0]>10000) { + encoder_timer_change[0]=10000; + } + + unsigned long ms_per_step = encoder_timer_change[0] / abs(encoder_change); + g_print_debug("encoder ms per step: %lu\n",ms_per_step); + if (ms_per_step > MAX_MS_PER_STEP) { + g_print_debug("ignoring slow change\n"); + Menu_Clear_Buttons(TRUE); + return; + } if ( (encoder_timer_change[0] < 50) @@ -2360,6 +2375,7 @@ static void Submenu_Service_Encoder(int encoder_change) && (encoder_timer_change[2] < 50) && (Submenu_extra_fine==NO) ) { ++encoder_mult; + g_print_debug("fast spin x%d\n", encoder_mult); if (encoder_mult>8) { encoder_mult=8; } @@ -3473,4 +3489,3 @@ static void Nonstd_menu_network(void) globals.MenuStatus.Nonstd_Display=YES; } - |