};
ENCODER encoders_controller2_v2[MAX_ENCODERS]={
- {TRUE,TRUE,5,1,6,1,0,RF_GAIN,R_START,TRUE,TRUE,26,1,20,1,0,AF_GAIN,R_START,TRUE,TRUE,22,MENU_BAND,0L},
+ {TRUE,TRUE,5,1,6,1,0,DRIVE,R_START,TRUE,TRUE,26,1,20,1,0,AF_GAIN,R_START,TRUE,TRUE,22,MENU_BAND,0L},
{TRUE,TRUE,9,1,7,1,0,ATTENUATION,R_START,TRUE,TRUE,21,1,4,1,0,AGC_GAIN,R_START,TRUE,TRUE,27,MENU_MODE,0L},
{TRUE,TRUE,11,1,10,1,0,IF_WIDTH,R_START,TRUE,TRUE,19,1,16,1,0,IF_SHIFT,R_START,TRUE,TRUE,23,MENU_FILTER,0L},
{TRUE,TRUE,13,1,12,1,0,XIT,R_START,TRUE,TRUE,8,1,25,1,0,RIT,R_START,TRUE,TRUE,24,MENU_FREQUENCY,0L},
vfo_step(pos);
}
+static uint64_t epochMilli;
+
+static void initialiseEpoch() {
+ struct timespec ts ;
+
+ clock_gettime (CLOCK_MONOTONIC_RAW, &ts) ;
+ epochMilli = (uint64_t)ts.tv_sec * (uint64_t)1000 + (uint64_t)(ts.tv_nsec / 1000000L) ;
+}
+
+static uint32_t millis () {
+ uint64_t now ;
+ struct timespec ts ;
+ clock_gettime (CLOCK_MONOTONIC_RAW, &ts) ;
+ now = (uint64_t)ts.tv_sec * (uint64_t)1000 + (uint64_t)(ts.tv_nsec / 1000000L) ;
+ return (uint32_t)(now - epochMilli) ;
+}
+
+static uint32_t debounce_time=50; // 50ms
+static uint32_t t;
+static uint32_t debounce=0;
+
void i2c_interrupt() {
unsigned int flags;
unsigned int ints;
// Perhaps we should determine the lock status and simply return if it is locked.
//
g_mutex_lock(&i2c_mutex);
+ t=millis();
for (;;) {
flags=read_word_data(0x0E); // indicates which switch caused the interrupt
// More than one bit may be set if two input lines
if (flags == 0) break; // "forever" loop is left if no interrups pending
ints=read_word_data(0x10); // input lines at time of interrupt
// only those bits set in "flags" are meaningful!
+ if(t<debounce) break;
for(i=0; i<16 && flags; i++) { // leave loop if no bits left in flags.
if(i2c_sw[i] & flags) {
// The input line associated with switch #i has triggered an interrupt
}
}
}
+ debounce=t+debounce_time;
g_mutex_unlock(&i2c_mutex);
}
}
}
} while(flags!=0);
+
+ initialiseEpoch();
}
#endif