San Yune / Mbed 2 deprecated Chapter003_TRobot

Dependencies:   F746_GUI Array_Matrix TS_DISCO_F746NG mbed LCD_DISCO_F746NG BSP_DISCO_F746NG SDFileSystem_Warning_Fixed FrequencyResponseDrawer F746_SAI_IO

Files at this revision

API Documentation at this revision

Comitter:
MikamiUitOpen
Date:
Mon Apr 25 00:49:09 2016 +0000
Parent:
1:cc2669b9d1e2
Child:
3:cda40218256c
Commit message:
3

Changed in this revision

MyClasses_Functions/DesignerDrawer.cpp Show annotated file Show diff for this revision Revisions of this file
MyClasses_Functions/DesignerDrawer.hpp Show annotated file Show diff for this revision Revisions of this file
MyClasses_Functions/FrquencyResponseDrawer.cpp Show annotated file Show diff for this revision Revisions of this file
MyClasses_Functions/FrquencyResponseDrawer.hpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/MyClasses_Functions/DesignerDrawer.cpp	Wed Apr 20 12:10:17 2016 +0000
+++ b/MyClasses_Functions/DesignerDrawer.cpp	Mon Apr 25 00:49:09 2016 +0000
@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------
 //  IIR フィルタを双一次 z 変換で設計し,その周波数特性を描画するためのクラス
 //  
-//  2016/04/19, Copyright (c) 2016 MIKAMI, Naoki
+//  2016/04/25, Copyright (c) 2016 MIKAMI, Naoki
 //------------------------------------------------------------------------------
 
 #include "DesignerDrawer.hpp"
@@ -10,17 +10,17 @@
 {
     // Constructor
     DesignerDrawer::DesignerDrawer(uint16_t x0, uint16_t y0,
-                                   uint16_t db10, int fs, int order,
+                                   uint16_t db1, int fs, int order,
                                    float fc, uint16_t fL, uint16_t fH,
                                    BilinearDesign::Type lpHp)
         : lcd_(GuiBase::GetLcdPtr()), ts_(GuiBase::GetTsPtr()),
-          X0_(x0), Y0_(y0), DB10_(db10), ORDER_(order),
-          CURSOR_Y0_(y0+1-db10*6), CURSOR_LENGTH_(db10*6-1),
+          X0_(x0), Y0_(y0), DB1_(db1), ORDER_(order),
+          CURSOR_Y0_(y0+1-db1*60), CURSOR_LENGTH_(db1*60-1),
           LOWER_F_(fL), HIGHER_F_(fH),
           CURSOR_COLOR_(0xFFE000D0), CURSOR_TOUCHED_COLOR_(0xFFFF80FF)
     {
         drawerObj_ = new FrqRespDrawer(x0, 100.0f, 20000.0f, 140,
-                                       y0, -60, 0, db10, fs);
+                                       y0, -60, 0, db1, 10, fs);
 
         // 双一次 z 変換による IIR フィルタの設計
         designObj_ = new BilinearDesign(order, fs);
@@ -101,8 +101,8 @@
         FrqRespDrawer::AxisX_Char numX[] =  // 横軸の目盛値を描画する際に使う構造体の配列
             {{  100, "0.1"}, {  200, "0.2"}, {  500, "0.5"}, { 1000,  "1"},
              { 2000,   "2"}, { 5000,   "5"}, {10000,  "10"}, {20000, "20"}};
-        drawerObj_->DrawNumericX(numX, 8, 6, "Frequency [kHz]"); // 横軸の目盛
-        drawerObj_->DrawNumericY(-24, -6, 4, 20, "%3d");         // 縦軸の目盛は 20 dB 間隔
+        drawerObj_->DrawNumericX(numX, 8, 6, "Frequency [kHz]");    // 横軸の目盛
+        drawerObj_->DrawNumericY(-24, -6, 20, "%3d");               // 縦軸の目盛は 20 dB 間隔
         drawerObj_->DrawGraph(frqResp_);    // 周波数特性のカーブの描画
 
         cursorX_ = drawerObj_->X(fC_);
--- a/MyClasses_Functions/DesignerDrawer.hpp	Wed Apr 20 12:10:17 2016 +0000
+++ b/MyClasses_Functions/DesignerDrawer.hpp	Mon Apr 25 00:49:09 2016 +0000
@@ -1,7 +1,7 @@
 //------------------------------------------------------------------------------
 //  IIR フィルタを双一次 z 変換で設計し,その周波数特性を描画するためのクラス -- Header
 //  
-//  2016/04/19, Copyright (c) 2016 MIKAMI, Naoki
+//  2016/04/25, Copyright (c) 2016 MIKAMI, Naoki
 //------------------------------------------------------------------------------
 
 #ifndef F746_DISIGNER_AND_DRAWER_HPP
@@ -42,7 +42,7 @@
         TS_DISCO_F746NG *ts_;
 
         const uint16_t X0_, Y0_;
-        const uint16_t DB10_;
+        const uint16_t DB1_;
         const uint16_t ORDER_;
         const uint16_t CURSOR_Y0_, CURSOR_LENGTH_;
         const uint16_t LOWER_F_, HIGHER_F_;
--- a/MyClasses_Functions/FrquencyResponseDrawer.cpp	Wed Apr 20 12:10:17 2016 +0000
+++ b/MyClasses_Functions/FrquencyResponseDrawer.cpp	Mon Apr 25 00:49:09 2016 +0000
@@ -2,7 +2,7 @@
 //  周波数が対数スケールの周波数特性を描画するクラス
 //  FrqRespDrawer class
 //
-//  2016/04/18, Copyright (c) 2016 MIKAMI, Naoki
+//  2016/04/25, Copyright (c) 2016 MIKAMI, Naoki
 //-----------------------------------------------------------
 
 #include "FrquencyResponseDrawer.hpp"
@@ -36,8 +36,9 @@
         lcd_->DrawVLine(X(MAX_), y0, height);   // 最大値に対応する線
         
         uint16_t width = X(MAX_) - X(MIN_);
-        for (int n=0; n<= (MAX_DB_ - MIN_DB_)/10; n++)
-            lcd_->DrawHLine(X(MIN_), ORGY_-DB10_*n, width);
+        int count =Round((MAX_DB_ - MIN_DB_)/(Y_SPACE_/DB1_));
+        for (int n=0; n<= count; n++)
+            lcd_->DrawHLine(X(MIN_), ORGY_-Y_SPACE_*n, width);
     }
 
     // 横軸の目盛値の表示
