Add display rotation config
This commit is contained in:
@@ -21,6 +21,7 @@ namespace config::server
|
||||
|
||||
cfg.display.rotation = std::stoi(ini.get("display", "rotation", "0"));
|
||||
cfg.display.refreshMs = std::chrono::milliseconds(std::stoi(ini.get("display", "refresh_ms", "1000")));
|
||||
cfg.display.framebuffer = ini.get("display", "framebuffer", "/dev/fb0");
|
||||
|
||||
cfg.network.listenPort = std::stoi(ini.get("network", "listen_port", "5005"));
|
||||
cfg.network.intervalMs = std::chrono::milliseconds(std::stoi(ini.get("network", "interval_ms", "1000")));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
|
||||
namespace config::server
|
||||
{
|
||||
@@ -8,5 +9,6 @@ namespace config::server
|
||||
{
|
||||
int rotation = 0;
|
||||
std::chrono::milliseconds refreshMs = std::chrono::milliseconds(1000);
|
||||
std::string framebuffer = "/dev/fb0";
|
||||
};
|
||||
} // namespace config::server
|
||||
|
||||
@@ -4,9 +4,9 @@ namespace display::graphics
|
||||
{
|
||||
enum class FramebufferRotation
|
||||
{
|
||||
R0,
|
||||
R90,
|
||||
R180,
|
||||
R270
|
||||
R0 = 0,
|
||||
R90 = 1,
|
||||
R180 = 2,
|
||||
R270 = 3
|
||||
};
|
||||
} // namespace display::graphics
|
||||
@@ -42,15 +42,15 @@ namespace display::ui::bar
|
||||
{
|
||||
int fillWidth = static_cast<int>(width * value);
|
||||
int overlayWidth = static_cast<int>(width * overlay_value);
|
||||
int overlayX = x + (overlayWidth - fillWidth);
|
||||
framebuffer.fillRect(overlayX, y, overlayWidth, height, display::graphics::White());
|
||||
int overlayX = x + (fillWidth - overlayWidth);
|
||||
framebuffer.drawRectDiagonalOverlay(overlayX, y + 1, overlayWidth, height - 2, style.border, 3);
|
||||
}
|
||||
else // Vertical
|
||||
{
|
||||
int fillHeight = static_cast<int>(height * value);
|
||||
int overlayHeight = static_cast<int>(height * overlay_value);
|
||||
int overlayY = y + (overlayHeight - fillHeight);
|
||||
framebuffer.fillRect(x, overlayY + (height - overlayHeight), width, overlayHeight, display::graphics::White());
|
||||
int overlayY = y + (fillHeight - overlayHeight);
|
||||
framebuffer.drawRectDiagonalOverlay(x + 1, overlayY + (height - overlayHeight), width - 2, overlayHeight, style.border, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "display/ui/hostblock/HostBlock.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
|
||||
#include "display/ui/bar/Orientation.h"
|
||||
#include "display/ui/bar/Style.h"
|
||||
@@ -49,7 +50,7 @@ namespace display::ui::hostblock
|
||||
cursorY,
|
||||
BLOCK_WIDTH - PADDING * 2,
|
||||
HEADER_HEIGHT,
|
||||
display::ui::theme::hostblock::HEADER);
|
||||
std::chrono::high_resolution_clock::now() - metrics.packetTimepoint < std::chrono::seconds(5) ? display::ui::theme::hostblock::HEADER : display::graphics::Red());
|
||||
|
||||
text.drawTextOutlined(
|
||||
fb,
|
||||
@@ -83,7 +84,7 @@ namespace display::ui::hostblock
|
||||
|
||||
cpuBar.draw(fb, bx, by, value);
|
||||
|
||||
value = std::clamp(metrics.cpu.coreTemps[i].current / (metrics.cpu.coreTemps[i].max == 0 ? 100.0f : metrics.cpu.coreTemps[i].max), 0.0f, 1.0f);
|
||||
value = std::clamp((metrics.cpu.coreTemps[i].current - CPU_BAR_TEMP_MIN) / ((metrics.cpu.coreTemps[i].max == 0 ? 100.0f : metrics.cpu.coreTemps[i].max) - CPU_BAR_TEMP_MIN), 0.0f, 1.0f);
|
||||
|
||||
cpuTempBar.draw(fb, bx + CPU_BAR_WIDTH - 1, by, value);
|
||||
}
|
||||
@@ -103,7 +104,7 @@ namespace display::ui::hostblock
|
||||
fb,
|
||||
x + PADDING,
|
||||
cursorY,
|
||||
std::clamp(memValue, 0.0f, 1.0f));
|
||||
std::clamp(memValue, 0.0f, 1.0f), std::clamp(hugepagesValue, 0.0f, 1.0f));
|
||||
text.drawTextOutlined(fb,
|
||||
x + MEM_BAR_TEXT_PADDING_X,
|
||||
cursorY + 8,
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace display::ui::hostblock
|
||||
constexpr int CPU_BAR_HEIGHT = 16; // 16
|
||||
constexpr int CPU_MAX_PER_ROW = 8; // 8
|
||||
constexpr int CPU_ROWS = 2; // 2
|
||||
constexpr int CPU_BAR_TEMP_MIN = 20;
|
||||
|
||||
// ===== Memory bar =====
|
||||
constexpr int MEM_BAR_HEIGHT = 11; // 8
|
||||
|
||||
@@ -14,7 +14,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
config::server::Config config = config::server::Config::load("/etc/esdashboard/server.ini");
|
||||
model::HostRegistry registry;
|
||||
display::graphics::Framebuffer fb("/dev/fb1", display::graphics::FramebufferRotation::R270);
|
||||
display::graphics::Framebuffer fb(config.display.framebuffer.c_str(), display::graphics::FramebufferRotation(config.display.rotation));
|
||||
display::graphics::Renderer renderer(fb, registry);
|
||||
network::Server server(config.network.listenPort, registry);
|
||||
|
||||
|
||||
@@ -120,6 +120,8 @@ namespace metrics
|
||||
h.disks.push_back(disk);
|
||||
}
|
||||
|
||||
h.packetTimepoint = std::chrono::high_resolution_clock::now();
|
||||
|
||||
return h;
|
||||
}
|
||||
} // namespace metrics
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <chrono>
|
||||
|
||||
#include "metrics/Cpu.h"
|
||||
#include "metrics/Memory.h"
|
||||
@@ -11,6 +12,7 @@ namespace metrics
|
||||
{
|
||||
struct Host
|
||||
{
|
||||
std::chrono::high_resolution_clock::time_point packetTimepoint;
|
||||
std::string hostname;
|
||||
Cpu cpu;
|
||||
Memory memory;
|
||||
|
||||
Reference in New Issue
Block a user