OSDN Git Service

[UI] Fix same keyin feeling.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Thu, 22 Aug 2013 16:39:54 +0000 (01:39 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Thu, 22 Aug 2013 16:39:54 +0000 (01:39 +0900)
menu_memoryfreq.c
nbproject/Makefile-genesis.properties
ui.c

index 5e8e48c..07a4627 100644 (file)
@@ -139,10 +139,7 @@ void on_updown_userfreq(void)
         update_status();
         print_freq(1);
         _HOME();
-       do {
-           n = pollkeys(pollkeybuf, 19, 1);
-       } while(n == 0);
-       c = pollkeybuf[0];
+        c = pollkey_single_timeout(44, 1); // About 1s
        switch(c) {
            case charcode_8: // UP CH
                 setup.memorynum++;
@@ -173,8 +170,7 @@ void on_updown_userfreq(void)
            default:
                break;
            }
-//        _HOME();
-       _HOME();
+//       _HOME();
     } while(1);
 _l0:
     _CLS();
index d0f71b0..b14fb92 100644 (file)
@@ -1,5 +1,5 @@
 #
-#Fri Aug 23 00:59:05 JST 2013
+#Fri Aug 23 01:38:06 JST 2013
 default.languagetoolchain.dir=/opt/microchip/xc8/v1.20/bin
 com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=1c49f19f6a43b876c317e0d8d41c0854
 default.languagetoolchain.version=1.20
diff --git a/ui.c b/ui.c
index c9da851..6a3ba64 100644 (file)
--- a/ui.c
+++ b/ui.c
@@ -331,9 +331,14 @@ unsigned char pollkey_single(void)
                 cold = c;
                 return c;
             }
+            penalty = 0;
+        } else {
+            penalty++;
+            if(penalty > 4) {
+                penalty = 0;
+                cold = charcode_null; // About 100ms
+            }
         }
-        penalty++;
-        if(penalty > 65) cold = charcode_null; // About 1500ms
     } while(1);
 }
 
@@ -341,44 +346,52 @@ unsigned char pollkey_single_timeout(unsigned int limit, unsigned char repeat)
 {
     unsigned char c;
     unsigned int ticks = 0;
+    unsigned char penalty = 0;
+    unsigned char count = 0;
 
 
-//    cold = charcode_null;
+    cold = charcode_null;
+    pollkeybuf[0] = charcode_null;
     do {
+        if(limit != 0) {
+            ticks++;
+            if(ticks > limit) {
+                break;
+            }
+        }
         idle_time_ms(5); // 5ms.
         c = readkey(); // 2 * 9 = 18ms
         ClrWdt();
         ticks++;
-        if(c != charcode_null) {
-            if(repeat != 0){
+        if(c != charcode_null){
+            if(cold != c) {
+                pollkeybuf[count++] = c;
                 cold = c;
-                break;
-            } else {
-                if(cold != c) {
-                    cold = c;
-                    break;
+                count++;
+                if(repeat == 0) {
+                        break;
                 }
+                penalty = 0;
             }
-        }
-        if(limit != 0) {
-            ticks++;
-            if(ticks > limit) {
+        }  else {
+            penalty++;
+            if(penalty > 4){
+                penalty = 0;
                 cold = charcode_null;
-                return charcode_null;
             }
         }
-    } while(1);
+    } while(count < 32);
 
     /*
      * Set Deadzone.
      */
     if(limit == 0) {
-//        if(ticks >= (limit >> 1)) cold = charcode_null;
         while(ticks <= limit) {
             idle_time_ms(5 + 18);
             ticks++;
         }
     }
+    c = pollkeybuf[0];
     return c;
 }
 /*