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