@@ -51,17 +52,19 @@
         Label l_frq(x0, ORGY_+20, str, Label::CENTER);
     }
 
-    // 縦軸の数値の表示
-    void FrqRespDrawer::DrawNumericY(int offsetX, int offsetY, int count,
-                                     uint16_t d_dB, const char fmt[], sFONT &fonts,
+    // 縦軸の目盛値の表示
+    void FrqRespDrawer::DrawNumericY(int offsetX, int offsetY, uint16_t d_dB,
+                                     const char fmt[], sFONT &fonts,
                                      uint32_t textColor, string str)
     {
         uint16_t x0 = ORGX_ + offsetX;
         uint16_t y0 = ORGY_ + offsetY;
-        for (int n=0; n<count; n++)
+        int count = Round((MAX_DB_ - MIN_DB_)/d_dB);
+
+        for (int n=0; n<=count; n++)
             NumericLabel<int> num(x0, y0-n*d_dB*DB1_,
                                   fmt, (int)(MIN_DB_+d_dB*n));
-        Label l_dB(x0, y0-(count-1)*d_dB*DB1_-12, str);
+        Label l_dB(x0, y0-count*d_dB*DB1_-12, str);
     }
 
     // 周波数特性のグラフの描画
--- a/MyClasses_Functions/FrquencyResponseDrawer.hpp	Wed Apr 20 12:10:17 2016 +0000
+++ b/MyClasses_Functions/FrquencyResponseDrawer.hpp	Mon Apr 25 00:49:09 2016 +0000
@@ -2,7 +2,7 @@
 //  周波数が対数スケールの周波数特性を描画するクラス
 //  FrqRespDrawer class Header
 //
-//  2016/04/19, Copyright (c) 2016 MIKAMI, Naoki
+//  2016/04/25, Copyright (c) 2016 MIKAMI, Naoki
 //-----------------------------------------------------------
 
 #ifndef F746_FRQ_RESP_DRAWER_HPP
@@ -21,19 +21,18 @@
         
         // Constructor
         FrqRespDrawer(uint16_t org, float min, float max, uint16_t dec,
-                      uint16_t orgY, float minDb, float maxDb, uint16_t db10,
-                      float fs,
+                      uint16_t orgY, float minDb, float maxDb,
+                      float db1Pixel, float ySpace, float fs,
                       uint32_t lineColor = 0xFF00B0FF,
                       uint32_t axisColor = LCD_COLOR_LIGHTGRAY,
                       uint32_t backColor = GuiBase::ENUM_BACK)
             : lcd_(GuiBase::GetLcdPtr()),
               ORGX_(org), MIN_(min), MAX_(max), DEC_(dec),
-              ORGY_(orgY), MIN_DB_(minDb), MAX_DB_(maxDb), DB10_(db10),
-              FS_(fs),
+              ORGY_(orgY), MIN_DB_(minDb), MAX_DB_(maxDb),
+              DB1_(db1Pixel), Y_SPACE_(db1Pixel*ySpace), FS_(fs),
               LINE_COLOR_(lineColor),
               AXIS_COLOR_(axisColor),
-              BACK_COLOR_(backColor),
-              DB1_(db10*0.1f) {}
+              BACK_COLOR_(backColor) {}
 
         // 周波数に対応する x 座標値の取得
         int X(float frq)
@@ -52,8 +51,8 @@
                           uint32_t textColor = LCD_COLOR_WHITE);
 
         // 縦軸の目盛値の表示
