more unfinished changes, process tab for dashboard

This commit is contained in:
2026-09-30 14:26:50 +02:00
parent 0bfda04e91
commit 359f832609
98 changed files with 8633 additions and 2983 deletions
@@ -19,6 +19,8 @@ void CircularBuffer::setCapacity(int capacity) {
m_capacity = capacity;
m_data.resize(capacity);
m_data.fill(0.0);
m_smoothed.resize(capacity);
m_smoothed.fill(0.0);
m_head = 0;
m_count = 0;
@@ -30,6 +32,8 @@ void CircularBuffer::setCapacity(int capacity) {
m_count++;
}
recomputeAllSmoothed();
emit capacityChanged();
emit countChanged();
emit valuesChanged();
@@ -56,6 +60,19 @@ qreal CircularBuffer::maximum() const {
return maxVal;
}
int CircularBuffer::smoothingRadius() const {
return m_smoothingRadius;
}
void CircularBuffer::setSmoothingRadius(int radius) {
radius = std::max(0, radius);
if (m_smoothingRadius == radius) return;
m_smoothingRadius = radius;
recomputeAllSmoothed();
emit smoothingRadiusChanged();
emit valuesChanged();
}
void CircularBuffer::push(qreal value) {
if (m_capacity <= 0) return;
@@ -65,6 +82,9 @@ void CircularBuffer::push(qreal value) {
m_count++;
emit countChanged();
}
updateSmoothedTail();
emit valuesChanged();
}
@@ -85,4 +105,44 @@ qreal CircularBuffer::at(int index) const {
return m_data[actualIndex];
}
qreal CircularBuffer::smoothedAt(int index) const {
if (index < 0 || index >= m_count) return 0.0;
const int actualIndex =
(m_head - m_count + index + m_capacity) % m_capacity;
return m_smoothed[actualIndex];
}
void CircularBuffer::writeSmoothedAt(int logicalIndex) {
const int actualIndex =
(m_head - m_count + logicalIndex + m_capacity) % m_capacity;
if (m_smoothingRadius <= 0) {
m_smoothed[actualIndex] = m_data[actualIndex];
return;
}
qreal sum = 0.0;
int sampleCount = 0;
for (int j = -m_smoothingRadius; j <= m_smoothingRadius; ++j) {
const int idx = logicalIndex + j;
if (idx < 0 || idx >= m_count) continue;
const int a = (m_head - m_count + idx + m_capacity) % m_capacity;
sum += m_data[a];
sampleCount++;
}
m_smoothed[actualIndex] = sampleCount > 0 ? sum / sampleCount : 0.0;
}
void CircularBuffer::updateSmoothedTail() {
const int start = std::max(0, m_count - 1 - m_smoothingRadius);
for (int i = start; i < m_count; ++i)
writeSmoothedAt(i);
}
void CircularBuffer::recomputeAllSmoothed() {
for (int i = 0; i < m_count; ++i)
writeSmoothedAt(i);
}
} // namespace ZShell::internal