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
WaveformDisplay.cpp
00001 //----------------------------------------------------------- 00002 // Class for waveform display 00003 // 00004 // 2017/03/17, Copyright (c) 2017 MIKAMI, Naoki 00005 //----------------------------------------------------------- 00006 00007 #include "WaveformDisplay.hpp" 00008 00009 namespace Mikami 00010 { 00011 void WaveformDisplay::Execute() 00012 { 00013 uint16_t lim1 = Y0_ + LIMIT2_; 00014 uint16_t lim2 = Y0_ - LIMIT2_; 00015 Axis(); 00016 lcd_.SetTextColor(LINE_COLOR_); 00017 uint16_t x1 = X0_; 00018 uint16_t y1 = Clip(xn_[0]); 00019 for (int n=1; n<N_DATA_; n++) 00020 { 00021 uint16_t x2 = X0_ + n; 00022 uint16_t y2 = Clip(xn_[n]); 00023 if ( ((y2 == lim1) && (y1 == lim1)) || 00024 ((y2 == lim2) && (y1 == lim2)) ) 00025 { // Out of displaying boundaries 00026 lcd_.SetTextColor(LCD_COLOR_RED); 00027 lcd_.DrawHLine(x1, y1, 1); 00028 lcd_.SetTextColor(LINE_COLOR_); 00029 } 00030 else 00031 lcd_.DrawLine(x1, y1, x2, y2); 00032 if ((y1 == lim1) || (y1 == lim2)) 00033 lcd_.DrawPixel(x1, y1, LCD_COLOR_RED); 00034 x1 = x2; 00035 y1 = y2; 00036 } 00037 lcd_.SetTextColor(BACK_COLOR_); 00038 } 00039 00040 // Clipping 00041 uint16_t WaveformDisplay::Clip(int16_t xn) 00042 { 00043 int16_t x = xn >> R_SHIFT_; 00044 if (x > LIMIT_ ) x = LIMIT2_; 00045 if (x < -LIMIT_ ) x = -LIMIT2_ ; 00046 return Y0_ - x; 00047 } 00048 00049 void WaveformDisplay::Axis() 00050 { 00051 lcd_.SetTextColor(BACK_COLOR_); 00052 lcd_.FillRect(X0_, Y0_-LIMIT2_, N_DATA_, LIMIT2_*2+1); 00053 00054 lcd_.SetTextColor(AXIS_COLOR_); 00055 lcd_.DrawLine(X0_-5, Y0_, X0_+N_DATA_+5, Y0_); 00056 } 00057 }
Generated on Fri Jul 22 2022 14:41:57 by
1.7.2