-        void DrawNumericY(int offsetX, int offsetY, int count,
-                          uint16_t d_dB, const char fmt[], sFONT &fonts = Font12,
+        void DrawNumericY(int offsetX, int offsetY, uint16_t d_dB,
+                          const char fmt[], sFONT &fonts = Font12,
                           uint32_t textColor = LCD_COLOR_WHITE,
                           string str = "[dB]");
 
@@ -74,12 +73,12 @@
         const uint16_t ORGY_;   // 縦軸の目盛の最小値に対応する位置
         const float MIN_DB_;    // 縦軸の目盛の最小値 [dB]
         const float MAX_DB_;    // 縦軸の目盛の最大値 [dB]
-        const uint16_t DB10_;   // 10 dB 対応する長さ (pixels)
+        const float DB1_;       // 1 dB に対応する pixels 数
+        const float Y_SPACE_;   // 縦軸の目盛線の間隔に対応する pixels 数
         const float FS_;        // 標本化周波数
         const uint32_t LINE_COLOR_;
         const uint32_t AXIS_COLOR_;
         const uint32_t BACK_COLOR_;
-        const float DB1_;
         
         // 丸め
         int Round(float x) { return x + 0.5f - (x < 0); }  
@@ -94,4 +93,3 @@
     };
 }
 #endif  // F746_FRQ_RESP_DRAWER_HPP
-
--- a/main.cpp	Wed Apr 20 12:10:17 2016 +0000
+++ b/main.cpp	Mon Apr 25 00:49:09 2016 +0000
@@ -3,8 +3,9 @@
 //      SD のファイル: *.wav
 //                   PCM,16 ビットステレオ,標本化周波数 44.1 kHz
 //      IIR フィルタ ---- 低域通過および高域通過フィルタ
+//      出力:モノラル    
 //
-//  2016/04/20, Copyright (c) 2016 MIKAMI, Naoki
+//  2016/04/25, Copyright (c) 2016 MIKAMI, Naoki
 //--------------------------------------------------------------
 
 #include "MyFunctions.hpp"
@@ -53,7 +54,7 @@
     DesignerDrawer drawerObj(
                      45,        // グラフの左端の位置
                      230,       // グラフの下端の位置
-                     30,        // 10 dB 当たりのピクセル数
+                     3,         // 1 dB 当たりのピクセル数
                      FS,        // 標本化周波数
                      ORDER,     // フィルタの次数
                      400,       // 最初に与える遮断周波数
@@ -164,4 +165,3 @@
         sdReader.Close();   // SD のファイルのクローズ
     }
 }
-