Waveform display for input signal using SAI from MEMS microphone or line. MEMS マイクまたはラインから SAI により入力した信号の波形を表示する.
Dependencies: BSP_DISCO_F746NG F746_GUI F746_SAI_IO LCD_DISCO_F746NG TS_DISCO_F746NG mbed
MyClasses/WaveformDisplay.cpp
- Committer:
- MikamiUitOpen
- Date:
- 2016-07-24
- Revision:
- 0:e2c6c8630aab
- Child:
- 2:afff5ec35233
File content as of revision 0:e2c6c8630aab:
//----------------------------------------------------------- // 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_); } }