2018-02-22 16:52:49 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2023-11-18 06:02:48 -05:00
|
|
|
// Copyright (C) 2018-2019, 2021 Edouard Griffiths, F4EXB <f4exb06@gmail.com> //
|
2018-02-22 16:52:49 -05:00
|
|
|
// Copyright (C) 2018 F4HKW //
|
|
|
|
// for F4EXB / SDRAngel //
|
|
|
|
// using LeanSDR Framework (C) 2016 F4DAV //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
2019-04-11 00:39:30 -04:00
|
|
|
// (at your option) any later version. //
|
2018-02-22 16:52:49 -05:00
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef DATVCONSTELLATION_H
|
|
|
|
#define DATVCONSTELLATION_H
|
|
|
|
|
2018-03-14 19:58:18 -04:00
|
|
|
#include <vector>
|
2018-02-22 16:52:49 -05:00
|
|
|
|
|
|
|
#include "leansdr/framework.h"
|
2018-03-11 11:39:02 -04:00
|
|
|
#include "gui/tvscreen.h"
|
2018-02-22 16:52:49 -05:00
|
|
|
|
2019-03-16 20:36:44 -04:00
|
|
|
namespace leansdr {
|
2018-02-22 16:52:49 -05:00
|
|
|
|
2018-02-24 18:07:08 -05:00
|
|
|
static const int DEFAULT_GUI_DECIMATION = 64;
|
2018-02-22 16:52:49 -05:00
|
|
|
|
2019-07-14 09:35:45 -04:00
|
|
|
static inline cstln_lut<eucl_ss, 256> * make_dvbs_constellation(cstln_lut<eucl_ss, 256>::predef c,
|
2019-03-17 16:31:42 -04:00
|
|
|
code_rate r)
|
|
|
|
{
|
|
|
|
float gamma1 = 1, gamma2 = 1, gamma3 = 1;
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case cstln_lut<eucl_ss, 256>::APSK16:
|
|
|
|
// EN 302 307, section 5.4.3, Table 9
|
|
|
|
switch (r)
|
|
|
|
{
|
|
|
|
case FEC23:
|
|
|
|
case FEC46:
|
|
|
|
gamma1 = 3.15;
|
|
|
|
break;
|
|
|
|
case FEC34:
|
|
|
|
gamma1 = 2.85;
|
|
|
|
break;
|
|
|
|
case FEC45:
|
|
|
|
gamma1 = 2.75;
|
|
|
|
break;
|
|
|
|
case FEC56:
|
|
|
|
gamma1 = 2.70;
|
|
|
|
break;
|
|
|
|
case FEC89:
|
|
|
|
gamma1 = 2.60;
|
|
|
|
break;
|
|
|
|
case FEC910:
|
|
|
|
gamma1 = 2.57;
|
|
|
|
break;
|
|
|
|
default:
|
2019-07-14 09:35:45 -04:00
|
|
|
fail("cstln_lut<256>::make_dvbs_constellation: Code rate not supported with APSK16");
|
2019-03-17 16:31:42 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case cstln_lut<eucl_ss, 256>::APSK32:
|
|
|
|
// EN 302 307, section 5.4.4, Table 10
|
|
|
|
switch (r)
|
|
|
|
{
|
|
|
|
case FEC34:
|
|
|
|
gamma1 = 2.84;
|
|
|
|
gamma2 = 5.27;
|
|
|
|
break;
|
|
|
|
case FEC45:
|
|
|
|
gamma1 = 2.72;
|
|
|
|
gamma2 = 4.87;
|
|
|
|
break;
|
|
|
|
case FEC56:
|
|
|
|
gamma1 = 2.64;
|
|
|
|
gamma2 = 4.64;
|
|
|
|
break;
|
|
|
|
case FEC89:
|
|
|
|
gamma1 = 2.54;
|
|
|
|
gamma2 = 4.33;
|
|
|
|
break;
|
|
|
|
case FEC910:
|
|
|
|
gamma1 = 2.53;
|
|
|
|
gamma2 = 4.30;
|
|
|
|
break;
|
|
|
|
default:
|
2019-07-14 09:35:45 -04:00
|
|
|
fail("cstln_lut<eucl_ss, 256>::make_dvbs_constellation: Code rate not supported with APSK32");
|
2019-03-17 16:31:42 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case cstln_lut<eucl_ss, 256>::APSK64E:
|
|
|
|
// EN 302 307-2, section 5.4.5, Table 13f
|
|
|
|
gamma1 = 2.4;
|
|
|
|
gamma2 = 4.3;
|
|
|
|
gamma3 = 7;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2019-07-16 12:19:29 -04:00
|
|
|
cstln_lut<eucl_ss, 256> *newCstln = new cstln_lut<eucl_ss, 256>(c, 10, gamma1, gamma2, gamma3);
|
|
|
|
newCstln->m_rateCode = (int) r;
|
|
|
|
newCstln->m_typeCode = (int) c;
|
|
|
|
newCstln->m_setByModcod = false;
|
|
|
|
return newCstln;
|
2019-03-17 16:31:42 -04:00
|
|
|
}
|
|
|
|
|
2018-02-24 18:07:08 -05:00
|
|
|
template<typename T> struct datvconstellation: runnable
|
|
|
|
{
|
2018-02-25 19:04:45 -05:00
|
|
|
T xymin, xymax;
|
2018-02-24 18:07:08 -05:00
|
|
|
unsigned long decimation;
|
2019-03-17 16:31:42 -04:00
|
|
|
long pixels_per_frame;
|
|
|
|
cstln_lut<eucl_ss, 256> **cstln; // Optional ptr to optional constellation
|
2021-10-30 06:35:02 -04:00
|
|
|
TVScreen *m_tvScreen;
|
2021-03-28 23:25:32 -04:00
|
|
|
pipereader<std::complex<T> > in;
|
2018-02-24 18:07:08 -05:00
|
|
|
unsigned long phase;
|
2018-03-14 19:58:18 -04:00
|
|
|
std::vector<int> cstln_rows;
|
|
|
|
std::vector<int> cstln_cols;
|
2018-02-24 18:07:08 -05:00
|
|
|
|
2019-03-16 20:36:44 -04:00
|
|
|
datvconstellation(
|
|
|
|
scheduler *sch,
|
2021-03-28 23:25:32 -04:00
|
|
|
pipebuf<std::complex<T> > &_in,
|
2019-03-16 20:36:44 -04:00
|
|
|
T _xymin,
|
|
|
|
T _xymax,
|
|
|
|
const char *_name = nullptr,
|
2021-10-30 06:35:02 -04:00
|
|
|
TVScreen *tvScreen = nullptr) :
|
2019-03-16 20:36:44 -04:00
|
|
|
runnable(sch, _name ? _name : _in.name),
|
|
|
|
xymin(_xymin),
|
|
|
|
xymax(_xymax),
|
|
|
|
decimation(DEFAULT_GUI_DECIMATION),
|
|
|
|
pixels_per_frame(1024),
|
|
|
|
cstln(0),
|
2021-10-30 06:35:02 -04:00
|
|
|
m_tvScreen(tvScreen),
|
2019-03-16 20:36:44 -04:00
|
|
|
in(_in),
|
|
|
|
phase(0)
|
2018-02-24 18:07:08 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void run()
|
2018-02-22 16:52:49 -05:00
|
|
|
{
|
|
|
|
//Symbols
|
2018-02-24 18:07:08 -05:00
|
|
|
while (in.readable() >= pixels_per_frame)
|
2018-02-22 16:52:49 -05:00
|
|
|
{
|
2021-10-30 06:35:02 -04:00
|
|
|
if ((!phase) && m_tvScreen)
|
2018-02-22 16:52:49 -05:00
|
|
|
{
|
2021-10-30 06:35:02 -04:00
|
|
|
m_tvScreen->resetImage();
|
2018-02-22 16:52:49 -05:00
|
|
|
|
2021-03-28 23:25:32 -04:00
|
|
|
std::complex<T> *p = in.rd(), *pend = p + pixels_per_frame;
|
2018-02-22 16:52:49 -05:00
|
|
|
|
2018-02-24 18:07:08 -05:00
|
|
|
for (; p < pend; ++p)
|
2018-02-22 16:52:49 -05:00
|
|
|
{
|
2021-10-30 06:35:02 -04:00
|
|
|
m_tvScreen->selectRow(256 * (p->real() - xymin) / (xymax - xymin));
|
|
|
|
m_tvScreen->setDataColor(
|
2021-03-28 23:25:32 -04:00
|
|
|
256 - 256 * ((p->imag() - xymin) / (xymax - xymin)),
|
2019-03-16 20:36:44 -04:00
|
|
|
255, 0, 255);
|
2018-02-22 16:52:49 -05:00
|
|
|
}
|
|
|
|
|
2018-02-24 18:07:08 -05:00
|
|
|
if (cstln && (*cstln))
|
2018-02-22 16:52:49 -05:00
|
|
|
{
|
2018-02-24 18:07:08 -05:00
|
|
|
// Plot constellation points
|
2018-03-14 19:58:18 -04:00
|
|
|
std::vector<int>::const_iterator row_it = cstln_rows.begin();
|
|
|
|
std::vector<int>::const_iterator col_it = cstln_cols.begin();
|
|
|
|
|
2019-03-16 20:36:44 -04:00
|
|
|
for (;(row_it != cstln_rows.end()) && (col_it != cstln_cols.end()); ++row_it, ++col_it)
|
2018-02-22 16:52:49 -05:00
|
|
|
{
|
2021-10-30 06:35:02 -04:00
|
|
|
m_tvScreen->selectRow(*row_it);
|
|
|
|
m_tvScreen->setDataColor(*col_it, 250, 250, 5);
|
2018-02-22 16:52:49 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-30 06:35:02 -04:00
|
|
|
m_tvScreen->renderImage(0);
|
2018-02-22 16:52:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
in.read(pixels_per_frame);
|
|
|
|
|
2019-03-16 20:36:44 -04:00
|
|
|
if (++phase >= decimation) {
|
2018-02-22 16:52:49 -05:00
|
|
|
phase = 0;
|
|
|
|
}
|
2018-02-24 18:07:08 -05:00
|
|
|
}
|
|
|
|
}
|
2018-02-22 16:52:49 -05:00
|
|
|
|
2018-02-24 18:07:08 -05:00
|
|
|
void draw_begin()
|
|
|
|
{
|
|
|
|
}
|
2018-02-22 16:52:49 -05:00
|
|
|
|
2018-03-14 19:58:18 -04:00
|
|
|
void calculate_cstln_points()
|
|
|
|
{
|
|
|
|
if (!(*cstln)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cstln_rows.clear();
|
|
|
|
cstln_cols.clear();
|
|
|
|
|
|
|
|
for (int i = 0; i < (*cstln)->nsymbols; ++i)
|
|
|
|
{
|
2021-03-28 23:25:32 -04:00
|
|
|
std::complex<signed char> *p = &(*cstln)->symbols[i];
|
|
|
|
int x = 256 * (p->real() - xymin) / (xymax - xymin);
|
|
|
|
int y = 256 - 256 * (p->imag() - xymin) / (xymax - xymin);
|
2018-03-14 19:58:18 -04:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-02-24 18:07:08 -05:00
|
|
|
};
|
2018-02-22 16:52:49 -05:00
|
|
|
|
2019-03-16 20:36:44 -04:00
|
|
|
} // leansdr
|
2018-02-22 16:52:49 -05:00
|
|
|
|
|
|
|
#endif // DATVCONSTELLATION_H
|