ノイズを付加した正弦波発生器 Sinusoidal wave generator with noise.
Dependencies: F746_GUI F746_SAI_IO Random mbed
MyFiles/WaveformDisplay.cpp
- Committer:
- MikamiUitOpen
- Date:
- 2018-11-04
- Revision:
- 0:31361b0fcdad
File content as of revision 0:31361b0fcdad:
//----------------------------------------------------------- // Class for waveform display // // 2018/11/03, Copyright (c) 2018 MIKAMI, Naoki //----------------------------------------------------------- #include "WaveformDisplay.hpp" namespace Mikami { void WaveformDisplay::Execute(int start, int factor) { Axis(); dt_ = factor; Draw(xn_, start, LINE_COLOR1_); 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::Draw(const Array<int16_t>& xn, int start, uint32_t color) { lcd_.SetTextColor(color); uint16_t x1 = X0_; uint16_t y1 = Clip(xn[start]); for (int n=1; n<N_DATA_/dt_; n++) { uint16_t x2 = X0_ + n*dt_; uint16_t y2 = Clip(xn[start+n]); lcd_.DrawLine(x1, y1, x2, y2); x1 = x2; y1 = y2; } } 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_); } }