Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ping-viewer to work with ping2 #1058

Merged
merged 6 commits into from May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/link/ping1dsimulationlink.cpp
Expand Up @@ -14,7 +14,7 @@ void Ping1DSimulationLink::randomUpdate()
{
static uint counter = 1;
static const float numPoints = 200;
static const float maxDepth = 70000;
static const float maxDepth = 120000;
const float stop1 = numPoints / 2.0 - 10 * qSin(counter / 10.0);
const float stop2 = 3 * numPoints / 5.0 + 6 * qCos(counter / 5.5);
const float osc = maxDepth * (1.3 + qCos(counter / 40.0)) / 2.3;
Expand Down
10 changes: 7 additions & 3 deletions src/sensor/ping.cpp
Expand Up @@ -205,12 +205,16 @@ void Ping::handleMessage(const ping_message& msg)
_scan_start = m.scan_start();
_scan_length = m.scan_length();
_gain_setting = m.gain_setting();
// _num_points = m.profile_data_length(); // const for now
// memcpy(_points.data(), m.data(), _num_points); // careful with constant
_num_points = m.profile_data_length();

if (_num_points != _points.size()) {
_points.resize(_num_points);
}
#pragma omp for
// This is necessary to convert <uint8_t> to <int>
// QProperty only supports vector<int>, otherwise, we could use memcpy, like the two lines above
// QProperty only supports vector<int>, otherwise, we could use memcpy, like the two lines below:
// _num_points = m.profile_data_length(); // const for no
// memcpy(_points.data(), m.data(), _num_points); // careful with constant
for (int i = 0; i < m.profile_data_length(); i++) {
_points.replace(i, m.profile_data()[i] / 255.0);
}
Expand Down
6 changes: 3 additions & 3 deletions src/sensor/ping.h
Expand Up @@ -389,7 +389,7 @@ class Ping : public PingSensor {
uint16_t _processor_temperature;
///@}

static const uint16_t _num_points = 200;
uint16_t _num_points = 0;

/**
* @brief The points received by the sensor
Expand Down Expand Up @@ -497,10 +497,10 @@ class Ping : public PingSensor {
{{"3_gainIndex"},
{0, 0, 6, std::bind(&Ping::gain_setting, this), [this](long long int value) { set_gain_setting(value); }}},
{{"3_lengthDistance"},
{5000, 500, 70000, std::bind(&Ping::length_mm, this),
{5000, 500, 120000, std::bind(&Ping::length_mm, this),
[this](long long int value) { set_length_mm(value); }}},
{{"3_startDistance"},
{0, 0, 70000, std::bind(&Ping::start_mm, this), [this](long long int value) { set_start_mm(value); }}},
{0, 0, 120000, std::bind(&Ping::start_mm, this), [this](long long int value) { set_start_mm(value); }}},
};

struct messageStatus {
Expand Down
6 changes: 3 additions & 3 deletions src/waterfall/waterfallplot.cpp
Expand Up @@ -16,15 +16,15 @@ uint16_t WaterfallPlot::_displayWidth = 500;
WaterfallPlot::WaterfallPlot(QQuickItem* parent)
: Waterfall(parent)
, _currentDrawIndex(_displayWidth)
, _image(2048, 2500, QImage::Format_RGBA8888)
, _image(2048, 3500, QImage::Format_RGBA8888)
, _maxDepthToDrawInPixels(0)
, _minDepthToDrawInPixels(0)
, _mouseDepth(0)
, _painter(nullptr)
, _updateTimer(new QTimer(this))
{
// This is the max depth that ping returns
setWaterfallMaxDepth(70);
setMaxDepth(200);
_DCRing.fill({static_cast<float>(_image.height()), 0, 0, 0}, _displayWidth);
setAcceptedMouseButtons(Qt::AllButtons);
setAcceptHoverEvents(true);
Expand All @@ -37,7 +37,7 @@ WaterfallPlot::WaterfallPlot(QQuickItem* parent)
connect(this, &Waterfall::mousePosChanged, this, &WaterfallPlot::updateMouseColumnData);
}

void WaterfallPlot::setWaterfallMaxDepth(float maxDepth)
void WaterfallPlot::setMaxDepth(float maxDepth)
{
_waterfallDepth = maxDepth;
_minPixelsPerMeter = _image.height() / _waterfallDepth;
Expand Down
10 changes: 9 additions & 1 deletion src/waterfall/waterfallplot.h
Expand Up @@ -45,7 +45,15 @@ class WaterfallPlot : public Waterfall {
*
* @param maxDepth
*/
Q_INVOKABLE void setWaterfallMaxDepth(float maxDepth);
void setMaxDepth(float maxDepth);

/**
* @brief Get the waterfall max depth in meters
*
* @return float
*/
float maxDepth() const { return _waterfallDepth; };
Q_PROPERTY(float maxDepth READ maxDepth WRITE setMaxDepth)

/**
* @brief Draw a list of points in the waterfall
Expand Down