Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_DISCO_F746NG BUTTON_GROUP LCD_DISCO_F746NG TS_DISCO_F746NG UIT_FFT_Real mbed
Revision 1:ac0a67a0deec, committed 2016-01-07
- Comitter:
- MikamiUitOpen
- Date:
- Thu Jan 07 00:26:31 2016 +0000
- Parent:
- 0:0e5131366580
- Child:
- 2:5644475f01ea
- Commit message:
- 2
Changed in this revision
--- a/MyClasses_Functions/SpectrumDisplay.cpp Wed Jan 06 12:46:15 2016 +0000
+++ b/MyClasses_Functions/SpectrumDisplay.cpp Thu Jan 07 00:26:31 2016 +0000
@@ -1,7 +1,7 @@
//-------------------------------------------------------
// Class for display spectrum
//
-// 2015/12/11, Copyright (c) 2015 MIKAMI, Naoki
+// 2016/01/07, Copyright (c) 2015 MIKAMI, Naoki
//-------------------------------------------------------
#include "SpectrumDisplay.hpp"
@@ -10,11 +10,11 @@
{
SpectrumDisplay::SpectrumDisplay(
LCD_DISCO_F746NG &lcd,
- int nFft, int x0, int y0,
+ int nFft, int x0, int y0, float offset,
float db1, int bin, float maxDb, int fs,
uint32_t axisColor, uint32_t lineColor,
uint32_t backColor)
- : N_FFT_(nFft), X0_(x0), Y0_(y0),
+ : N_FFT_(nFft), X0_(x0), Y0_(y0), OFFSET_(offset),
DB1_(db1), BIN_(bin), MAX_DB_(maxDb),
FS_(fs), AXIS_COLOR_(axisColor),
LINE_COLOR_(lineColor), BACK_COLOR_(backColor),
@@ -26,16 +26,15 @@
void SpectrumDisplay::Draw(float db[])
{
- const float OFFSET = -50.0f;
lcd_.SetTextColor(BACK_COLOR_);
lcd_.FillRect(X0_+1, Y0_-(int)(MAX_DB_*DB1_),
N_FFT_*BIN_/2, MAX_DB_*DB1_);
- float h = ((db[1] + OFFSET) > 0)? db[1] + OFFSET : 0;
+ float h = ((db[1] + OFFSET_) > 0)? db[1] + OFFSET_ : 0;
int y1 = Y0_ - (int)(h*DB1_);
for (int n=1; n<N_FFT_/2; n++)
{
- float h2 = ((db[n+1] + OFFSET) > 0)? db[n+1] + OFFSET : 0;
+ float h2 = ((db[n+1] + OFFSET_) > 0)? db[n+1] + OFFSET_ : 0;
if (h2 > MAX_DB_) h2 = MAX_DB_;
int y2 = Y0_ - (int)(h2*DB1_);
lcd_.SetTextColor(LINE_COLOR_);
@@ -91,3 +90,4 @@
DrawString(X0_-27, Y0_-(int)(DB1_*MAX_DB_)-18, "[dB]");
}
}
+
--- a/MyClasses_Functions/SpectrumDisplay.hpp Wed Jan 06 12:46:15 2016 +0000
+++ b/MyClasses_Functions/SpectrumDisplay.hpp Thu Jan 07 00:26:31 2016 +0000
@@ -1,7 +1,7 @@
//-------------------------------------------------------
// Class for display spectrum (Header)
//
-// 2015/12/15, Copyright (c) 2015 MIKAMI, Naoki
+// 2016/01/07, Copyright (c) 2015 MIKAMI, Naoki
//-------------------------------------------------------
#ifndef SPECTRUM_DISPLAY_HPP
@@ -15,7 +15,7 @@
{
public:
SpectrumDisplay(LCD_DISCO_F746NG &lcd,
- int nFft, int x0, int y0,
+ int nFft, int x0, int y0, float offset,
float db1, int bin, float maxDb, int fs,
uint32_t axisColor, uint32_t lineColor,
uint32_t backColor);
@@ -27,6 +27,7 @@
const int N_FFT_; // number of date for FFT
const int X0_; // Origin for x axis
const int Y0_; // Origin for y axis
+ const float OFFSET_; // Offset for display
const float DB1_; // Pixels for 1 dB
const int BIN_; // Pixels per bin
const float MAX_DB_; // Maximum dB
--- a/MyClasses_Functions/WaveformDisplay.hpp Wed Jan 06 12:46:15 2016 +0000
+++ b/MyClasses_Functions/WaveformDisplay.hpp Thu Jan 07 00:26:31 2016 +0000
@@ -1,7 +1,7 @@
//-----------------------------------------------------------
// Class for waveform display
//
-// 2015/12/15, Copyright (c) 2015 MIKAMI, Naoki
+// 2015/01/07, Copyright (c) 2015 MIKAMI, Naoki
//-----------------------------------------------------------
#ifndef F746_WAVEFORM_DISPLAY_HPP
@@ -28,11 +28,11 @@
Axis();
lcd_.SetTextColor(LINE_COLOR_);
uint16_t x1 = X0_;
- uint16_t y1 = Y0_ - (xn[0] >> R_SHIFT_);
+ uint16_t y1 = Clip(xn[0]);
for (int n=1; n<N_DATA_; n++)
{
uint16_t x2 = X0_ + n;
- uint16_t y2 = Y0_ - (xn[n] >> R_SHIFT_);
+ uint16_t y2 = Clip(xn[n]);
lcd_.DrawLine(x1, y1, x2, y2);
x1 = x2;
y1 = y2;
@@ -47,9 +47,18 @@
const uint32_t AXIS_COLOR_;
const uint32_t LINE_COLOR_;
const uint32_t BACK_COLOR_;
-
+
LCD_DISCO_F746NG& lcd_;
+ // Clipping
+ uint16_t Clip(int16_t xn)
+ {
+ int16_t x = xn >> R_SHIFT_;
+ if (x > 32) x = 32;
+ if (x < -32) x = -32;
+ return Y0_ - x;
+ }
+
void Axis()
{
lcd_.SetTextColor(BACK_COLOR_);
--- a/MyClasses_Functions/functions_for_audio.cpp Wed Jan 06 12:46:15 2016 +0000
+++ b/MyClasses_Functions/functions_for_audio.cpp Thu Jan 07 00:26:31 2016 +0000
@@ -70,3 +70,4 @@
}
}
}
+
--- a/main.cpp Wed Jan 06 12:46:15 2016 +0000
+++ b/main.cpp Thu Jan 07 00:26:31 2016 +0000
@@ -62,14 +62,14 @@
method.DrawAll(INACTIVE_COLOR, INACTIVE_TEXT_COLOR);
// End of button group setting
- WaveformDisplay waveDisp(lcd, X_WAV, Y_WAV, N_DATA, 10,
+ WaveformDisplay waveDisp(lcd, X_WAV, Y_WAV, N_DATA, 9,
AXIS_COLOR, LINE_COLOR, BACK_COLOR);
- SpectrumDisplay disp(lcd, N_FFT, X0, Y0, DB1, BIN, W_DB, FS,
+ SpectrumDisplay disp(lcd, N_FFT, X0, Y0, -40, DB1, BIN, W_DB, FS,
AXIS_COLOR, LINE_COLOR, BACK_COLOR);
- // Linear prediction: order = 12
+ // Linear prediction: order = 10
// Cepstral smoothing: highest quefrency = 40
- Selector analyzer(disp, N_DATA, N_FFT, 12, 40);
+ Selector analyzer(disp, N_DATA, N_FFT, 10, 40);
// Initialize the infinite loop procedure
int select = -1;
@@ -133,4 +133,3 @@
}
}
}
-