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:
- 4:2cdaad00d208
- Parent:
- 1:ac0a67a0deec
--- a/MyClasses_Functions/SpectrumDisplay.cpp Fri Jan 08 13:03:24 2016 +0000
+++ b/MyClasses_Functions/SpectrumDisplay.cpp Sun Jan 10 09:58:43 2016 +0000
@@ -1,7 +1,7 @@
//-------------------------------------------------------
// Class for display spectrum
//
-// 2016/01/07, Copyright (c) 2015 MIKAMI, Naoki
+// 2016/01/10, Copyright (c) 2015 MIKAMI, Naoki
//-------------------------------------------------------
#include "SpectrumDisplay.hpp"
@@ -26,19 +26,30 @@
void SpectrumDisplay::Draw(float db[])
{
+ static const int TOP = Y0_ - (int)(MAX_DB_*DB1_);
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;
+ if (h > MAX_DB_) h = MAX_DB_;
int y1 = Y0_ - (int)(h*DB1_);
+ lcd_.SetTextColor(LINE_COLOR_);
for (int n=1; n<N_FFT_/2; n++)
{
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_);
- lcd_.DrawLine(X0_+n, y1, X0_+n+1, y2);
+
+ if ( (y1 <= TOP) && (y2 <= TOP) )
+ { // Out of displaying boundaries
+ lcd_.SetTextColor(LCD_COLOR_RED);
+ lcd_.DrawHLine(X0_+n, TOP, 1);
+ lcd_.SetTextColor(LINE_COLOR_);
+ }
+ else
+ lcd_.DrawLine(X0_+n, y1, X0_+n+1, y2);
+ if (y1 <= TOP) lcd_.DrawPixel(X0_+n, y1, LCD_COLOR_RED);
y1 = y2;
}
lcd_.SetTextColor(AXIS_COLOR_);