Review changes
This commit is contained in:
@@ -6,10 +6,9 @@
|
||||
#include <WiFi.h>
|
||||
#include <esp_task_wdt.h>
|
||||
|
||||
#include "activities/network/SignalStrengthWidget.h"
|
||||
|
||||
#include "MappedInputManager.h"
|
||||
#include "WifiSelectionActivity.h"
|
||||
#include "activities/network/SignalStrengthWidget.h"
|
||||
#include "components/UITheme.h"
|
||||
#include "fontIds.h"
|
||||
|
||||
|
||||
@@ -377,8 +377,7 @@ void CrossPointWebServerActivity::render(RenderLock&&) {
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
} // namespace
|
||||
namespace {} // namespace
|
||||
|
||||
void CrossPointWebServerActivity::renderServerRunning() const {
|
||||
const auto& metrics = UITheme::getInstance().getMetrics();
|
||||
@@ -463,7 +462,8 @@ void CrossPointWebServerActivity::renderServerRunning() const {
|
||||
const int signalHeight = 22;
|
||||
const int signalWidth = contentRect.width - metrics.contentSidePadding * 2;
|
||||
const int signalY = startY + height10 + metrics.verticalSpacing * 2;
|
||||
drawWifiSignalStrength(renderer, contentRect.x + metrics.contentSidePadding, signalY, signalWidth, signalHeight, currentRssi);
|
||||
drawWifiSignalStrength(renderer, contentRect.x + metrics.contentSidePadding, signalY, signalWidth, signalHeight,
|
||||
currentRssi);
|
||||
renderer.drawCenteredText(SMALL_FONT_ID, signalY + signalHeight + 2, rssiLabel(currentRssi).c_str(), true);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <GfxRenderer.h>
|
||||
#include <I18n.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
inline StrId getRssiQualityStrId(int rssi) {
|
||||
@@ -21,18 +22,21 @@ inline StrId getRssiQualityStrId(int rssi) {
|
||||
inline void drawWifiSignalStrength(const GfxRenderer& renderer, int x, int y, int width, int height, int rssi) {
|
||||
const int barCount = 4;
|
||||
const int gap = 6;
|
||||
const int barWidth = std::min(10, (width - (barCount - 1) * gap) / barCount);
|
||||
const int barWidth = std::max(1, std::min(10, (width - (barCount - 1) * gap) / barCount));
|
||||
const int totalWidth = barCount * barWidth + (barCount - 1) * gap;
|
||||
const int startX = x + (width - totalWidth) / 2;
|
||||
const int maxBarHeight = height - 8;
|
||||
const int maxBarHeight = std::max(1, height - 8);
|
||||
const int bars = rssi == 0 ? 0 : (rssi <= -90 ? 1 : (rssi <= -75 ? 2 : (rssi <= -60 ? 3 : 4)));
|
||||
const int baseY = y + height - 2;
|
||||
for (int i = 0; i < barCount; ++i) {
|
||||
const int barHeight = ((i + 1) * maxBarHeight) / barCount;
|
||||
const int barHeight = std::max(0, ((i + 1) * maxBarHeight) / barCount);
|
||||
if (barHeight <= 0 || barWidth <= 0) {
|
||||
continue;
|
||||
}
|
||||
const int barX = startX + i * (barWidth + gap);
|
||||
const int barY = baseY - barHeight;
|
||||
renderer.drawRect(barX, barY, barWidth, barHeight, true);
|
||||
if (i < bars) {
|
||||
if (i < bars && barWidth > 2 && barHeight > 2) {
|
||||
renderer.fillRect(barX + 1, barY + 1, barWidth - 2, barHeight - 2);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user