不韋 呂 / Mbed 2 deprecated F746_AudioIO_Demo

Dependencies:   BSP_DISCO_F746NG F746_GUI F746_SAI_IO LCD_DISCO_F746NG TS_DISCO_F746NG mbed

Files at this revision

API Documentation at this revision

Comitter:
MikamiUitOpen
Date:
Sat Jul 23 06:14:23 2016 +0000
Parent:
3:68f16dc80b68
Child:
5:d12a1fcf5ad1
Commit message:
5

Changed in this revision

F746_GUI.lib Show annotated file Show diff for this revision Revisions of this file
F746_SAI_IO.lib Show annotated file Show diff for this revision Revisions of this file
MyClasses_Functions/WaveformDisplay.hpp Show diff for this revision Revisions of this file
WaveformDisplay.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/F746_GUI.lib	Wed Jun 15 12:54:02 2016 +0000
+++ b/F746_GUI.lib	Sat Jul 23 06:14:23 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/MikamiUitOpen/code/F746_GUI/#687ec6183385
+http://mbed.org/users/MikamiUitOpen/code/F746_GUI/#483926be0cf1
--- a/F746_SAI_IO.lib	Wed Jun 15 12:54:02 2016 +0000
+++ b/F746_SAI_IO.lib	Sat Jul 23 06:14:23 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/MikamiUitOpen/code/F746_SAI_IO/#2170289dfe94
+https://developer.mbed.org/users/MikamiUitOpen/code/F746_SAI_IO/#20cc265d7aec
--- a/MyClasses_Functions/WaveformDisplay.hpp	Wed Jun 15 12:54:02 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-//-----------------------------------------------------------
-//  Class for waveform display
-//
-//  2016/05/03, Copyright (c) 2016 MIKAMI, Naoki
-//-----------------------------------------------------------
-
-#ifndef F746_WAVEFORM_DISPLAY_HPP
-#define F746_WAVEFORM_DISPLAY_HPP
-
-#include "mbed.h"
-
-namespace Mikami
-{
-    class WaveformDisplay
-    {
-    public:
-        WaveformDisplay(LCD_DISCO_F746NG *lcd,
-                        uint16_t x0, uint16_t y0, int nData,
-                        uint16_t rShift,
-                        uint32_t axisColor, uint32_t lineColor,
-                        uint32_t backColor)
-            : X0_(x0), Y0_(y0), N_DATA_(nData), R_SHIFT_(rShift),
-              AXIS_COLOR_(axisColor), LINE_COLOR_(lineColor),
-              BACK_COLOR_(backColor), lcd_(lcd) { Axis(); }
-        
-        void Execute(const int16_t xn[])
-        {
-            static const uint16_t LIMIT1 = Y0_ + LIMIT2_;
-            static const uint16_t LIMIT2 = Y0_ - LIMIT2_;
-            Axis();
-            lcd_->SetTextColor(LINE_COLOR_);
-            uint16_t x1 = X0_;
-            uint16_t y1 = Clip(xn[0]);
-            for (int n=1; n<N_DATA_; n++)
-            {
-                uint16_t x2 = X0_ + n;
-                uint16_t y2 = Clip(xn[n]);
-                if ( ((y2 == LIMIT1) && (y1 == LIMIT1)) ||
-                     ((y2 == LIMIT2) && (y1 == LIMIT2)) )
-                {   // Out of displaying boundaries
-                    lcd_->SetTextColor(LCD_COLOR_RED);
-                    lcd_->DrawHLine(x1, y1, 1);
-                    lcd_->SetTextColor(LINE_COLOR_);
-                }
-                else
-                    lcd_->DrawLine(x1, y1, x2, y2);
-                if ((y1 == LIMIT1) || (y1 == LIMIT2))
-                    lcd_->DrawPixel(x1, y1, LCD_COLOR_RED);
-                x1 = x2;
-                y1 = y2;
-            }
-            lcd_->SetTextColor(BACK_COLOR_);
-        }
-        
-    private:
-        const uint16_t X0_;
-        const uint16_t Y0_;
-        const int N_DATA_;
-        const uint16_t R_SHIFT_;
-        const uint32_t AXIS_COLOR_;
-        const uint32_t LINE_COLOR_;
-        const uint32_t BACK_COLOR_;
-        static const int LIMIT_ = 32;
-        static const int LIMIT2_ = LIMIT_ + 1;
-        
-        LCD_DISCO_F746NG *lcd_;
-        
-        // Clipping
-        uint16_t Clip(int16_t xn)
-        {
-            int16_t x = xn >> R_SHIFT_;
-            if (x >  LIMIT_ ) x =  LIMIT2_;
-            if (x < -LIMIT_ ) x = -LIMIT2_ ;
-            return Y0_ - x;
-        }
-        
-        void Axis()
-        {
-            lcd_->SetTextColor(BACK_COLOR_);
-            lcd_->FillRect(X0_, Y0_-LIMIT2_, N_DATA_, LIMIT2_*2+1);
-
-            lcd_->SetTextColor(AXIS_COLOR_);
-            lcd_->DrawLine(X0_-5, Y0_, X0_+N_DATA_+5, Y0_);
-        }        
-
-        // disallow copy constructor and assignment operator
-        WaveformDisplay(const WaveformDisplay& );
-        WaveformDisplay& operator=(const WaveformDisplay& );
-    };
-}
-#endif  // F746_WAVEFORM_DISPLAY_HPP
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WaveformDisplay.hpp	Sat Jul 23 06:14:23 2016 +0000
@@ -0,0 +1,91 @@
+//-----------------------------------------------------------
+//  Class for waveform display
+//
+//  2016/05/03, Copyright (c) 2016 MIKAMI, Naoki
+//-----------------------------------------------------------
+
+#ifndef F746_WAVEFORM_DISPLAY_HPP
+#define F746_WAVEFORM_DISPLAY_HPP
+
+#include "mbed.h"
+
+namespace Mikami
+{
+    class WaveformDisplay
+    {
+    public:
+        WaveformDisplay(LCD_DISCO_F746NG *lcd,
+                        uint16_t x0, uint16_t y0, int nData,
+                        uint16_t rShift,
+                        uint32_t axisColor, uint32_t lineColor,
+                        uint32_t backColor)
+            : X0_(x0), Y0_(y0), N_DATA_(nData), R_SHIFT_(rShift),
+              AXIS_COLOR_(axisColor), LINE_COLOR_(lineColor),
+              BACK_COLOR_(backColor), lcd_(lcd) { Axis(); }
+        
+        void Execute(const int16_t xn[])
+        {
+            static const uint16_t LIMIT1 = Y0_ + LIMIT2_;
+            static const uint16_t LIMIT2 = Y0_ - LIMIT2_;
+            Axis();
+            lcd_->SetTextColor(LINE_COLOR_);
+            uint16_t x1 = X0_;
+            uint16_t y1 = Clip(xn[0]);
+            for (int n=1; n<N_DATA_; n++)
+            {
+                uint16_t x2 = X0_ + n;
+                uint16_t y2 = Clip(xn[n]);
+                if ( ((y2 == LIMIT1) && (y1 == LIMIT1)) ||
+                     ((y2 == LIMIT2) && (y1 == LIMIT2)) )
+                {   // Out of displaying boundaries
+                    lcd_->SetTextColor(LCD_COLOR_RED);
+                    lcd_->DrawHLine(x1, y1, 1);
+                    lcd_->SetTextColor(LINE_COLOR_);
+                }
+                else
+                    lcd_->DrawLine(x1, y1, x2, y2);
+                if ((y1 == LIMIT1) || (y1 == LIMIT2))
+                    lcd_->DrawPixel(x1, y1, LCD_COLOR_RED);
+                x1 = x2;
+                y1 = y2;
+            }
+            lcd_->SetTextColor(BACK_COLOR_);
+        }
+        
+    private:
+        const uint16_t X0_;
+        const uint16_t Y0_;
+        const int N_DATA_;
+        const uint16_t R_SHIFT_;
+        const uint32_t AXIS_COLOR_;
+        const uint32_t LINE_COLOR_;
+        const uint32_t BACK_COLOR_;
+        static const int LIMIT_ = 32;
+        static const int LIMIT2_ = LIMIT_ + 1;
+        
+        LCD_DISCO_F746NG *lcd_;
+        
+        // Clipping
+        uint16_t Clip(int16_t xn)
+        {
+            int16_t x = xn >> R_SHIFT_;
+            if (x >  LIMIT_ ) x =  LIMIT2_;
+            if (x < -LIMIT_ ) x = -LIMIT2_ ;
+            return Y0_ - x;
+        }
+        
+        void Axis()
+        {
+            lcd_->SetTextColor(BACK_COLOR_);
+            lcd_->FillRect(X0_, Y0_-LIMIT2_, N_DATA_, LIMIT2_*2+1);
+
+            lcd_->SetTextColor(AXIS_COLOR_);
+            lcd_->DrawLine(X0_-5, Y0_, X0_+N_DATA_+5, Y0_);
+        }        
+
+        // disallow copy constructor and assignment operator
+        WaveformDisplay(const WaveformDisplay& );
+        WaveformDisplay& operator=(const WaveformDisplay& );
+    };
+}
+#endif  // F746_WAVEFORM_DISPLAY_HPP
--- a/main.cpp	Wed Jun 15 12:54:02 2016 +0000
+++ b/main.cpp	Sat Jul 23 06:14:23 2016 +0000
@@ -1,20 +1,11 @@
-//----------------------------------------------------------------------
-//  CODEC を使い,MEMS マイクまたはライン (CN11) から入力した信号をそのまま
+//---------------------------------------------------
+//  CODEC を使い,MEMS マイクから入力した信号をそのまま
 //  リアルタイムでヘッドフォン出力 (CN10) へ出力する
