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 F746_GUI F746_SAI_IO LCD_DISCO_F746NG TS_DISCO_F746NG mbed
Diff: MyClasses/WaveformDisplay.cpp
- Revision:
- 0:e2c6c8630aab
- Child:
- 2:afff5ec35233
diff -r 000000000000 -r e2c6c8630aab MyClasses/WaveformDisplay.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MyClasses/WaveformDisplay.cpp Sun Jul 24 11:33:55 2016 +0000
@@ -0,0 +1,57 @@
+//-----------------------------------------------------------
+// Class for waveform display
+//
+// 2016/07/23, Copyright (c) 2016 MIKAMI, Naoki
+//-----------------------------------------------------------
+
+#include "WaveformDisplay.hpp"
+
+namespace Mikami
+{
+ void WaveformDisplay::Execute()
+ {
+ 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_);
+ }
+
+ // Clipping
+ uint16_t WaveformDisplay::Clip(int16_t xn)
+ {
+ int16_t x = xn >> R_SHIFT_;
+ if (x > LIMIT_ ) x = LIMIT2_;
+ if (x < -LIMIT_ ) x = -LIMIT2_ ;
+ return Y0_ - x;
+ }
+
+ void WaveformDisplay::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_);
+ }
+}