FrqRespDrawer class to draw frequency response for digital filter. ディジタルフィルタの周波数特性を,周波数軸をログスケールで描画するための FrqRespDrawer クラス. このライブラリを登録した際のプログラム:「F746_FrequencyResponseDrawer_Demo」

Dependents:   F746_SD_WavPlayer F746_SD_GraphicEqualizer_ren0620 F746_FrequencyResponseDrawer_Demo F746_SD_VarableFilter ... more

Files at this revision

API Documentation at this revision

Comitter:
MikamiUitOpen
Date:
Thu Mar 16 08:47:52 2017 +0000
Parent:
3:5a057b32802b
Commit message:
5

Changed in this revision

FrquencyResponseDrawer.cpp Show annotated file Show diff for this revision Revisions of this file
FrquencyResponseDrawer.hpp Show annotated file Show diff for this revision Revisions of this file
--- a/FrquencyResponseDrawer.cpp	Tue Nov 08 13:06:28 2016 +0000
+++ b/FrquencyResponseDrawer.cpp	Thu Mar 16 08:47:52 2017 +0000
@@ -2,7 +2,7 @@
 //  ディジタルフィルタの周波数特性を,周波数軸が対数スケールで描画するクラス
 //  FrqRespDrawer class
 //
-//  2016/07/24, Copyright (c) 2016 MIKAMI, Naoki
+//  2017/03/16, Copyright (c) 2017 MIKAMI, Naoki
 //------------------------------------------------------------------------
 
 #include "FrquencyResponseDrawer.hpp"
@@ -16,9 +16,9 @@
         int logMin = (int)floorf(log10f(MIN_));
         int loop = (int)floorf(log10f(MAX_)) - logMin;
 
-        lcd_->SetTextColor(AXIS_COLOR_);
+        lcd_.SetTextColor(AXIS_COLOR_);
         uint16_t y0 = ORGY_ - height;
-        lcd_->DrawVLine(X(MIN_), y0, height);   // 最小値に対応する線
+        lcd_.DrawVLine(X(MIN_), y0, height);   // 最小値に対応する線
 
         float du = powf(10.0, logMin);          // 座標値の増分
         float u1 = (floorf(MIN_/du) + 1.0f)*du; // 最小値に対応する線の次の座標値
@@ -27,18 +27,18 @@
         {
             float uMax = (10.0f*du < MAX_) ? 10.0f*du : MAX_;
             for (float u=u1; u<uMax*0.99f; u+=du)
-                lcd_->DrawVLine(X(u), y0, height);
+                lcd_.DrawVLine(X(u), y0, height);
 
             du = uMax;          // 値の増分を 10 倍する
             u1 = du;            // 次の for ループ の最初の値
         }
 
-        lcd_->DrawVLine(X(MAX_), y0, height);   // 最大値に対応する線
+        lcd_.DrawVLine(X(MAX_), y0, height);   // 最大値に対応する線
         
         uint16_t width = X(MAX_) - X(MIN_);
         int count = Round((MAX_DB_ - MIN_DB_)/(Y_SPACE_/DB1_));
         for (int n=0; n<= count; n++)
-            lcd_->DrawHLine(X(MIN_), Round(ORGY_-Y_SPACE_*n), width);
+            lcd_.DrawHLine(X(MIN_), Round(ORGY_-Y_SPACE_*n), width);
     }
 
     // 横軸の目盛値の表示
@@ -70,7 +70,7 @@
     // 周波数特性のグラフの描画
     void FrqRespDrawer::DrawGraph(FrequencyResponse &frqResp, uint32_t color)
     {
-        lcd_->SetTextColor(color);
+        lcd_.SetTextColor(color);
         uint16_t width = X(MAX_) - X(MIN_);   
         uint16_t x1 = 0;
         uint16_t y1 = 0;
@@ -84,20 +84,20 @@
             uint16_t y2 = ORGY_ - Round((dB - MIN_DB_)*DB1_);
             if (y2 > ORGY_) y2 = ORGY_;
 
-            if (n != 0) lcd_->DrawLine(x1, y1, x2, y2);
+            if (n != 0) lcd_.DrawLine(x1, y1, x2, y2);
 
             x1 = x2;
             y1 = y2;
         }
-        lcd_->SetTextColor(AXIS_COLOR_);
-        lcd_->DrawHLine(X(MIN_), ORGY_, width+1);
+        lcd_.SetTextColor(AXIS_COLOR_);
+        lcd_.DrawHLine(X(MIN_), ORGY_, width+1);
     }
 
     // 消去
     void FrqRespDrawer::Erase(float upDb)
     {
-        lcd_->SetTextColor(BACK_COLOR_);
+        lcd_.SetTextColor(BACK_COLOR_);
         uint16_t height = DB1_*(MAX_DB_+upDb - MIN_DB_);
-        lcd_->FillRect(ORGX_, ORGY_- height, X(MAX_)-X(MIN_)+1, height+1);
+        lcd_.FillRect(ORGX_, ORGY_- height, X(MAX_)-X(MIN_)+1, height+1);
     }
 }
--- a/FrquencyResponseDrawer.hpp	Tue Nov 08 13:06:28 2016 +0000
+++ b/FrquencyResponseDrawer.hpp	Thu Mar 16 08:47:52 2017 +0000
@@ -2,7 +2,7 @@
 //  ディジタルフィルタの周波数特性を,周波数軸が対数スケールで描画するクラス(ヘッダ)
 //  FrqRespDrawer class (header)
 //
-//  2016/07/24, Copyright (c) 2016 MIKAMI, Naoki
+//  2017/03/16, Copyright (c) 2017 MIKAMI, Naoki
 //------------------------------------------------------------------------
 
 #ifndef F746_FRQ_RESP_DRAWER_HPP
@@ -31,7 +31,7 @@
                       uint32_t lineColor = 0xFF00B0FF,
                       uint32_t axisColor = LCD_COLOR_LIGHTGRAY,
                       uint32_t backColor = GuiBase::ENUM_BACK)
-            : lcd_(GuiBase::GetLcdPtr()),
+            : lcd_(GuiBase::GetLcd()),
               ORGX_(orgX), MIN_(min), MAX_(max), DEC_(dec),
               ORGY_(orgY), MIN_DB_(minDb), MAX_DB_(maxDb),
               DB1_(db1Pixel), Y_SPACE_(db1Pixel*ySpace), FS_(fs),
@@ -71,7 +71,7 @@
         void Erase(float upDb = 0);
 
     private:
-        LCD_DISCO_F746NG *lcd_;
+        LCD_DISCO_F746NG &lcd_;
         const uint16_t ORGX_;   // 横軸の目盛の最小値に対応する位置
         const float MIN_;       // 横軸の目盛の最小値
         const float MAX_;       // 横軸の目盛の最大値