Add global configuration

This commit is contained in:
2025-12-30 14:25:58 +00:00
parent b3ec7a01a7
commit 0470e8aecb
7 changed files with 49 additions and 6 deletions
+40
View File
@@ -116,6 +116,28 @@ namespace display::graphics
fillRect(x + w - 1, y, 1, h, color);
}
void Framebuffer::drawRectDiagonalOverlay(int x, int y, int w, int h, const Color &color, int step)
{
if (color.a == 0 || step <= 0)
return;
int x0 = std::max(0, x);
int y0 = std::max(0, y);
int x1 = std::min(logical.width, x + w);
int y1 = std::min(logical.height, y + h);
for (int py = y0; py < y1; ++py)
{
for (int px = x0; px < x1; ++px)
{
if (((px + py) % step) != 0)
continue;
setPixel(px, py, blend(getPixel(px, py), color));
}
}
}
void Framebuffer::setPixel(int x, int y, const Color &color)
{
if (x < 0 || x >= logical.width || y < 0 || y >= logical.height)
@@ -135,4 +157,22 @@ namespace display::graphics
c.a = 255;
return c;
}
Color Framebuffer::blend(const Color &dst, const Color &src)
{
if (src.a == 255)
return src;
if (src.a == 0)
return dst;
uint8_t inv = 255 - src.a;
Color out;
out.r = (dst.r * inv + src.r * src.a) / 255;
out.g = (dst.g * inv + src.g * src.a) / 255;
out.b = (dst.b * inv + src.b * src.a) / 255;
out.a = 255; // framebuffer всегда непрозрачный
return out;
}
} // namespace display::graphics
+2
View File
@@ -17,8 +17,10 @@ namespace display::graphics
void present();
void fillRect(int x, int y, int w, int h, const Color &color);
void drawRect(int x, int y, int w, int h, const Color &color);
void drawRectDiagonalOverlay(int x, int y, int w, int h, const Color &color, int step);
void setPixel(int x, int y, const Color &color);
Color getPixel(int x, int y) const;
Color blend(const Color &dst, const Color &src);
int getWidth() const { return logical.width; }
int getHeight() const { return logical.height; }
+2 -2
View File
@@ -54,7 +54,7 @@ namespace display::ui::hostblock
text.drawTextOutlined(
fb,
x + PADDING + 2,
cursorY + HEADER_HEIGHT - 3,
cursorY + HEADER_HEIGHT - 1,
hostname,
display::ui::theme::text::TEXT,
display::ui::theme::text::OUTLINE,
@@ -83,7 +83,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.0f, 1.0f);
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);
cpuTempBar.draw(fb, bx + CPU_BAR_WIDTH - 1, by, value);
}
+1 -1
View File
@@ -16,7 +16,7 @@ namespace display::ui::hostblock
constexpr int BLOCK_HEIGHT = 146; // 146
constexpr int PADDING = 5; // 5
constexpr int HEADER_HEIGHT = 12; // 12
constexpr int HEADER_HEIGHT = 7; // 12
constexpr std::string_view HEADER_FONT_NAME = "PixelFive-Regular";
constexpr int HEADER_FONT_SIZE = 5; // 10
constexpr int SECTION_GAP = 4; // 4
+2 -1
View File
@@ -38,7 +38,8 @@ namespace display::ui::text
void Fonts::loadAllFonts()
{
loadFonts("/usr/share/fonts/truetype");
loadFonts(helpers::initPaths().exeDir);
loadFonts("/usr/share/esdashboard/fonts");
// loadFonts(helpers::initPaths().exeDir);
}
void Fonts::loadFonts(const std::string &path)
+1 -1
View File
@@ -10,7 +10,7 @@
int main(int argc, char **argv)
{
config::client::Config config = config::client::Config::load("client.ini");
config::client::Config config = config::client::Config::load("/etc/esdashboard/client.ini");
network::Client client(config.network.serverHost, config.network.serverPort);
metrics::Collector collector(config.collector.disks);
network::Agent agent(std::move(client), std::move(collector), config.network.intervalMs);
+1 -1
View File
@@ -12,7 +12,7 @@
int main(int argc, char **argv)
{
config::server::Config config = config::server::Config::load("server.ini");
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::Renderer renderer(fb, registry);