OSDN Git Service

Renamed level variables.
authorShinichiro Nakamura <shinta.main.jp@gmail.com>
Sat, 25 Aug 2012 19:00:25 +0000 (04:00 +0900)
committerShinichiro Nakamura <shinta.main.jp@gmail.com>
Sat, 25 Aug 2012 19:00:25 +0000 (04:00 +0900)
firm/bare_metal/common/effect.c
firm/bare_metal/common/system.c
firm/bare_metal/common/uzura.h
firm/bare_metal/dynamic_menu/main.c

index 221840e..e656be1 100644 (file)
@@ -41,17 +41,17 @@ void effect_through(
         const int32_t *src, int32_t *des, int32_t count)
 {
     int i;
-    UZURA_VOLUME_INPUT(p).left = 0;
-    UZURA_VOLUME_INPUT(p).right = 0;
-    UZURA_VOLUME_OUTPUT(p).left = 0;
-    UZURA_VOLUME_OUTPUT(p).right = 0;
+    UZURA_LEVEL_INPUT(p).left = 0;
+    UZURA_LEVEL_INPUT(p).right = 0;
+    UZURA_LEVEL_OUTPUT(p).left = 0;
+    UZURA_LEVEL_OUTPUT(p).right = 0;
     for (i = 0; i < count; i+=2) {
         *(des + i + 0) = *(src + i + 0);
         *(des + i + 1) = *(src + i + 1);
-        UZURA_VOLUME_INPUT(p).left += abs(*(src + i + 0)) >> 1;
-        UZURA_VOLUME_INPUT(p).right += abs(*(src + i + 1)) >> 1;
-        UZURA_VOLUME_OUTPUT(p).left += abs(*(des + i + 0)) >> 1;
-        UZURA_VOLUME_OUTPUT(p).right += abs(*(des + i + 1)) >> 1;
+        UZURA_LEVEL_INPUT(p).left += abs(*(src + i + 0)) >> 1;
+        UZURA_LEVEL_INPUT(p).right += abs(*(src + i + 1)) >> 1;
+        UZURA_LEVEL_OUTPUT(p).left += abs(*(des + i + 0)) >> 1;
+        UZURA_LEVEL_OUTPUT(p).right += abs(*(des + i + 1)) >> 1;
     }
 }
 
@@ -60,17 +60,17 @@ void effect_karaoke(
         const int32_t *src, int32_t *des, int32_t count)
 {
     int i;
-    UZURA_VOLUME_INPUT(p).left = 0;
-    UZURA_VOLUME_INPUT(p).right = 0;
-    UZURA_VOLUME_OUTPUT(p).left = 0;
-    UZURA_VOLUME_OUTPUT(p).right = 0;
+    UZURA_LEVEL_INPUT(p).left = 0;
+    UZURA_LEVEL_INPUT(p).right = 0;
+    UZURA_LEVEL_OUTPUT(p).left = 0;
+    UZURA_LEVEL_OUTPUT(p).right = 0;
     for (i = 0; i < count; i+=2) {
         *(des + i + 0) = *(src + i + 0) - *(src + i + 1);
         *(des + i + 1) = *(src + i + 0) - *(src + i + 1);
-        UZURA_VOLUME_INPUT(p).left += abs(*(src + i + 0)) >> 1;
-        UZURA_VOLUME_INPUT(p).right += abs(*(src + i + 1)) >> 1;
-        UZURA_VOLUME_OUTPUT(p).left += abs(*(des + i + 0)) >> 1;
-        UZURA_VOLUME_OUTPUT(p).right += abs(*(des + i + 1)) >> 1;
+        UZURA_LEVEL_INPUT(p).left += abs(*(src + i + 0)) >> 1;
+        UZURA_LEVEL_INPUT(p).right += abs(*(src + i + 1)) >> 1;
+        UZURA_LEVEL_OUTPUT(p).left += abs(*(des + i + 0)) >> 1;
+        UZURA_LEVEL_OUTPUT(p).right += abs(*(des + i + 1)) >> 1;
     }
 }
 