-//      ディジタルフィルタなどの雛形として使える    
 //
-//  "stm32746g_discovery_audio.c" の BSP_AUDIO_IN_OUT_Init() 関数は
-//  INPUT_LINE_1 からの入力を禁止しているため,これを禁止しない関数として,
-//  BSP_AUDIO_IN_OUT_Init() の一部を修正し,MyBSP_AUDIO_IN_OUT_Init() 
-//  という関数を定義した.
-//  この MyBSP_AUDIO_IN_OUT_Init() は "MyBSP_AUDIO_IN_OUT_Init.hpp" で
-//  定義されている.
-//
-//  2016/06/15, Copyright (c) 2016 MIKAMI, Naoki
-//----------------------------------------------------------------------
+//  2016/07/23, Copyright (c) 2016 MIKAMI, Naoki
+//---------------------------------------------------
 
-#include "ButtonGroup.hpp"
-#include "Label.hpp"
+#include "F746_GUI.hpp"
 #include "WaveformDisplay.hpp"
 
 #include "SAI_InOut.hpp"
@@ -27,47 +18,43 @@
     const uint32_t LINE_COLOR = LCD_COLOR_CYAN;
 
     const uint32_t N_DATA = 400;
-    SaiIO mySai(SaiIO::BOTH, N_DATA, I2S_AUDIOFREQ_16K, INPUT_DEVICE_INPUT_LINE_1);
+    SaiIO mySai(SaiIO::BOTH, N_DATA, I2S_AUDIOFREQ_16K,
+                INPUT_DEVICE_DIGITAL_MICROPHONE_2);
+    
     
     LCD_DISCO_F746NG *lcd = GuiBase::GetLcdPtr();
     lcd->Clear(BACK_COLOR);
 
