]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
Manually merged in John's updates
authorc vw <dl1ycf@darc.de>
Tue, 25 Jan 2022 13:47:48 +0000 (14:47 +0100)
committerc vw <dl1ycf@darc.de>
Tue, 25 Jan 2022 13:47:48 +0000 (14:47 +0100)
gpio.c
i2c.c
release/pihpsdr/install.sh
release/pihpsdr/libwdsp.so

diff --git a/gpio.c b/gpio.c
index 9d97f78fbe718db7faa46c27beeb3b91f61c1a24..70c349a9abd195bb4dfbff7858d938309ac6b1ad 100644 (file)
--- a/gpio.c
+++ b/gpio.c
@@ -167,7 +167,7 @@ ENCODER encoders_controller2_v1[MAX_ENCODERS]={
   };
 
 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},
diff --git a/i2c.c b/i2c.c
index a46e3f4594a750c3f2950b4ce754689e3531a95a..62da7caca70a2f736d5183fa5be77c5977db789c 100644 (file)
--- a/i2c.c
+++ b/i2c.c
@@ -78,6 +78,27 @@ static void frequencyStep(int pos) {
   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;
@@ -90,6 +111,7 @@ void i2c_interrupt() {
   // 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
@@ -97,6 +119,7 @@ void i2c_interrupt() {
     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
@@ -105,6 +128,7 @@ void i2c_interrupt() {
        }
       }
   }
+  debounce=t+debounce_time;
   g_mutex_unlock(&i2c_mutex);
 }
 
@@ -175,6 +199,8 @@ void i2c_init() {
       }
     }
   } while(flags!=0);
+
+  initialiseEpoch();
   
 }
 #endif
index 9f7121d83d2d7e090336d1f2b0a32791e38e8d0b..3f08f29a7c25571c5fc1ba1231257295be2c39b0 100755 (executable)
@@ -1,7 +1,7 @@
 echo "installing fftw"
 sudo apt-get -y install libfftw3-3
 echo "installing gppiod"
-sudo apt-get -y install libgpuiod2
+sudo apt-get -y install libgpiod2
 echo "installing pulseaudio"
 sudo apt-get -y install libpulse0
 sudo apt-get -y install libpulse-mainloop-glib0
index a020b796df1e72ca20ea9b0d290c3c292e4dfb79..7492325206799cf15cdbb66bc840876dd56adb55 100755 (executable)
Binary files a/release/pihpsdr/libwdsp.so and b/release/pihpsdr/libwdsp.so differ