index 96b51e9..b491b1c 100644 (file)
@@ -5,13 +5,13 @@
 void system_default(UZURA *p)
 {
     lcd_goto(0, 0);
-    lcd_putc(0x08 + (UZURA_VOLUME_INPUT(p).left   >> 29));
-    lcd_putc(0x08 + (UZURA_VOLUME_INPUT(p).right  >> 29));
-    lcd_putc(0x08 + (UZURA_VOLUME_OUTPUT(p).left  >> 29));
-    lcd_putc(0x08 + (UZURA_VOLUME_OUTPUT(p).right >> 29));
-    lcd_putc(0x08 + (UZURA_VOLUME_INPUT(p).left   >> 29));
-    lcd_putc(0x08 + (UZURA_VOLUME_INPUT(p).right  >> 29));
-    lcd_putc(0x08 + (UZURA_VOLUME_OUTPUT(p).left  >> 29));
-    lcd_putc(0x08 + (UZURA_VOLUME_OUTPUT(p).right >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_INPUT(p).left   >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_INPUT(p).right  >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_OUTPUT(p).left  >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_OUTPUT(p).right >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_INPUT(p).left   >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_INPUT(p).right  >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_OUTPUT(p).left  >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_OUTPUT(p).right >> 29));
 }
 
index c81cd0f..af2de2d 100644 (file)
@@ -43,8 +43,8 @@ typedef void (*UZURA_EFFECT_FUNC)(UZURA *p,
         const int32_t *src, int32_t *des, int32_t count);
 typedef void (*UZURA_SYSTEM_FUNC)(UZURA *p);
 
-#define UZURA_VOLUME_INPUT(P)   ((P)->input)
-#define UZURA_VOLUME_OUTPUT(P)  ((P)->input)
+#define UZURA_LEVEL_INPUT(P)    ((P)->input)
+#define UZURA_LEVEL_OUTPUT(P)   ((P)->output)
 #define UZURA_USER_DATA(P)      ((P)->user_data)
 
 /**
@@ -53,13 +53,13 @@ typedef void (*UZURA_SYSTEM_FUNC)(UZURA *p);
 typedef struct {
     uint32_t left;   /**< Left. */
     uint32_t right;  /**< Right. */
-} volume_t;
+} level_t;
 
 struct UZURA {
     UZURA_EFFECT_FUNC effect;   /**< Effect callback. */
     UZURA_SYSTEM_FUNC system;   /**< System callback. */
-    volume_t input;             /**< Input volume. */
-    volume_t output;            /**< Output volume. */
+    level_t input;              /**< Input volume. */
+    level_t output;             /**< Output volume. */
     void *user_data;            /**< User external object. */
 };
 
index 897ddd9..9340371 100644 (file)
@@ -49,6 +49,8 @@ typedef struct {
 
 static void rotenc_callback(RotencAction action, void *extobj)
 {
+    static int lotdiv = 0;
+
     work_t *w = (work_t *)extobj;
     if (RotencActionPush == action) {
         w->effect = !w->effect;
@@ -64,15 +66,25 @@ static void rotenc_callback(RotencAction action, void *extobj)
         }
     }
     if (RotencActionLeft == action) {
-        w->locate_target-=8;
-        if (w->locate_target < 0) {
-            w->locate_target = 0;
+        if (lotdiv < -4) {
+            w->locate_target-=8;
+            if (w->locate_target < 0) {
+                w->locate_target = 0;
+            }
+            lotdiv = 0;
+        } else {
+            lotdiv--;
         }
     }
     if (RotencActionRight == action) {
-        w->locate_target+=8;
-        if (32 < w->locate_target) {
-            w->locate_target = 32;
+        if (4 < lotdiv) {
+            w->locate_target+=8;
+            if (32 < w->locate_target) {
+                w->locate_target = 32;
+            }
+            lotdiv = 0;
+        } else {
+            lotdiv++;
         }
     }
 }
@@ -82,14 +94,14 @@ static void system_dynamic_menu(UZURA *p)
     work_t *w = (work_t *)UZURA_USER_DATA(p);
 
     lcd_goto(0, 0);
-    lcd_putc(0x08 + (UZURA_VOLUME_INPUT(p).left   >> 29));
-    lcd_putc(0x08 + (UZURA_VOLUME_INPUT(p).right  >> 29));
-    lcd_putc(0x08 + (UZURA_VOLUME_OUTPUT(p).left  >> 29));
-    lcd_putc(0x08 + (UZURA_VOLUME_OUTPUT(p).right >> 29));
-    lcd_putc(0x08 + (UZURA_VOLUME_INPUT(p).left   >> 29));
-    lcd_putc(0x08 + (UZURA_VOLUME_INPUT(p).right  >> 29));
-    lcd_putc(0x08 + (UZURA_VOLUME_OUTPUT(p).left  >> 29));
-    lcd_putc(0x08 + (UZURA_VOLUME_OUTPUT(p).right >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_INPUT(p).left   >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_INPUT(p).right  >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_OUTPUT(p).left  >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_OUTPUT(p).right >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_INPUT(p).left   >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_INPUT(p).right  >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_OUTPUT(p).left  >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_OUTPUT(p).right >> 29));
 
 #define SCROLL_SPEED    (16)
     static uint8_t divcnt = 0;