-    Label labelTitle(240, 10, "Demo of Audio I/O", Label::CENTER, Font16);
+    Label labelTitle(240, 10, "Demo of Audio I/O 18:48", Label::CENTER, Font16);
 
     const uint16_t BG_LEFT = 370;
     const uint16_t BG_WIDTH = 110;
     const uint16_t BG_HEIGHT = 40;
 
-    const string INPUT[2] = {"MIC", "LINE"};
-    ButtonGroup inSw(BG_LEFT, 180, BG_WIDTH/2, BG_HEIGHT,
-                     2, INPUT, 0, 0, 2, 1);
-
-    const string RUN_STOP[2] = {"RUN", "STOP"};
     ButtonGroup runStop(BG_LEFT, 230, BG_WIDTH/2, BG_HEIGHT,
-                         2, RUN_STOP, 0, 0, 2, 0);
+                        2, (string[]){"RUN", "STOP"}, 0, 0, 2, 0);
 
     lcd->SetTextColor(LCD_COLOR_WHITE);
     lcd->SetFont(&Font16);
 
     const int X_WAV = 30;   // Origin for x axis of waveform
-    const int Y_WAV = 60;   // Origin for y axis of waveform
+    const int Y_WAV = 80;   // Origin for y axis of waveform
     WaveformDisplay waveDispL(lcd, X_WAV, Y_WAV, N_DATA, 7,
                               AXIS_COLOR, LINE_COLOR, BACK_COLOR);
-    WaveformDisplay waveDispR(lcd, X_WAV, Y_WAV+60, N_DATA, 7,
+    WaveformDisplay waveDispR(lcd, X_WAV, Y_WAV+80, N_DATA, 7,
                               AXIS_COLOR, LINE_COLOR, BACK_COLOR);
     Label labelL(445, Y_WAV- 8, "L", Label::LEFT, Font16);
-    Label labelR(445, Y_WAV+52, "R", Label::LEFT, Font16);
+    Label labelR(445, Y_WAV+72, "R", Label::LEFT, Font16);
 
     int16_t snL[N_DATA];
     int16_t snR[N_DATA];
     bool on = true;
-    int inSelect = 1;   // input: line
 
     mySai.RecordIn();
     mySai.PlayOut();
     bool run = true;    // run
 
-    while(1)
+    while (true)
     {
         int sw = 0;
         if (runStop.GetTouchedNumber(sw))
@@ -78,13 +65,6 @@
             run = on;
         }
 
-        int swNow;
-        if (inSw.GetTouchedNumber(swNow) && (swNow != inSelect))
-        {
-            mySai.SwitchInputDevice(swNow);
-            inSelect = swNow;
-        }
-
         if (mySai.IsCompleted())
         {
             for (int n=0; n<mySai.GetLength(); n++)
--- a/mbed.bld	Wed Jun 15 12:54:02 2016 +0000
+++ b/mbed.bld	Sat Jul 23 06:14:23 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/aae6fcc7d9bb
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34
\ No newline at end of file