summaryrefslogtreecommitdiff
path: root/menus.c
diff options
context:
space:
mode:
authorMike <mjc@avtechpulse.com>2000-01-01 02:04:28 +0900
committerMike <mjc@avtechpulse.com>2000-01-01 02:04:28 +0900
commit3a3c23a5716695949a1c07cb44d01351128811bd (patch)
tree2eeccbbbf278708008f3e7c2152a8c8583a38ef5 /menus.c
parente5eda38a5b7debedb7a3f186424de4d7204be3e0 (diff)
ignore tiniest encoder steps
Diffstat (limited to 'menus.c')
-rw-r--r--menus.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/menus.c b/menus.c
index 8367650..52c6c3f 100644
--- a/menus.c
+++ b/menus.c
@@ -2296,17 +2296,25 @@ static int Submenu_Mult_Value(float mult_by)
static void Submenu_Service_Encoder(int encoder_change)
{
-
int error_num;
int equivalent_integer; /* non-exponent part stripped of its decimal point */
float new_value; /* new parameter value to be loaded */
float abs_Submenu_Value; /* absolute value of Submenu_Value */
int increment_size;
int new_int_value;
- int reset_encoder;
int channel;
- reset_encoder=YES;
+ // need an encoder change of at least 2 to do anything
+ if (abs(encoder_change) <= 1) {
+ Menu_Clear_Buttons(FALSE);
+ return;
+ }
+ else if (encoder_change > 0) {
+ --encoder_change;
+ } else {
+ ++encoder_change;
+ }
+
/* quit if RWLS mode */
update_remote_mode ();
@@ -2376,7 +2384,6 @@ static void Submenu_Service_Encoder(int encoder_change)
{
g_usleep (2e5);
- reset_encoder=YES; /* to avoid extra unwanted increments */
if (encoder_change>0) {
new_int_value=(int) (Submenu_Value + 1.0);
if (new_int_value>30) {
@@ -2394,7 +2401,6 @@ static void Submenu_Service_Encoder(int encoder_change)
{
g_usleep (2e5);
- reset_encoder=YES; /* to avoid extra unwanted increments */
new_int_value=(int) (Submenu_Value);
#define LARGE_CHANGE 3
@@ -2431,7 +2437,6 @@ static void Submenu_Service_Encoder(int encoder_change)
((Submenu_Numeric_Parameter-channel) == Show_route_secondary) ) {
g_usleep (2e5);
- reset_encoder=YES; /* to avoid extra unwanted increments */
new_int_value=(int) (Submenu_Value);
if (encoder_change>0) {
@@ -2734,9 +2739,7 @@ static void Submenu_Service_Encoder(int encoder_change)
last_encoder_adjust_error=error_num;
- if (reset_encoder) {
- Menu_Clear_Buttons();
- }
+ Menu_Clear_Buttons(TRUE);
return;
}
@@ -2744,7 +2747,7 @@ static void Submenu_Service_Encoder(int encoder_change)
static void Nonstd_menu_default_rs232(void)
{
- Menu_Clear_Buttons();
+ Menu_Clear_Buttons(TRUE);
LCD_clear(); /*0123456789012345678901234567890123456789*/
LCD_write(0,0,"The RS232 settings are now: 1200 baud,");
@@ -2754,7 +2757,7 @@ static void Nonstd_menu_default_rs232(void)
IO_Setup_RS232(1200, 1);
- Menu_Clear_Buttons();
+ Menu_Clear_Buttons(TRUE);
globals.MenuStatus.Nonstd_Display=YES;
}
@@ -2773,12 +2776,24 @@ static void Nonstd_menu_model_info(void)
}
-void Menu_Clear_Buttons(void)
+static void Reset_Encoder ()
+{
+ /* reset encoder-monitoring by presetting counters to mid range */
+ I2C_Write(PCF8574A+Upper_Encoder_Port,127);
+ I2C_Write(PCF8574A+Upper_Encoder_Port,255);
+}
+
+
+void Menu_Clear_Buttons(int reset_encoder)
{
int dummy1,dummy2,dummy3;
/* enable interrupt lines */
Read_Keypad(&dummy1,&dummy2,&dummy3);
+
+ if (reset_encoder) {
+ Reset_Encoder();
+ }
}
@@ -2825,11 +2840,6 @@ static void Read_Keypad(int *button_port_val, int *upper_encoder_val, int *lower
/* reenable encoder */
I2C_Write(PCF8574A+Button_Press_Port,255);
- /* reset encoder-monitoring by presetting counters to mid range */
- I2C_Write(PCF8574A+Upper_Encoder_Port,127);
- I2C_Write(PCF8574A+Upper_Encoder_Port,255);
-
-
/* alarm condition */
/* valid for both local and remote modes */
if ( !(*upper_encoder_val & Over_Temp)