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
Diff: MyClasses_Functions/SpectrumDisplay.cpp
- Revision:
- 1:ac0a67a0deec
- Parent:
- 0:0e5131366580
- Child:
- 4:2cdaad00d208
--- 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]");
}
}
+