AeroOS / kernel /src /apps /sysinfo.rs
Jaswanth-2008's picture
Upload AeroOS complete Rust source code
dcbeeb2 verified
Raw History Blame Contribute Delete
2.84 kB
extern crate alloc;
use alloc::format;
use core::sync::atomic::Ordering;
use crate::arch::idt::SYSTEM_TICKS;
use crate::graphics::color::Color;
use crate::graphics::icons::IconType;
use crate::graphics::surface::Surface;
pub struct SysInfoApp;
impl SysInfoApp {
pub fn new() -> Self {
Self
}
pub fn render(&self, surface: &mut Surface, x: i32, y: i32, w: usize, h: usize) {
surface.draw_rect(x, y, w, h, Color::rgb(26, 29, 38));
let ticks = SYSTEM_TICKS.load(Ordering::Relaxed);
let uptime_sec = ticks / 100;
// Header
surface.draw_icon_16(IconType::TaskManager, x + 16, y + 16, Color::rgb(40, 201, 64));
surface.draw_text("Task Manager & Hardware Monitor", x + 40, y + 16, Color::WHITE);
// CPU Sparkline Card
let card_w = w.saturating_sub(32);
surface.draw_rounded_rect(x + 16, y + 42, card_w, 80, 8, Color::rgb(34, 38, 50));
surface.draw_text("CPU Utilization (x86_64 @ 2.4 GHz): 4%", x + 28, y + 50, Color::TEXT_SECONDARY);
// Draw sparkline wave
let graph_x = x + 28;
let graph_y = y + 75;
let graph_w = card_w.saturating_sub(24);
surface.draw_rect(graph_x, graph_y, graph_w, 36, Color::rgb(22, 25, 34));
for i in 0..graph_w {
let sample = (((i as i32 * 5 + ticks as i32) % 36).abs() / 4) + 6;
surface.draw_rect(graph_x + i as i32, graph_y + 36 - sample, 1, sample as usize, Color::rgb(40, 201, 64));
}
// Memory Usage Card
surface.draw_rounded_rect(x + 16, y + 132, card_w, 70, 8, Color::rgb(34, 38, 50));
surface.draw_text("Memory: 16 MiB Heap (Kernel Space)", x + 28, y + 142, Color::TEXT_SECONDARY);
// Memory progress bar
let bar_x = x + 28;
let bar_y = y + 164;
let bar_w = card_w.saturating_sub(24);
surface.draw_rounded_rect(bar_x, bar_y, bar_w, 18, 4, Color::rgb(20, 22, 30));
let used_w = (bar_w * 22) / 100; // ~22% heap usage
surface.draw_rounded_rect(bar_x, bar_y, used_w, 18, 4, Color::ACCENT_BLUE);
surface.draw_text("3.5 MiB / 16.0 MiB Used (22%)", bar_x + 10, bar_y + 2, Color::WHITE);
// System details
let info_y = y + 215;
surface.draw_text("Operating System:", x + 20, info_y, Color::TEXT_SECONDARY);
surface.draw_text("AeroOS v1.0.0 (Rust Kernel)", x + 160, info_y, Color::WHITE);
surface.draw_text("Firmware / Arch:", x + 20, info_y + 20, Color::TEXT_SECONDARY);
surface.draw_text("UEFI x86_64 Long Mode", x + 160, info_y + 20, Color::WHITE);
surface.draw_text("System Uptime:", x + 20, info_y + 40, Color::TEXT_SECONDARY);
let uptime_str = format!("{} seconds", uptime_sec);
surface.draw_text(&uptime_str, x + 160, info_y + 40, Color::ACCENT_CYAN);
}
}