* @brief Updates the compass heading from the dashboard source. */
| 129 | * @brief Updates the compass heading from the dashboard source. |
| 130 | */ |
| 131 | void Widgets::Compass::updateData() |
| 132 | { |
| 133 | if (!isEnabled()) |
| 134 | return; |
| 135 | |
| 136 | if (!VALIDATE_WIDGET(SerialStudio::DashboardCompass, m_index)) |
| 137 | return; |
| 138 | |
| 139 | const auto& dataset = GET_DATASET(SerialStudio::DashboardCompass, m_index); |
| 140 | if (!std::isfinite(dataset.numericValue)) |
| 141 | return; |
| 142 | |
| 143 | double v = std::fmod(dataset.numericValue, 360.0); |
| 144 | if (v < 0.0) |
| 145 | v += 360.0; |
| 146 | |
| 147 | const auto card = cardinalDirection(v); |
| 148 | if (!DSP::notEqual(v, m_value) && card == m_cardinal) |
| 149 | return; |
| 150 | |
| 151 | m_value = v; |
| 152 | m_cardinal = card; |
| 153 | Q_EMIT updated(); |
| 154 | } |
| 155 | |
| 156 | //-------------------------------------------------------------------------------------------------- |
| 157 | // Cardinal resolver |
nothing calls this directly
no test coverage detected