diff --git a/plugins/channelrx/demoddatv/datvconstellation.h b/plugins/channelrx/demoddatv/datvconstellation.h index 9cd92ecf3..3004a7196 100644 --- a/plugins/channelrx/demoddatv/datvconstellation.h +++ b/plugins/channelrx/demoddatv/datvconstellation.h @@ -20,6 +20,7 @@ #define DATVCONSTELLATION_H #include +#include #include "leansdr/framework.h" #include "gui/tvscreen.h" @@ -38,6 +39,8 @@ template struct datvconstellation: runnable TVScreen *m_objDATVScreen; pipereader > in; unsigned long phase; + std::vector cstln_rows; + std::vector cstln_cols; datvconstellation(scheduler *sch, pipebuf > &_in, T _xymin, T _xymax, const char *_name = 0, TVScreen *objDATVScreen = 0) : runnable(sch, _name ? _name : _in.name), @@ -45,7 +48,7 @@ template struct datvconstellation: runnable xymax(_xymax), decimation(DEFAULT_GUI_DECIMATION), pixels_per_frame(1024), - cstln(NULL), + cstln(0), m_objDATVScreen(objDATVScreen), in(_in), phase(0) @@ -66,9 +69,8 @@ template struct datvconstellation: runnable for (; p < pend; ++p) { - if (m_objDATVScreen != NULL) + if (m_objDATVScreen != 0) { - m_objDATVScreen->selectRow(256 * (p->re - xymin) / (xymax - xymin)); m_objDATVScreen->setDataColor(256 - 256 * ((p->im - xymin) / (xymax - xymin)), 255, 0, 255); } @@ -79,23 +81,17 @@ template struct datvconstellation: runnable { // Plot constellation points - for (int i = 0; i < (*cstln)->nsymbols; ++i) - { - complex *p = &(*cstln)->symbols[i]; - int x = 256 * (p->re - xymin) / (xymax - xymin); - int y = 256 - 256 * (p->im - xymin) / (xymax - xymin); + std::vector::const_iterator row_it = cstln_rows.begin(); + std::vector::const_iterator col_it = cstln_cols.begin(); - for (int d = -4; d <= 4; ++d) - { - m_objDATVScreen->selectRow(x + d); - m_objDATVScreen->setDataColor(y, 5, 250, 250); - m_objDATVScreen->selectRow(x); - m_objDATVScreen->setDataColor(y + d, 5, 250, 250); - } + for (; (row_it != cstln_rows.end()) && (col_it != cstln_cols.end()); ++row_it, ++col_it) + { + m_objDATVScreen->selectRow(*row_it); + m_objDATVScreen->setDataColor(*col_it, 250, 250, 5); } } - m_objDATVScreen->renderImage(NULL); + m_objDATVScreen->renderImage(0); } in.read(pixels_per_frame); @@ -111,6 +107,30 @@ template struct datvconstellation: runnable { } + void calculate_cstln_points() + { + if (!(*cstln)) { + return; + } + + cstln_rows.clear(); + cstln_cols.clear(); + + for (int i = 0; i < (*cstln)->nsymbols; ++i) + { + complex *p = &(*cstln)->symbols[i]; + int x = 256 * (p->re - xymin) / (xymax - xymin); + int y = 256 - 256 * (p->im - xymin) / (xymax - xymin); + + for (int d = -4; d <= 4; ++d) + { + cstln_rows.push_back(x + d); + cstln_cols.push_back(y); + cstln_rows.push_back(x); + cstln_cols.push_back(y + d); + } + } + } }; } diff --git a/plugins/channelrx/demoddatv/datvdemod.cpp b/plugins/channelrx/demoddatv/datvdemod.cpp index 25d78b408..87caea8b7 100644 --- a/plugins/channelrx/demoddatv/datvdemod.cpp +++ b/plugins/channelrx/demoddatv/datvdemod.cpp @@ -701,6 +701,7 @@ void DATVDemod::InitDATVFramework() r_scope_symbols = new leansdr::datvconstellation(m_objScheduler, *p_sampled, -128,128, NULL, m_objRegisteredTVScreen); r_scope_symbols->decimation = 1; r_scope_symbols->cstln = &m_objDemodulator->cstln; + r_scope_symbols->calculate_cstln_points(); } // DECONVOLUTION AND SYNCHRONIZATION